Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0f8a551

Browse files
committed
Potential patch for #1636
1 parent 3c9be94 commit 0f8a551

2 files changed

Lines changed: 20 additions & 2 deletions

File tree

lib/techniques/blind/inference.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
See the file 'doc/COPYING' for copying permission
66
"""
77

8+
import re
89
import threading
910
import time
1011

@@ -25,6 +26,7 @@
2526
from lib.core.common import hashDBRetrieve
2627
from lib.core.common import hashDBWrite
2728
from lib.core.common import incrementCounter
29+
from lib.core.common import randomInt
2830
from lib.core.common import safeStringFormat
2931
from lib.core.common import singleTimeWarnMessage
3032
from lib.core.data import conf
@@ -42,6 +44,7 @@
4244
from lib.core.settings import INFERENCE_GREATER_CHAR
4345
from lib.core.settings import INFERENCE_EQUALS_CHAR
4446
from lib.core.settings import INFERENCE_NOT_EQUALS_CHAR
47+
from lib.core.settings import MIN_TIME_RESPONSES
4548
from lib.core.settings import MAX_BISECTION_LENGTH
4649
from lib.core.settings import MAX_TIME_REVALIDATION_STEPS
4750
from lib.core.settings import PARTIAL_HEX_VALUE_MARKER
@@ -267,6 +270,21 @@ def getChar(idx, charTbl=None, continuousOrder=True, expand=charsetType is None,
267270
unescapedCharValue = unescaper.escape("'%s'" % decodeIntToUnicode(posValue))
268271
forgedPayload = safeStringFormat(payload, (expressionUnescaped, idx)).replace(markingValue, unescapedCharValue)
269272

273+
if timeBasedCompare and kb.whereCollectTimes:
274+
kb.responseTimes = []
275+
276+
warnMsg = "\n[%s] [WARNING] time-based comparison requires " % time.strftime("%X")
277+
warnMsg += "larger statistical model, please wait"
278+
dataToStdout(warnMsg)
279+
280+
while len(kb.responseTimes) < MIN_TIME_RESPONSES:
281+
falseWherePayload = re.sub(r"\b%s\b" % posValue, str(randomInt(6)), forgedPayload)
282+
Request.queryPage(falseWherePayload, content=True, raise404=False)
283+
dataToStdout('.')
284+
285+
dataToStdout("\n")
286+
kb.whereCollectTimes = False
287+
270288
result = Request.queryPage(forgedPayload, timeBasedCompare=timeBasedCompare, raise404=False)
271289
incrementCounter(kb.technique)
272290

plugins/generic/entries.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ def dumpTable(self, foundData=None):
237237
query = whereQuery(query)
238238

239239
if conf.dumpWhere:
240-
kb.whereResponseTimes = True
240+
kb.whereCollectTimes = True
241241
pushValue(kb.responseTimes)
242242

243243
count = inject.getValue(query, union=False, error=False, expected=EXPECTED.INT, charsetType=CHARSET_TYPE.DIGITS)
@@ -330,7 +330,7 @@ def dumpTable(self, foundData=None):
330330

331331
if conf.dumpWhere:
332332
kb.responseTimes = popValue()
333-
kb.whereResponseTimes = False
333+
kb.whereCollectTimes = False
334334

335335
for column, columnEntries in entries.items():
336336
length = max(lengths[column], len(column))

0 commit comments

Comments
 (0)