-
Notifications
You must be signed in to change notification settings - Fork 561
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wrote tests, shodan_port --> internetdb
- Loading branch information
1 parent
899534c
commit 7849638
Showing
6 changed files
with
95 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from bbot.modules.templates.subdomain_enum import subdomain_enum | ||
|
||
|
||
class shodan(subdomain_enum): | ||
options = {"api_key": ""} | ||
options_desc = {"api_key": "Shodan API key"} | ||
|
||
base_url = "https://api.shodan.io" | ||
|
||
async def setup(self): | ||
await super().setup() | ||
self.api_key = None | ||
for module_name in ("shodan", "shodan_dns", "shodan_port"): | ||
module_config = self.scan.config.get("modules", {}).get(module_name, {}) | ||
api_key = module_config.get("api_key", "") | ||
if api_key: | ||
self.api_key = api_key | ||
break | ||
if not self.api_key: | ||
if self.auth_required: | ||
return None, "No API key set" | ||
try: | ||
await self.ping() | ||
self.hugesuccess(f"API is ready") | ||
return True | ||
except Exception as e: | ||
return None, f"Error with API ({str(e).strip()})" | ||
return True | ||
|
||
async def ping(self): | ||
url = f"{self.base_url}/api-info?key={self.api_key}" | ||
r = await self.request_with_fail_count(url) | ||
resp_content = getattr(r, "text", "") | ||
assert getattr(r, "status_code", 0) == 200, resp_content |
55 changes: 55 additions & 0 deletions
55
bbot/test/test_step_2/module_tests/test_module_internetdb.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
from .base import ModuleTestBase | ||
|
||
|
||
class TestInternetDB(ModuleTestBase): | ||
config_overrides = {"dns_resolution": True} | ||
|
||
async def setup_before_prep(self, module_test): | ||
module_test.scan.helpers.mock_dns( | ||
{ | ||
("blacklanternsecurity.com", "A"): "1.2.3.4", | ||
("autodiscover.blacklanternsecurity.com", "A"): "2.3.4.5", | ||
("mail.blacklanternsecurity.com", "A"): "3.4.5.6", | ||
} | ||
) | ||
|
||
module_test.httpx_mock.add_response( | ||
url="https://internetdb.shodan.io/1.2.3.4", | ||
json={ | ||
"cpes": [ | ||
"cpe:/a:microsoft:internet_information_services", | ||
"cpe:/a:microsoft:outlook_web_access:15.0.1367", | ||
], | ||
"hostnames": [ | ||
"autodiscover.blacklanternsecurity.com", | ||
"mail.blacklanternsecurity.com", | ||
], | ||
"ip": "1.2.3.4", | ||
"ports": [ | ||
25, | ||
80, | ||
443, | ||
], | ||
"tags": ["starttls", "self-signed", "eol-os"], | ||
"vulns": ["CVE-2021-26857", "CVE-2021-26855"], | ||
}, | ||
) | ||
|
||
def check(self, module_test, events): | ||
assert 9 == len([e for e in events if str(e.module) == "internetdb"]) | ||
assert 1 == len( | ||
[e for e in events if e.type == "DNS_NAME" and e.data == "autodiscover.blacklanternsecurity.com"] | ||
) | ||
assert 1 == len([e for e in events if e.type == "DNS_NAME" and e.data == "mail.blacklanternsecurity.com"]) | ||
assert 3 == len([e for e in events if e.type == "OPEN_TCP_PORT" and str(e.module) == "internetdb"]) | ||
assert 1 == len([e for e in events if e.type == "OPEN_TCP_PORT" and e.data == "blacklanternsecurity.com:443"]) | ||
assert 2 == len([e for e in events if e.type == "FINDING" and str(e.module) == "internetdb"]) | ||
assert 1 == len([e for e in events if e.type == "FINDING" and "CVE-2021-26857" in e.data["description"]]) | ||
assert 2 == len([e for e in events if e.type == "TECHNOLOGY" and str(e.module) == "internetdb"]) | ||
assert 1 == len( | ||
[ | ||
e | ||
for e in events | ||
if e.type == "TECHNOLOGY" and e.data["technology"] == "cpe:/a:microsoft:outlook_web_access:15.0.1367" | ||
] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters