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

Skip to content

Commit 056d1ad

Browse files
committed
new commit regarding good samaritan feature
1 parent 2a1dd49 commit 056d1ad

3 files changed

Lines changed: 28 additions & 12 deletions

File tree

lib/core/common.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1224,6 +1224,9 @@ def getGoodSamaritanCharsets(part, prevValue, originalCharset):
12241224
if kb.commonOutputs is None:
12251225
initCommonOutputs()
12261226

1227+
if not part or not prevValue: #is not None and != ""
1228+
return None, originalCharset
1229+
12271230
predictionSet = set()
12281231
wildIndexes = []
12291232

@@ -1239,7 +1242,7 @@ def getGoodSamaritanCharsets(part, prevValue, originalCharset):
12391242
findIndex = prevValue.find('.', charIndex)
12401243

12411244
if part in kb.commonOutputs:
1242-
for item in kb.commonOutputs[kb.dbms]:
1245+
for item in kb.commonOutputs[part]:
12431246
if re.search('\A%s' % prevValue, item):
12441247
for index in wildIndexes:
12451248
char = item[index]
@@ -1250,7 +1253,7 @@ def getGoodSamaritanCharsets(part, prevValue, originalCharset):
12501253
predictedCharset = []
12511254
otherCharset = []
12521255

1253-
for ordChar in originalTable:
1256+
for ordChar in originalCharset:
12541257
if chr(ordChar) not in predictionSet:
12551258
otherCharset.append(ordChar)
12561259
else:
@@ -1260,7 +1263,7 @@ def getGoodSamaritanCharsets(part, prevValue, originalCharset):
12601263

12611264
return predictedCharset, otherCharset
12621265
else:
1263-
return None, originalTable
1266+
return None, originalCharset
12641267

12651268
def getCompiledRegex(regex):
12661269
if regex in __compiledRegularExpressions:

lib/techniques/blind/inference.py

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -141,12 +141,23 @@ def tryHint(idx):
141141

142142
return None
143143

144-
def getChar(idx, charTbl=asciiTbl):
144+
def getChar(idx, charTbl=asciiTbl, sequentialOrder=True):
145145
result = tryHint(idx)
146146

147147
if result:
148148
return result
149149

150+
if not sequentialOrder:
151+
originalTbl = list(charTbl)
152+
153+
if len(charTbl) == 1:
154+
forgedPayload = safeStringFormat(payload.replace('%3E', '%3D'), (expressionUnescaped, idx, charTbl[0]))
155+
result = Request.queryPage(urlencode(forgedPayload))
156+
if result:
157+
return chr(charTbl[0]) if charTbl[0] < 128 else unichr(charTbl[0])
158+
else:
159+
return None
160+
150161
maxChar = maxValue = charTbl[-1]
151162
minValue = charTbl[0]
152163

@@ -189,15 +200,14 @@ def getChar(idx, charTbl=asciiTbl):
189200
if maxValue == 1:
190201
return None
191202
elif minValue == maxChar:
192-
charTbl = xrange( maxChar + 1, (maxChar + 1) << 8 )
203+
charTbl = xrange(maxChar + 1, (maxChar + 1) << 8)
193204
maxChar = maxValue = charTbl[-1]
194205
minValue = charTbl[0]
195-
else:
206+
elif sequentialOrder:
196207
retVal = minValue + 1
197-
if retVal < 128:
198-
return chr(retVal)
199-
else:
200-
return unichr(retVal)
208+
return chr(retVal) if retVal < 128 else unichr(retVal)
209+
else:
210+
retVal = originalTbl[originalTbl.index(minValue) + 1]
201211

202212
def etaProgressUpdate(charTime, index):
203213
if len(progressTime) <= ( (length * 3) / 100 ):
@@ -361,7 +371,7 @@ def downloadThread():
361371

362372
if conf.useCommonPrediction:
363373
predictedCharset, otherCharset = getGoodSamaritanCharsets(kb.partRun, finalValue, asciiTbl)
364-
val = getChar(index, predictedCharset) if predictedCharset else None
374+
val = getChar(index, predictedCharset, False) if predictedCharset else None
365375
if not val:
366376
val = getChar(index, otherCharset)
367377
else:

txt/common-outputs.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
[Tables]
2-
users
2+
users
3+
4+
[Users]
5+
luther

0 commit comments

Comments
 (0)