Files
XSStrike/core/dom.py

27 lines
1.2 KiB
Python
Raw Normal View History

2018-10-27 18:58:52 +05:30
import re
from core.colors import red, end, yellow
2018-11-12 12:59:31 +05:30
def dom(response):
2018-10-27 18:58:52 +05:30
highlighted = []
response = response.split('\n')
2018-10-30 12:49:36 +05:30
sources = r"""location\.|\.([.\[]\s*["']?\s*arguments|dialogArguments|innerHTML|write|open|showModalDialog|cookie|URL|documentURI|baseURI|referrer|name|opener|parent|top|content|self|frames)[^\w\-]|(localStorage|sessionStorage|Database)[^\w\-]"""
sinks = r"""( (src|href|data|location|code|value|action)=)|(replace|assign|navigate|getResponseHeader|open|showModalDialog|eval|evaluate|execCommand|execScript|setTimeout|setInterval)\("""
2018-10-27 18:58:52 +05:30
num = 1
2018-11-12 23:31:57 +05:30
try:
for newLine in response:
line = newLine
pattern = re.findall(sources, line)
for grp in pattern:
source = ''.join(grp)
line = line.replace(source, yellow + source + end)
pattern = re.findall(sinks, line)
for grp in pattern:
sink = ''.join(grp)
line = line.replace(sink, red + sink + end)
if line != newLine:
highlighted.append('%-3s %s' % (str(num), line.lstrip(' ')))
num += 1
except MemoryError:
pass
2018-11-12 12:59:31 +05:30
return highlighted