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

Skip to content

Commit 4bb5885

Browse files
committed
some changes regarding --common-outputs feature
1 parent 0450df8 commit 4bb5885

3 files changed

Lines changed: 69 additions & 25 deletions

File tree

lib/core/common.py

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@
5454
from lib.core.data import paths
5555
from lib.core.data import queries
5656
from lib.core.data import temp
57+
from lib.core.convert import md5hash
58+
from lib.core.convert import sha1hash
5759
from lib.core.convert import urlencode
5860
from lib.core.convert import utf8decode
5961
from lib.core.exception import sqlmapFilePathException
@@ -1224,7 +1226,9 @@ def initCommonOutputs():
12241226
if key not in kb.commonOutputs:
12251227
kb.commonOutputs[key] = []
12261228

1227-
kb.commonOutputs[key].append(line.strip())
1229+
item = line.strip()
1230+
if item not in kb.commonOutputs[key]:
1231+
kb.commonOutputs[key].append(item)
12281232

12291233
cfile.close()
12301234

@@ -1252,29 +1256,23 @@ def goGoodSamaritan(part, prevValue, originalCharset):
12521256
predictionSet = set()
12531257
wildIndexes = []
12541258
singleValue = None
1255-
reObj = getCompiledRegex('\A%s' % prevValue)
1256-
1257-
if prevValue[-1] != '.':
1258-
prevValue += '.'
1259-
1260-
charIndex = 0
1261-
findIndex = prevValue.find('.', charIndex)
1262-
1263-
while findIndex != -1:
1264-
wildIndexes.append(findIndex)
1265-
charIndex += 1
1266-
findIndex = prevValue.find('.', charIndex)
12671259

12681260
# If the header we are looking for has common outputs defined
12691261
if part in kb.commonOutputs:
12701262
for item in kb.commonOutputs[part]:
1263+
#if part == 'Passwords':
1264+
#if prevValue.startswith('*'): #MySQL_160bit
1265+
#return None, None, originalCharset
1266+
#if item not in kb.cache.md5:
1267+
#kb.cache.md5[item] = md5hash(item).upper()
1268+
#item = kb.cache.md5[item]
1269+
12711270
# Check if the common output (item) starts with prevValue
1272-
if reObj.search(item):
1271+
if item.startswith(prevValue):
12731272
singleValue = item
12741273

1275-
for index in wildIndexes:
1276-
char = item[index]
1277-
1274+
if len(item) > len(prevValue):
1275+
char = item[len(prevValue)]
12781276
if char not in predictionSet:
12791277
predictionSet.add(char)
12801278

lib/techniques/blind/inference.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -214,14 +214,13 @@ def getChar(idx, charTbl=asciiTbl, continuousOrder=True):
214214
else:
215215
if minValue == maxChar or maxValue == minChar:
216216
return None
217-
retVal = originalTbl[originalTbl.index(minValue) + 1]
218-
forgedPayload = safeStringFormat(payload.replace('%3E', '%3D'), (expressionUnescaped, idx, retVal))
219-
queriesCount[0] += 1
220-
result = Request.queryPage(urlencode(forgedPayload))
221-
if result:
222-
return chr(retVal) if retVal < 128 else unichr(retVal)
223-
else:
224-
return None
217+
for retVal in (originalTbl[originalTbl.index(minValue)], originalTbl[originalTbl.index(minValue) + 1]):
218+
forgedPayload = safeStringFormat(payload.replace('%3E', '%3D'), (expressionUnescaped, idx, retVal))
219+
queriesCount[0] += 1
220+
result = Request.queryPage(urlencode(forgedPayload))
221+
if result:
222+
return chr(retVal) if retVal < 128 else unichr(retVal)
223+
return None
225224

226225
def etaProgressUpdate(charTime, index):
227226
if len(progressTime) <= ( (length * 3) / 100 ):

txt/common-outputs.txt

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
[Databases]
2+
3+
#MySQL
24
information_schema
35
mysql
46
public
57
master
68

79
[Tables]
10+
11+
#MySQL
812
CHARACTER_SETS
913
COLLATION_CHARACTER_SET_APPLICABILITY
1014
COLLATIONS
@@ -33,3 +37,46 @@ TABLES
3337
TRIGGERS
3438
USER_PRIVILEGES
3539
VIEWS
40+
41+
#Oracle
42+
BONUS
43+
DEPT
44+
EMP
45+
SALGRADE
46+
USERS
47+
48+
[Passwords]
49+
50+
root
51+
test
52+
testpass
53+
password
54+
abc123
55+
qwertz
56+
12345
57+
123456
58+
59+
[Users]
60+
61+
#Oracle
62+
SCOTT
63+
MGMT_VIEW
64+
MDDATA
65+
SYSMAN
66+
MDSYS
67+
SI_INFORMTN_SCHEMA
68+
ORDPLUGINS
69+
ORDSYS
70+
OLAPSYS
71+
ANONYMOUS
72+
XDB
73+
CTXSYS
74+
EXFSYS
75+
WMSYS
76+
DBSNMP
77+
TSMSYS
78+
DMSYS
79+
DIP
80+
OUTLN
81+
SYSTEM
82+
SYS

0 commit comments

Comments
 (0)