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

Skip to content

Commit 4741874

Browse files
committed
Enhancement to speedup MySQL fingerprint
1 parent e98b81f commit 4741874

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

plugins/dbms/mysql/fingerprint.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ def checkDbms(self):
178178
return False
179179

180180
# Determine if it is MySQL >= 5.0.0
181-
if inject.getValue("SELECT %s FROM information_schema.TABLES LIMIT 0, 1" % randInt, charsetType=2, suppressOutput=True) == randInt:
181+
if inject.checkBooleanExpression("%s=(SELECT %s FROM information_schema.TABLES LIMIT 0, 1)" % (randInt, randInt)):
182182
kb.data.has_information_schema = True
183183
kb.dbmsVersion = [">= 5.0.0"]
184184

@@ -190,26 +190,26 @@ def checkDbms(self):
190190
return True
191191

192192
# Check if it is MySQL >= 5.5.0
193-
if inject.getValue("SELECT MID(TO_SECONDS(950501), 1, 1)", unpack=False, charsetType=2, suppressOutput=True) == "6":
193+
if inject.checkBooleanExpression("6=(SELECT MID(TO_SECONDS(950501), 1, 1))"):
194194
kb.dbmsVersion = [">= 5.5.0"]
195195

196196
# Check if it is MySQL >= 5.1.2 and < 5.5.0
197197
elif inject.getValue("SELECT MID(@@table_open_cache, 1, 1)", unpack=False):
198-
if inject.getValue("SELECT %s FROM information_schema.GLOBAL_STATUS LIMIT 0, 1" % randInt, unpack=False, charsetType=2, suppressOutput=True) == randInt:
198+
if inject.checkBooleanExpression("%s=(SELECT %s FROM information_schema.GLOBAL_STATUS LIMIT 0, 1)" % (randInt, randInt)):
199199
kb.dbmsVersion = [">= 5.1.12", "< 5.5.0"]
200-
elif inject.getValue("SELECT %s FROM information_schema.PROCESSLIST LIMIT 0, 1" % randInt, unpack=False, charsetType=2, suppressOutput=True) == randInt:
200+
elif inject.checkBooleanExpression("%s=(SELECT %s FROM information_schema.PROCESSLIST LIMIT 0, 1)" % (randInt,randInt)):
201201
kb.dbmsVersion = [">= 5.1.7", "< 5.1.12"]
202-
elif inject.getValue("SELECT %s FROM information_schema.PARTITIONS LIMIT 0, 1" % randInt, unpack=False, charsetType=2, suppressOutput=True) == randInt:
202+
elif inject.checkBooleanExpression("%s=(SELECT %s FROM information_schema.PARTITIONS LIMIT 0, 1)" % (randInt, randInt)):
203203
kb.dbmsVersion = ["= 5.1.6"]
204-
elif inject.getValue("SELECT %s FROM information_schema.PLUGINS LIMIT 0, 1" % randInt, unpack=False, charsetType=2, suppressOutput=True) == randInt:
204+
elif inject.checkBooleanExpression("%s=(SELECT %s FROM information_schema.PLUGINS LIMIT 0, 1)" % (randInt, randInt)):
205205
kb.dbmsVersion = [">= 5.1.5", "< 5.1.6"]
206206
else:
207207
kb.dbmsVersion = [">= 5.1.2", "< 5.1.5"]
208208

209209
# Check if it is MySQL >= 5.0.0 and < 5.1.2
210210
elif inject.getValue("SELECT MID(@@hostname, 1, 1)", unpack=False, suppressOutput=True):
211211
kb.dbmsVersion = [">= 5.0.38", "< 5.1.2"]
212-
elif inject.getValue("SELECT 1 FROM DUAL", charsetType=1, suppressOutput=True) == "1":
212+
elif inject.checkBooleanExpression("%s=(SELECT %s FROM DUAL)" % (randInt, randInt)):
213213
kb.dbmsVersion = [">= 5.0.11", "< 5.0.38"]
214214
elif inject.getValue("SELECT DATABASE() LIKE SCHEMA()", suppressOutput=True):
215215
kb.dbmsVersion = [">= 5.0.2", "< 5.0.11"]
@@ -237,11 +237,11 @@ def checkDbms(self):
237237
elif inject.getValue("SELECT CURRENT_USER()", suppressOutput=True):
238238
kb.dbmsVersion = [">= 4.0.6", "< 4.1.1"]
239239

240-
if inject.getValue("SELECT CHARSET(CURRENT_USER())", suppressOutput=True) == "utf8":
240+
if inject.checkBooleanExpression("(SELECT CHARSET(CURRENT_USER()))='utf8'"):
241241
kb.dbmsVersion = ["= 4.1.0"]
242242
else:
243243
kb.dbmsVersion = [">= 4.0.6", "< 4.1.0"]
244-
elif inject.getValue("SELECT FOUND_ROWS()", charsetType=1, suppressOutput=True) == "0":
244+
elif inject.checkBooleanExpression("0=(SELECT FOUND_ROWS()"):
245245
kb.dbmsVersion = [">= 4.0.0", "< 4.0.6"]
246246
elif inject.getValue("SELECT CONNECTION_ID()", suppressOutput=True):
247247
kb.dbmsVersion = [">= 3.23.14", "< 4.0.0"]

0 commit comments

Comments
 (0)