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

Skip to content

Commit ce29c84

Browse files
committed
some comments added
1 parent 1a3dfd8 commit ce29c84

2 files changed

Lines changed: 19 additions & 3 deletions

File tree

lib/core/common.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1221,7 +1221,13 @@ def initCommonOutputs():
12211221
cfile.close()
12221222

12231223
def getGoodSamaritanParameters(part, prevValue, originalCharset):
1224-
###wild card . (dot) is supported for compatibility with threading
1224+
"""
1225+
Function for retrieving parameters needed for good samaritan (common outputs) feature.
1226+
Returns singleValue if there is a complete single match (in part of common-outputs.txt set by parameter 'part')
1227+
regarding parameter prevValue. If there is no single value match, but multiple, predictedCharset is returned
1228+
containing more probable characters (retrieved from matched items in common-outputs.txt) together with the
1229+
rest of charset as otherCharset
1230+
"""
12251231
if kb.commonOutputs is None:
12261232
initCommonOutputs()
12271233

@@ -1272,15 +1278,20 @@ def getGoodSamaritanParameters(part, prevValue, originalCharset):
12721278
return None, None, originalCharset
12731279

12741280
def getCompiledRegex(regex, args=()):
1281+
"""
1282+
Returns compiled regular expression and stores it in cache for further usage
1283+
"""
12751284
if regex in __compiledRegularExpressions:
12761285
return __compiledRegularExpressions[regex]
12771286
else:
12781287
retVal = re.compile(regex, *args)
12791288
__compiledRegularExpressions[regex] = retVal
12801289
return retVal
12811290

1282-
#dumper.dbTableValues(conf.dbmsHandler.dumpTable()) -> dumpTable
12831291
def getPartRun():
1292+
"""
1293+
Goes through call stack and finds constructs matching conf.dmbsHandler.*. Returns it or it's alias used in common-outputs.txt
1294+
"""
12841295
commonPartsDict = { "getTables":"Tables", "getColumns":"Columns", "getUsers":"Users", "getBanner":"Banners", "getDbs":"Databases" }
12851296
retVal = None
12861297
stack = [item[4][0] if isinstance(item[4], list) else '' for item in inspect.stack()]

lib/techniques/blind/inference.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def bisection(payload, expression, length=None, charsetType=None, firstChar=None
5757

5858
asciiTbl = getCharset(charsetType)
5959

60-
kb.partRun = getPartRun() if conf.useCommonPrediction else None
60+
kb.partRun = getPartRun() if conf.useCommonPrediction else None #set kb.partRun in case common-prediction used
6161

6262
if "LENGTH(" in expression or "LEN(" in expression:
6363
firstChar = 0
@@ -372,16 +372,20 @@ def downloadThread():
372372
index += 1
373373
charStart = time.time()
374374

375+
#common prediction (a.k.a. good samaritan)
375376
if conf.useCommonPrediction:
376377
singleValue, predictedCharset, otherCharset = getGoodSamaritanParameters(kb.partRun, finalValue, asciiTbl)
377378
val = None
378379

380+
#if there is no singleValue (single match from common-outputs.txt) use the returned predictedCharset
379381
if singleValue is None:
380382
val = getChar(index, predictedCharset, False) if predictedCharset else None
381383
else:
384+
#one shot query containing equals singleValue
382385
query = agent.prefixQuery(" %s" % safeStringFormat('AND (%s) = %s', (expressionUnescaped, unescaper.unescape('\'%s\'' % singleValue))))
383386
query = agent.postfixQuery(query)
384387
result = Request.queryPage(urlencode(agent.payload(newValue=query)))
388+
#did we have luck?
385389
if result:
386390
dataToSessionFile(replaceNewlineTabs(singleValue[index-1:]))
387391
if showEta:
@@ -390,6 +394,7 @@ def downloadThread():
390394
dataToStdout(singleValue[index-1:])
391395
finalValue = singleValue
392396
break
397+
#if we had no luck with singleValue and predictedCharset use the returned otherCharset
393398
if not val:
394399
val = getChar(index, otherCharset)
395400
else:

0 commit comments

Comments
 (0)