Skip to content

Commit

Permalink
code cleanup in geoip modules
Browse files Browse the repository at this point in the history
  • Loading branch information
TheTechromancer committed Sep 13, 2023
1 parent 9f98071 commit ef6fae2
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
7 changes: 7 additions & 0 deletions bbot/modules/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,13 @@ def priority(self):
def auth_required(self):
return self.meta.get("auth_required", False)

@property
def http_timeout(self):
"""
Convenience shortcut to `http_timeout` in the config
"""
return self.scan.config.get("http_timeout", 10)

@property
def log(self):
if getattr(self, "_log", None) is None:
Expand Down
10 changes: 4 additions & 6 deletions bbot/modules/ip2location.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from .shodan_dns import shodan_dns
from bbot.modules.base import BaseModule


class IP2Location(shodan_dns):
class IP2Location(BaseModule):
"""
IP2Location.io Geolocation API.
"""
Expand All @@ -21,12 +21,10 @@ class IP2Location(shodan_dns):

base_url = "http://api.ip2location.io"

async def filter_event(self, event):
return True

async def setup(self):
await self.require_api_key()
self.lang = self.config.get("lang", "")
return await super().setup()
return True

async def ping(self):
url = self.build_url("8.8.8.8")
Expand Down
9 changes: 5 additions & 4 deletions bbot/modules/ipstack.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from bbot.modules.templates.subdomain_enum import subdomain_enum_apikey
from bbot.modules.base import BaseModule


class Ipstack(subdomain_enum_apikey):
class Ipstack(BaseModule):
"""
Ipstack GeoIP
Leverages the ipstack.com API to geolocate a host by IP address.
Expand All @@ -10,7 +10,7 @@ class Ipstack(subdomain_enum_apikey):
watched_events = ["IP_ADDRESS"]
produced_events = ["GEOLOCATION"]
flags = ["passive", "safe"]
meta = {"description": "Query IPStack's API for GeoIP ", "auth_required": True}
meta = {"description": "Query IPStack's GeoIP API", "auth_required": True}
options = {"api_key": ""}
options_desc = {"api_key": "IPStack GeoIP API Key"}
scope_distance_modifier = 1
Expand All @@ -19,7 +19,8 @@ class Ipstack(subdomain_enum_apikey):

base_url = "http://api.ipstack.com"

async def filter_event(self, event):
async def setup(self):
await self.require_api_key()
return True

async def ping(self):
Expand Down
2 changes: 0 additions & 2 deletions bbot/modules/templates/subdomain_enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ class subdomain_enum(BaseModule):

async def setup(self):
self.processed = set()
self.http_timeout = self.scan.config.get("http_timeout", 10)
self._failures = 0
return True

async def handle_event(self, event):
Expand Down

0 comments on commit ef6fae2

Please sign in to comment.