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

Skip to content

Commit a43eb64

Browse files
committed
Minor refactoring
1 parent f718425 commit a43eb64

2 files changed

Lines changed: 15 additions & 6 deletions

File tree

lib/core/common.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1165,7 +1165,6 @@ def profile(profileOutputFile=None, dotOutputFile=None, imageOutputFile=None):
11651165
gobject.timeout_add(1000, win.update, dotOutputFile)
11661166
gtk.main()
11671167

1168-
11691168
def getConsoleWidth(default=80):
11701169
width = None
11711170

@@ -1204,31 +1203,36 @@ def initCommonOutputs():
12041203
key = None
12051204

12061205
fileName = os.path.join(paths.SQLMAP_TXT_PATH, 'common-outputs.txt')
1207-
file = open(fileName, 'r')
1206+
cfile = open(fileName, 'r')
12081207

1209-
for line in file.xreadlines():
1208+
for line in cfile.xreadlines():
12101209
line = line.strip()
1210+
12111211
if len(line) > 1:
12121212
if line[0] == '[' and line[-1] == ']':
12131213
key = line[1:-1]
12141214
elif key:
12151215
if key not in kb.commonOutputs:
12161216
kb.commonOutputs[key] = []
1217+
12171218
kb.commonOutputs[key].append(line.strip())
1218-
file.close()
1219+
1220+
cfile.close()
12191221

12201222
def getGoodSamaritanCharsets(part, prevValue, originalCharset):
12211223
###wild card . (dot) is supported for compatibility with threading
1222-
if not kb.commonOutputs:
1224+
if kb.commonOutputs is None:
12231225
initCommonOutputs()
12241226

12251227
predictionSet = set()
12261228
wildIndexes = []
12271229

12281230
if prevValue[-1] != '.':
12291231
prevValue += '.'
1232+
12301233
charIndex = 0
12311234
findIndex = prevValue.find('.', charIndex)
1235+
12321236
while findIndex != -1:
12331237
wildIndexes.append(findIndex)
12341238
charIndex += 1
@@ -1239,16 +1243,21 @@ def getGoodSamaritanCharsets(part, prevValue, originalCharset):
12391243
if re.search('\A%s' % prevValue, item):
12401244
for index in wildIndexes:
12411245
char = item[index]
1246+
12421247
if char not in predictionSet:
12431248
predictionSet.add(char)
1249+
12441250
predictedCharset = []
12451251
otherCharset = []
1252+
12461253
for ordChar in originalTable:
12471254
if chr(ordChar) not in predictionSet:
12481255
otherCharset.append(ordChar)
12491256
else:
12501257
predictedCharset.append(ordChar)
1258+
12511259
predictedCharset.sort()
1260+
12521261
return predictedCharset, otherCharset
12531262
else:
12541263
return None, originalTable

lib/core/option.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -929,8 +929,8 @@ def __setKnowledgeBaseAttributes():
929929

930930
kb.absFilePaths = set()
931931
kb.bannerFp = advancedDict()
932-
kb.data = advancedDict()
933932
kb.commonOutputs = None
933+
kb.data = advancedDict()
934934

935935
# Basic back-end DBMS fingerprint
936936
kb.dbms = None

0 commit comments

Comments
 (0)