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

Skip to content

Commit 64f2afe

Browse files
committed
in a mood for more changes
1 parent 219628a commit 64f2afe

3 files changed

Lines changed: 25 additions & 19 deletions

File tree

lib/core/common.py

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,49 +1166,54 @@ def calculateDeltaSeconds(start, epsilon=0.05):
11661166

11671167
def initCommonOutputs():
11681168
kb.commonOutputs = {}
1169+
key = None
1170+
11691171
fileName = os.path.join(paths.SQLMAP_TXT_PATH, 'common-outputs.txt')
11701172
file = open(fileName, 'r')
1171-
key = None
1173+
11721174
for line in file.xreadlines():
11731175
line = line.strip()
11741176
if len(line) > 1:
11751177
if line[0] == '[' and line[-1] == ']':
11761178
key = line[1:-1]
11771179
elif key:
1178-
if key not in kb.commonTables:
1179-
kb.commonTables[key] = []
1180-
kb.commonTables[key].append(line.strip())
1180+
if key not in kb.commonOutputs:
1181+
kb.commonOutputs[key] = []
1182+
kb.commonOutputs[key].append(line.strip())
1183+
file.close()
11811184

1182-
def getGoodSamaritanCharsets(part, originalCharset):
1185+
def getGoodSamaritanCharsets(part, prevValue, originalCharset):
1186+
###wild card . (dot) is supported for compatibility with threading
11831187
if not kb.commonOutputs:
11841188
initCommonOutputs()
11851189

11861190
predictionSet = set()
11871191
wildIndexes = []
11881192

1189-
if value[-1] != '.':
1190-
value += '.'
1193+
if prevValue[-1] != '.':
1194+
prevValue += '.'
11911195
charIndex = 0
1192-
findIndex = value.find('.', charIndex)
1196+
findIndex = prevValue.find('.', charIndex)
11931197
while findIndex != -1:
11941198
wildIndexes.append(findIndex)
11951199
charIndex += 1
1196-
findIndex = value.find('.', charIndex)
1197-
if kb.dbms in kb.commonTables:
1198-
for item in kb.commonTables[kb.dbms]:
1199-
if re.search('\A%s' % value, item):
1200+
findIndex = prevValue.find('.', charIndex)
1201+
1202+
if part in kb.commonOutputs:
1203+
for item in kb.commonOutputs[kb.dbms]:
1204+
if re.search('\A%s' % prevValue, item):
12001205
for index in wildIndexes:
12011206
char = item[index]
12021207
if char not in predictionSet:
12031208
predictionSet.add(char)
1204-
predictionTable = []
1205-
otherTable = []
1209+
predictedCharset = []
1210+
otherCharset = []
12061211
for ordChar in originalTable:
12071212
if chr(ordChar) not in predictionSet:
1208-
otherTable.append(ordChar)
1213+
otherCharset.append(ordChar)
12091214
else:
1210-
predictionTable.append(ordChar)
1211-
predictionTable.sort()
1212-
return predictionTable, otherTable
1215+
predictedCharset.append(ordChar)
1216+
predictedCharset.sort()
1217+
return predictedCharset, otherCharset
12131218
else:
12141219
return None, originalTable

lib/core/option.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -954,6 +954,7 @@ def __setKnowledgeBaseAttributes():
954954
kb.osSP = None
955955

956956
kb.parenthesis = None
957+
kb.partRun = None
957958
kb.queryCounter = 0
958959
kb.resumedQueries = {}
959960
kb.stackedTest = None

lib/techniques/blind/inference.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ def downloadThread():
343343
charStart = time.time()
344344

345345
if conf.useCommonPrediction:
346-
predictedCharset, otherCharset = getGoodSamaritanCharsets(finalValue, asciiTbl)
346+
predictedCharset, otherCharset = getGoodSamaritanCharsets(kb.partRun, finalValue, asciiTbl)
347347
val = getChar(index, predictedCharset) if predictedCharset else None
348348
if not val:
349349
val = getChar(index, otherCharset)

0 commit comments

Comments
 (0)