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

Skip to content

Commit 0cc6e68

Browse files
committed
Refactoring MySQL fingeprint.py (those payloads are now stored into session file too)
1 parent 5a8f94a commit 0cc6e68

1 file changed

Lines changed: 9 additions & 13 deletions

File tree

plugins/dbms/mysql/fingerprint.py

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ def _commentCheck(self):
3030
infoMsg = "executing %s comment injection fingerprint" % DBMS.MYSQL
3131
logger.info(infoMsg)
3232

33-
randInt = randomInt()
34-
result = inject.checkBooleanExpression("%d=%d/* NoValue */" % (randInt, randInt))
33+
result = inject.checkBooleanExpression("[RANDNUM]=[RANDNUM]/* NoValue */")
3534

3635
if not result:
3736
warnMsg = "unable to perform %s comment injection" % DBMS.MYSQL
@@ -57,9 +56,8 @@ def _commentCheck(self):
5756
for i in xrange(len(versions)):
5857
element = versions[i]
5958
version = element[0]
60-
randInt = randomInt()
6159
version = getUnicode(version)
62-
result = inject.checkBooleanExpression("%d=%d/*!%s AND %d=%d*/" % (randInt, randInt, version, randInt, randInt + 1))
60+
result = inject.checkBooleanExpression("[RANDNUM]=[RANDNUM]/*!%s AND [RANDNUM1]=[RANDNUM2]*/" % version)
6361

6462
if result:
6563
break
@@ -70,9 +68,8 @@ def _commentCheck(self):
7068
prevVer = None
7169

7270
for version in xrange(versions[index][0], versions[index][1] + 1):
73-
randInt = randomInt()
7471
version = getUnicode(version)
75-
result = inject.checkBooleanExpression("%d=%d/*!%s AND %d=%d*/" % (randInt, randInt, version, randInt, randInt + 1))
72+
result = inject.checkBooleanExpression("[RANDNUM]=[RANDNUM]/*!%s AND [RANDNUM1]=[RANDNUM2]*/" % version)
7673

7774
if result:
7875
if not prevVer:
@@ -167,7 +164,6 @@ def checkDbms(self):
167164
infoMsg = "testing %s" % DBMS.MYSQL
168165
logger.info(infoMsg)
169166

170-
randInt = getUnicode(randomInt(1))
171167
result = inject.checkBooleanExpression("QUARTER(NULL) IS NULL")
172168

173169
if result:
@@ -186,7 +182,7 @@ def checkDbms(self):
186182
# Reference: http://bugs.mysql.com/bug.php?id=15855
187183

188184
# Determine if it is MySQL >= 5.0.0
189-
if inject.checkBooleanExpression("ISNULL(TIMESTAMPADD(MINUTE,%s,%s))" % (randInt, randInt)):
185+
if inject.checkBooleanExpression("ISNULL(TIMESTAMPADD(MINUTE,[RANDNUM],[RANDNUM]))"):
190186
kb.data.has_information_schema = True
191187
Backend.setVersion(">= 5.0.0")
192188
setDbms("%s 5" % DBMS.MYSQL)
@@ -204,13 +200,13 @@ def checkDbms(self):
204200

205201
# Check if it is MySQL >= 5.1.2 and < 5.5.0
206202
elif inject.checkBooleanExpression("@@table_open_cache=@@table_open_cache"):
207-
if inject.checkBooleanExpression("%s=(SELECT %s FROM information_schema.GLOBAL_STATUS LIMIT 0, 1)" % (randInt, randInt)):
203+
if inject.checkBooleanExpression("[RANDNUM]=(SELECT [RANDNUM] FROM information_schema.GLOBAL_STATUS LIMIT 0, 1)"):
208204
Backend.setVersionList([">= 5.1.12", "< 5.5.0"])
209-
elif inject.checkBooleanExpression("%s=(SELECT %s FROM information_schema.PROCESSLIST LIMIT 0, 1)" % (randInt, randInt)):
205+
elif inject.checkBooleanExpression("[RANDNUM]=(SELECT [RANDNUM] FROM information_schema.PROCESSLIST LIMIT 0, 1)"):
210206
Backend.setVersionList([">= 5.1.7", "< 5.1.12"])
211-
elif inject.checkBooleanExpression("%s=(SELECT %s FROM information_schema.PARTITIONS LIMIT 0, 1)" % (randInt, randInt)):
207+
elif inject.checkBooleanExpression("[RANDNUM]=(SELECT [RANDNUM] FROM information_schema.PARTITIONS LIMIT 0, 1)"):
212208
Backend.setVersion("= 5.1.6")
213-
elif inject.checkBooleanExpression("%s=(SELECT %s FROM information_schema.PLUGINS LIMIT 0, 1)" % (randInt, randInt)):
209+
elif inject.checkBooleanExpression("[RANDNUM]=(SELECT [RANDNUM] FROM information_schema.PLUGINS LIMIT 0, 1)"):
214210
Backend.setVersionList([">= 5.1.5", "< 5.1.6"])
215211
else:
216212
Backend.setVersionList([">= 5.1.2", "< 5.1.5"])
@@ -220,7 +216,7 @@ def checkDbms(self):
220216
Backend.setVersionList([">= 5.0.38", "< 5.1.2"])
221217
elif inject.checkBooleanExpression("@@character_set_filesystem=@@character_set_filesystem"):
222218
Backend.setVersionList([">= 5.0.19", "< 5.0.38"])
223-
elif not inject.checkBooleanExpression("%s=(SELECT %s FROM DUAL WHERE %s!=%s)" % (randInt, randInt, randInt, randInt)):
219+
elif not inject.checkBooleanExpression("[RANDNUM]=(SELECT [RANDNUM] FROM DUAL WHERE [RANDNUM1]!=[RANDNUM2])"):
224220
Backend.setVersionList([">= 5.0.11", "< 5.0.19"])
225221
elif inject.checkBooleanExpression("@@div_precision_increment=@@div_precision_increment"):
226222
Backend.setVersionList([">= 5.0.6", "< 5.0.11"])

0 commit comments

Comments
 (0)