Skip to content

Commit

Permalink
Added output to gather in scope email addresses to file
Browse files Browse the repository at this point in the history
  • Loading branch information
domwhewell-sage committed Dec 22, 2023
1 parent 6603724 commit da1c4e6
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
35 changes: 35 additions & 0 deletions bbot/modules/output/email_addresses.py
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 bbot/test/test_step_2/module_tests/test_module_email_addresses.py
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]"}

0 comments on commit da1c4e6

Please sign in to comment.