Skip to content

Commit 54576ab

Browse files
committed
making a random choice from candidates
1 parent bbbcc95 commit 54576ab

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

lib/controller/checks.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"""
99

1010
import httplib
11+
import random
1112
import re
1213
import socket
1314
import time
@@ -349,10 +350,10 @@ def genCmpPayload():
349350
if not injectable and not conf.string and kb.pageStable:
350351
trueSet = set(extractTextTagContent(truePage))
351352
falseSet = set(extractTextTagContent(falsePage))
352-
candidate = reduce(lambda x, y: x or (y.strip() if y.strip() in (kb.pageTemplate or "") and y.strip() not in falsePage else None), (trueSet - falseSet), None)
353-
if candidate:
354-
conf.string = candidate
355-
infoMsg = "%s parameter '%s' seems to be '%s' injectable (with --string=%s)" % (place, parameter, title, repr(candidate).lstrip('u'))
353+
candidates = filter(None, (_.strip() if _.strip() in (kb.pageTemplate or "") and _.strip() not in falsePage else None for _ in (trueSet - falseSet)))
354+
if candidates:
355+
conf.string = random.sample(candidates, 1)[0]
356+
infoMsg = "%s parameter '%s' seems to be '%s' injectable (with --string=%s)" % (place, parameter, title, repr(conf.string).lstrip('u'))
356357
logger.info(infoMsg)
357358

358359
injectable = True

0 commit comments

Comments
 (0)