Skip to content

Commit 17dbabf

Browse files
committed
-c option for conditionally included comments
1 parent a2dd248 commit 17dbabf

2 files changed

Lines changed: 24 additions & 9 deletions

File tree

htmlanalyzer/htmlanalyzer.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,26 @@
1414
# @TODO: args parser for: -c (comments) -s (links/src), -j (JavaScript)
1515

1616
# find interesting string(s)
17-
def analyze_line(_line, i):
17+
def analyze_line(_line, i, include_comments):
1818
"""single HTML source line - code analyze"""
19-
modules.detection_engine.detect_comments(_line, i)
19+
if include_comments == True:
20+
modules.detection_engine.detect_comments(_line, i)
21+
2022
modules.detection_engine.detect_admin_stuff(_line, i)
2123
modules.detection_engine.detect_debug(_line, i)
2224
modules.detection_engine.detect_external_resources(_line, i)
2325
modules.detection_engine.detect_javascript(_line, i)
2426
modules.detection_engine.detect_dombased_xss(_line, i)
2527

2628

27-
def main(_filename):
29+
def main(_filename, args):
2830
"""main program loop"""
2931
_ident = ""
3032
_fw = ""
3133

34+
# include comments?
35+
include_comments = True if args.c else False
36+
3237
try:
3338
_file = open(_filename, "r")
3439
print "[+] {} opened, starting analysis...\n\n".format(_filename)
@@ -42,7 +47,7 @@ def main(_filename):
4247

4348
for _line in _file:
4449
i += 1
45-
analyze_line(_line, i)
50+
analyze_line(_line, i, include_comments)
4651
if _ident == "":
4752
_ident = modules.detection_engine.identify(_line)
4853
if _fw == "":
@@ -58,6 +63,9 @@ def main(_filename):
5863
parser.add_argument(
5964
'-u', help='Target url - index.html will be downloaded')
6065
parser.add_argument('-f', help='HTML file name to analyze')
66+
parser.add_argument(
67+
'-c', help='include comments in summary (excluded by default)')
68+
6169
_filename = "index.html"
6270
args = parser.parse_args()
6371

@@ -68,4 +76,4 @@ def main(_filename):
6876
if args.f and not args.u:
6977
_filename = args.f
7078

71-
main(_filename)
79+
main(_filename, args)

htmlanalyzer/modules/detection_engine.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,21 @@ def detect_dombased_xss(_line, i):
3737
'document.url',
3838
'document.urlencoded',
3939
'document.referrer',
40-
'window.location'
40+
'window.location',
41+
'document.write(',
42+
'document.writeln('
43+
'.innerHTML',
44+
'eval(',
45+
'setInterval(',
46+
'setTimeout(',
47+
'Function('
4148
]
4249

4350
for dombased_call in dombased_calls:
4451
if dombased_call in _line.lower():
4552
print_output_line(i, ConsoleOutputBeautifier.getColor("red"),
4653
"POSSIBLE DOM BASED INJECTION POINT found at line %d: %s",
47-
(i, _line.lstrip().rstrip()), "DOM BASED XSS")
54+
(i, _line.lstrip().rstrip()[0:120] + '...'), "DOM BASED XSS")
4855

4956

5057
def detect_comments(_line, i):
@@ -53,11 +60,11 @@ def detect_comments(_line, i):
5360
if "\"/" in _line:
5461
print_output_line(i, ConsoleOutputBeautifier.getColor("red"),
5562
"COMMENTED PATH found at line %d: %s",
56-
(i, _line.lstrip().rstrip()), "COMMENT")
63+
(i, _line.lstrip().rstrip()[0:120] + '...'), "COMMENT")
5764
else:
5865
print_output_line(i, ConsoleOutputBeautifier.getColor("yellow"),
5966
"COMMENT found at line %d: %s",
60-
(i, _line.lstrip().rstrip()), "COMMENT")
67+
(i, _line.lstrip().rstrip()[0:120] + '...'), "COMMENT")
6168

6269

6370
def detect_admin_stuff(_line, i):

0 commit comments

Comments
 (0)