-
Notifications
You must be signed in to change notification settings - Fork 561
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Newsletters Module #1072
Merged
+509
−398
Merged
Newsletters Module #1072
Changes from 17 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
52429f3
Added Newsletter Module
stryker2k2 66a33f9
Now using helpers.request
stryker2k2 6fe98a7
truncate human output to prevent blockingioerror
TheTechromancer b427b17
fix truncate string bug
TheTechromancer f540811
Added/Fixed Newsletters Tests; which added Newsletters to the Docs
stryker2k2 923c3cb
Undo 'usage: pytest' and fix endline in Newsletter
stryker2k2 3ff3572
Fixed endline
stryker2k2 e73196c
run_tests, black, lint, etc
stryker2k2 0038030
Slimmed down module and using [FINDING] now
stryker2k2 88dc334
Merged dev -> newsletters
stryker2k2 161ec0a
black & remove unused variable
stryker2k2 b57e914
Added log to base.py, added await self.emit_event, fixed test to look…
stryker2k2 a8f53a0
black and code cleanup
stryker2k2 eccb7a9
Test now compares to 'host' or 'url'
stryker2k2 bb7a55c
Refined Newsletter Test, Updated Poetry, Ran Black
stryker2k2 0c13422
Ran Flake8 & Created lint-tests.sh
stryker2k2 040f72e
Newline & Remove 'logging'
stryker2k2 1466be3
Set Newsletter to 'active' and removed lint-tests
stryker2k2 8411acb
Removed lint-tests
stryker2k2 0e34a80
Merge branch 'dev' into newsletters
stryker2k2 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
__pycache__/ | ||
.coverage* |
Large diffs are not rendered by default.
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,46 @@ | ||
# Created a new module called 'newsletters' that will scrape the websites (or recursive websites, | ||
# thanks to BBOT's sub-domain enumeration) looking for the presence of an 'email type' that also | ||
# contains a 'placeholder'. The combination of these two HTML items usually signify the presence | ||
# of an "Enter Your Email Here" type Newsletter Subscription service. This module could be used | ||
# to find newsletters for a future email bombing attack and/or find user-input fields that could | ||
# be be susceptible to overflows or injections. | ||
|
||
from .base import BaseModule | ||
import re | ||
from bs4 import BeautifulSoup | ||
|
||
# Known Websites with Newsletters | ||
# https://futureparty.com/ | ||
# https://www.marketingbrew.com/ | ||
# https://buffer.com/ | ||
# https://www.milkkarten.net/ | ||
# https://geekout.mattnavarra.com/ | ||
|
||
deps_pip = ["beautifulsoup4"] | ||
|
||
|
||
class newsletters(BaseModule): | ||
watched_events = ["HTTP_RESPONSE"] | ||
produced_events = ["FINDING"] | ||
flags = ["passive", "safe"] | ||
meta = {"description": "Searches for Newsletter Submission Entry Fields on Websites"} | ||
|
||
# Parse through Website to find a Text Entry Box of 'type = email' | ||
# and ensure that there is placeholder text within it. | ||
def find_type(self, soup): | ||
email_type = soup.find(type="email") | ||
if email_type: | ||
regex = re.compile(r"placeholder") | ||
if regex.search(str(email_type)): | ||
return True | ||
return False | ||
|
||
async def handle_event(self, event): | ||
if event.data["status_code"] == 200: | ||
soup = BeautifulSoup(event.data["body"], "html.parser") | ||
result = self.find_type(soup) | ||
if result: | ||
description = f"Found a Newsletter Submission Form that could be used for email bombing attacks" | ||
data = {"host": str(event.host), "description": description, "url": event.data["url"]} | ||
|
||
await self.emit_event(data, "FINDING", event) |
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
57 changes: 57 additions & 0 deletions
57
bbot/test/test_step_2/module_tests/test_module_newsletters.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,57 @@ | ||
from .base import ModuleTestBase | ||
|
||
# import logging | ||
|
||
|
||
class TestNewsletters(ModuleTestBase): | ||
found_tgt = "http://127.0.0.1:8888/found" | ||
missing_tgt = "http://127.0.0.1:8888/missing" | ||
targets = [found_tgt, missing_tgt] | ||
modules_overrides = ["speculate", "httpx", "newsletters"] | ||
|
||
html_with_newsletter = """ | ||
<input aria-required="true" | ||
class="form-input form-input-text required" | ||
data-at="form-email" | ||
data-describedby="form-validation-error-box-element-5" | ||
data-label-inside="Enter your email" | ||
id="field-5f329905b4bfe1027b44513f94b50363-0" | ||
name="Enter your email" | ||
placeholder="Enter your email" | ||
required="" | ||
title="Enter your email" | ||
type="email" value=""/> | ||
""" | ||
|
||
html_without_newsletter = """ | ||
<div> | ||
<h1>Example Domain</h1> | ||
<p>This domain is for use in illustrative examples in documents. You may use this | ||
domain in literature without prior coordination or asking for permission.</p> | ||
<p><a href="https://www.iana.org/domains/example">More information...</a></p> | ||
</div> | ||
""" | ||
|
||
async def setup_after_prep(self, module_test): | ||
request_args = dict(uri="/found", headers={"test": "header"}) | ||
respond_args = dict(response_data=self.html_with_newsletter) | ||
module_test.set_expect_requests(request_args, respond_args) | ||
request_args = dict(uri="/missing", headers={"test": "header"}) | ||
respond_args = dict(response_data=self.html_without_newsletter) | ||
module_test.set_expect_requests(request_args, respond_args) | ||
|
||
def check(self, module_test, events): | ||
found = False | ||
missing = True | ||
for event in events: | ||
# self.log.info(f"event type: {event.type}") | ||
if event.type == "FINDING": | ||
# self.log.info(f"event data: {event.data}") | ||
# Verify Positive Result | ||
if event.data["url"] == self.found_tgt: | ||
found = True | ||
# Verify Negative Result (should skip this statement if correct) | ||
elif event.data["url"] == self.missing_tgt: | ||
missing = False | ||
assert found, f"NEWSLETTER 'Found' Error - Expect status of True but got False" | ||
assert missing, f"NEWSLETTER 'Missing' Error - Expect status of True but got False" |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"passive" here should be "active" since it relies on web requests.