-
-
Notifications
You must be signed in to change notification settings - Fork 626
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
credshed module tests, optimizations
- Loading branch information
1 parent
3d316ca
commit d4568bb
Showing
5 changed files
with
172 additions
and
123 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 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
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,33 @@ | ||
from bbot.modules.base import BaseModule | ||
|
||
|
||
class credential_leak(BaseModule): | ||
""" | ||
A typical free API-based subdomain enumeration module | ||
Inherited by many other modules including sublist3r, dnsdumpster, etc. | ||
""" | ||
|
||
async def setup(self): | ||
self.queries_processed = set() | ||
self.data_seen = set() | ||
return True | ||
|
||
async def filter_event(self, event): | ||
query = self.make_query(event) | ||
query_hash = hash(query) | ||
if query_hash not in self.queries_processed: | ||
self.queries_processed.add(query_hash) | ||
return True | ||
return False, f'Already processed "{query}"' | ||
|
||
def make_query(self, event): | ||
if "target" in event.tags: | ||
return event.data | ||
_, domain = self.helpers.split_domain(event.data) | ||
return domain | ||
|
||
def already_seen(self, item): | ||
h = hash(item) | ||
already_seen = h in self.data_seen | ||
self.data_seen.add(h) | ||
return already_seen |
91 changes: 91 additions & 0 deletions
91
bbot/test/test_step_2/module_tests/test_module_credshed.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,91 @@ | ||
from .base import ModuleTestBase | ||
|
||
|
||
credshed_auth_response = { | ||
"access_token": "big_access_token", | ||
"login": True, | ||
} | ||
|
||
|
||
credshed_response = { | ||
"accounts": [ | ||
{ | ||
"e": "[email protected]", | ||
"h": [], | ||
"m": "hello my name is bob", | ||
"p": "", | ||
"s": [121562], | ||
"u": "", | ||
}, | ||
{ | ||
"e": "[email protected]", | ||
"h": [ | ||
"539FE8942DEADBEEFBC49E6EB2F175AC", | ||
"D2D8F0E9A4A2DEADBEEF1AC80F36D61F", | ||
"$2a$12$SHIC49jLIwsobdeadbeefuWb2BKWHUOk2yhpD77A0itiZI1vJqXHm", | ||
], | ||
"m": "hello my name is judy", | ||
"p": "", | ||
"s": [80437], | ||
"u": "", | ||
}, | ||
{ | ||
"e": "[email protected]", | ||
"h": [], | ||
"m": "hello my name is tim", | ||
"p": "TimTamSlam69", | ||
"s": [80437], | ||
"u": "tim", | ||
}, | ||
], | ||
"stats": { | ||
"accounts_searched": 9820758365, | ||
"elapsed": "0.00", | ||
"limit": 1000, | ||
"query": "blacklanternsecurity.com", | ||
"query_type": "domain", | ||
"sources_searched": 129957, | ||
"total_count": 3, | ||
"unique_count": 3, | ||
}, | ||
} | ||
|
||
|
||
class TestCredshed(ModuleTestBase): | ||
config_overrides = { | ||
"modules": {"credshed": {"username": "admin", "password": "password", "credshed_url": "https://credshed.com"}} | ||
} | ||
|
||
async def setup_before_prep(self, module_test): | ||
module_test.httpx_mock.add_response( | ||
url=f"https://credshed.com/api/auth", | ||
json=credshed_auth_response, | ||
method="POST", | ||
) | ||
module_test.httpx_mock.add_response( | ||
url=f"https://credshed.com/api/search", | ||
json=credshed_response, | ||
method="POST", | ||
) | ||
|
||
def check(self, module_test, events): | ||
assert len(events) == 10 | ||
assert 1 == len([e for e in events if e.type == "EMAIL_ADDRESS" and e.data == "[email protected]"]) | ||
assert 1 == len([e for e in events if e.type == "EMAIL_ADDRESS" and e.data == "[email protected]"]) | ||
assert 1 == len([e for e in events if e.type == "EMAIL_ADDRESS" and e.data == "[email protected]"]) | ||
assert 1 == len( | ||
[e for e in events if e.type == "HASHED_PASSWORD" and e.data == "539FE8942DEADBEEFBC49E6EB2F175AC"] | ||
) | ||
assert 1 == len( | ||
[e for e in events if e.type == "HASHED_PASSWORD" and e.data == "D2D8F0E9A4A2DEADBEEF1AC80F36D61F"] | ||
) | ||
assert 1 == len( | ||
[ | ||
e | ||
for e in events | ||
if e.type == "HASHED_PASSWORD" | ||
and e.data == "$2a$12$SHIC49jLIwsobdeadbeefuWb2BKWHUOk2yhpD77A0itiZI1vJqXHm" | ||
] | ||
) | ||
assert 1 == len([e for e in events if e.type == "PASSWORD" and e.data == "TimTamSlam69"]) | ||
assert 1 == len([e for e in events if e.type == "USERNAME" and e.data == "tim"]) |