Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion bbot/modules/emailformat.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,29 @@ class emailformat(BaseModule):

base_url = "https://www.email-format.com"

async def setup(self):
self.cfemail_regex = self.helpers.re.compile(r'data-cfemail="([0-9a-z]+)"')
return True

async def handle_event(self, event):
_, query = self.helpers.split_domain(event.data)
url = f"{self.base_url}/d/{self.helpers.quote(query)}/"
r = await self.api_request(url)
if not r:
return
for email in await self.helpers.re.extract_emails(r.text):

encrypted_emails = await self.helpers.re.findall(self.cfemail_regex, r.text)

for enc in encrypted_emails:
enc_len = len(enc)

if enc_len < 2 or enc_len % 2 != 0:
continue

key = int(enc[:2], 16)

email = "".join([chr(int(enc[i : i + 2], 16) ^ key) for i in range(2, enc_len, 2)]).lower()

if email.endswith(query):
await self.emit_event(
email,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class TestEmailFormat(ModuleTestBase):
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>info@blacklanternsecurity.com</a>",
text="""<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="0a63646c654a68666b6961666b647e6f7864796f697f78637e7324696567">[email&#160;protected]</a>""",
)

def check(self, module_test, events):
Expand Down
4 changes: 2 additions & 2 deletions bbot/test/test_step_2/module_tests/test_module_emails.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
from .base import ModuleTestBase


class TestEmais(ModuleTestBase):
class TestEmails(ModuleTestBase):
modules_overrides = ["emails", "emailformat", "skymem"]

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>info@blacklanternsecurity.com</p>",
text="""<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="0a63646c654a68666b6961666b647e6f7864796f697f78637e7324696567">[email&#160;protected]</a>""",
)
module_test.httpx_mock.add_response(
url="https://www.skymem.info/srch?q=blacklanternsecurity.com",
Expand Down
Loading