Skip to content
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

Update Wappalyzer and add support for cookie-based detections #424

Merged
merged 2 commits into from
Aug 18, 2021
Merged
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
13 changes: 11 additions & 2 deletions internal/devtools_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -946,7 +946,15 @@ def wappalyzer_detect(self, task, request_headers):
if self.devtools is not None:
try:
logging.debug('wappalyzer_detect')
detect_script = self.wappalyzer_script(request_headers)
cookies = {}
response = self.devtools.send_command("Storage.getCookies", {}, wait=True, timeout=30)
if response is not None and 'result' in response and 'cookies' in response['result']:
for cookie in response['result']['cookies']:
name = cookie['name'].lower()
if name not in cookies:
cookies[name] = []
cookies[name].append(cookie['value'])
detect_script = self.wappalyzer_script(request_headers, cookies)
response = self.devtools.send_command("Runtime.evaluate",
{'expression': detect_script,
'awaitPromise': True,
Expand All @@ -971,7 +979,7 @@ def wappalyzer_detect(self, task, request_headers):
task['page_data']['wappalyzer_failed'] = 1
self.profile_end('dtbrowser.wappalyzer_detect')

def wappalyzer_script(self, response_headers):
def wappalyzer_script(self, response_headers, cookies):
"""Build the wappalyzer script to run in-browser"""
script = None
try:
Expand Down Expand Up @@ -1012,6 +1020,7 @@ def wappalyzer_script(self, response_headers):
headers[key].append(value)
script = script.replace('%WAPPALYZER%', wappalyzer)
script = script.replace('%JSON%', json_data)
script = script.replace('%COOKIES%', json.dumps(cookies))
script = script.replace('%RESPONSE_HEADERS%', json.dumps(headers))
except Exception:
logging.exception('Error building wappalyzer script')
Expand Down
5 changes: 4 additions & 1 deletion internal/support/Wappalyzer/script.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
(async function() {
%WAPPALYZER%;
const json = %JSON%;
var responseHeaders = %RESPONSE_HEADERS%;
const cookies = %COOKIES%;
const responseHeaders = %RESPONSE_HEADERS%;
Wappalyzer.setTechnologies(json.technologies);
Wappalyzer.setCategories(json.categories);

Expand Down Expand Up @@ -35,13 +36,15 @@
},
{}
)

// Run the analysis
const detections = await Wappalyzer.analyze({
url: window.top.location.href,
html: new window.XMLSerializer().serializeToString(document),
css: css,
headers: responseHeaders,
meta: meta,
cookies: cookies,
scripts: scripts
});
const dom_detections = await analyzeDom(Wappalyzer.technologies);
Expand Down
Loading