-
Notifications
You must be signed in to change notification settings - Fork 561
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
small tweaks, updated tests to use local server
- Loading branch information
1 parent
10ee86f
commit 5f040b4
Showing
5 changed files
with
127 additions
and
63 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
70 changes: 57 additions & 13 deletions
70
bbot/test/test_step_2/module_tests/test_module_dastardly.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 |
---|---|---|
@@ -1,19 +1,63 @@ | ||
import json | ||
from werkzeug import Response | ||
|
||
from .base import ModuleTestBase | ||
|
||
|
||
class TestDastardly(ModuleTestBase): | ||
targets = ["ginandjuice.shop"] | ||
modules_overrides = ["nmap", "httpx", "dastardly"] | ||
targets = ["http://127.0.0.1:8888/"] | ||
modules_overrides = ["httpx", "dastardly"] | ||
|
||
web_response = """<!DOCTYPE html> | ||
<html> | ||
<body> | ||
<a href="/test?test=yes">visit this<a/> | ||
</body> | ||
</html>""" | ||
|
||
def xss_handler(self, request): | ||
response = f"""<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Email Form</title> | ||
</head> | ||
<body> | ||
{request.args.get("test", "")} | ||
</body> | ||
</html>""" | ||
return Response(response, content_type="text/html") | ||
|
||
async def get_docker_ip(self, module_test): | ||
docker_ip = "172.17.0.1" | ||
try: | ||
ip_output = await module_test.scan.helpers.run(["ip", "-j", "-4", "a", "show", "dev", "docker0"]) | ||
interface_json = json.loads(ip_output.stdout) | ||
docker_ip = interface_json[0]["addr_info"][0]["local"] | ||
except Exception: | ||
pass | ||
return docker_ip | ||
|
||
async def setup_after_prep(self, module_test): | ||
module_test.httpserver.expect_request("/").respond_with_data(self.web_response) | ||
module_test.httpserver.expect_request("/test").respond_with_handler(self.xss_handler) | ||
|
||
# get docker IP | ||
docker_ip = await self.get_docker_ip(module_test) | ||
module_test.scan.target.add_target(docker_ip) | ||
|
||
# replace 127.0.0.1 with docker host IP to allow dastardly access to local http server | ||
old_filter_event = module_test.module.filter_event | ||
|
||
def new_filter_event(event): | ||
self.new_url = f"http://{docker_ip}:8888/" | ||
event.data["url"] = self.new_url | ||
event.parsed = module_test.scan.helpers.urlparse(self.new_url) | ||
return old_filter_event(event) | ||
|
||
module_test.monkeypatch.setattr(module_test.module, "filter_event", new_filter_event) | ||
|
||
def check(self, module_test, events): | ||
reflected_xss = False | ||
vulnerable_js = False | ||
for e in events: | ||
if e.type == "VULNERABILITY": | ||
if "Cross-site scripting (reflected)" in e.data["description"]: | ||
reflected_xss = True | ||
if e.type == "VULNERABILITY": | ||
if "Vulnerable JavaScript dependency" in e.data["description"]: | ||
vulnerable_js = True | ||
assert reflected_xss | ||
assert vulnerable_js | ||
assert 1 == len([e for e in events if e.type == "VULNERABILITY"]) | ||
assert 1 == len( | ||
[e for e in events if e.type == "VULNERABILITY" and f"{self.new_url}test" in e.data["description"]] | ||
) |