-
Notifications
You must be signed in to change notification settings - Fork 564
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added output to gather in scope email addresses to file
- Loading branch information
1 parent
6603724
commit da1c4e6
Showing
2 changed files
with
51 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from contextlib import suppress | ||
|
||
from bbot.modules.base import BaseModule | ||
from bbot.modules.output.human import Human | ||
|
||
|
||
class email_addresses(Human): | ||
watched_events = ["EMAIL_ADDRESS"] | ||
flags = ["subdomain-enum"] | ||
meta = {"description": "Output any email addresses found belonging to the target domain"} | ||
options = {"output_file": ""} | ||
options_desc = {"output_file": "Output to file"} | ||
in_scope_only = True | ||
|
||
output_filename = "email_addresses.txt" | ||
|
||
async def setup(self): | ||
return await super().setup() | ||
|
||
def _scope_distance_check(self, event): | ||
return BaseModule._scope_distance_check(self, event) | ||
|
||
async def handle_event(self, event): | ||
if self.file is not None: | ||
self.file.write(f"{event.data}\n") | ||
self.file.flush() | ||
|
||
async def cleanup(self): | ||
if getattr(self, "_file", None) is not None: | ||
with suppress(Exception): | ||
self.file.close() | ||
|
||
async def report(self): | ||
if getattr(self, "_file", None) is not None: | ||
self.info(f"Saved email addresses to {self.output_file}") |
16 changes: 16 additions & 0 deletions
16
bbot/test/test_step_2/module_tests/test_module_email_addresses.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,16 @@ | ||
from .base import ModuleTestBase | ||
|
||
|
||
class TestEmail_Addresses(ModuleTestBase): | ||
modules_overrides = ["email_addresses", "emailformat"] | ||
|
||
async def setup_before_prep(self, module_test): | ||
module_test.httpx_mock.add_response( | ||
url="https://www.email-format.com/d/blacklanternsecurity.com/", | ||
text="<p>[email protected]</a>", | ||
) | ||
|
||
def check(self, module_test, events): | ||
sub_file = module_test.scan.home / "email_addresses.txt" | ||
email_addresses = set(open(sub_file).read().splitlines()) | ||
assert email_addresses == {"[email protected]"} |