Minor optimizations

This commit is contained in:
Miroslav Stampar 2020-01-25 23:37:57 +01:00
parent b2d6ab2949
commit 615ac3b733
3 changed files with 26 additions and 35 deletions

View File

@ -18,7 +18,7 @@ from lib.core.enums import OS
from thirdparty.six import unichr as _unichr
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
VERSION = "1.4.1.50"
VERSION = "1.4.1.51"
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}
VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)

View File

@ -45,54 +45,43 @@ class Fingerprint(GenericFingerprint):
# Reference: https://dev.mysql.com/doc/relnotes/mysql/<major>.<minor>/en/
versions = (
(32200, 32235), # MySQL 3.22
(32300, 32359), # MySQL 3.23
(40000, 40032), # MySQL 4.0
(40100, 40131), # MySQL 4.1
(50000, 50097), # MySQL 5.0
(50100, 50174), # MySQL 5.1
(50400, 50404), # MySQL 5.4
(50500, 50562), # MySQL 5.5
(50600, 50648), # MySQL 5.6
(50700, 50730), # MySQL 5.7
(60000, 60014), # MySQL 6.0
(80000, 80021), # MySQL 8.0
(60000, 60014), # MySQL 6.0
(50700, 50731), # MySQL 5.7
(50600, 50649), # MySQL 5.6
(50500, 50563), # MySQL 5.5
(50400, 50404), # MySQL 5.4
(50100, 50174), # MySQL 5.1
(50000, 50097), # MySQL 5.0
(40100, 40131), # MySQL 4.1
(40000, 40032), # MySQL 4.0
(32300, 32359), # MySQL 3.23
(32200, 32235), # MySQL 3.22
)
index = -1
for i in xrange(len(versions)):
element = versions[i]
version = element[0]
version = getUnicode(version)
result = inject.checkBooleanExpression("[RANDNUM]=[RANDNUM]/*!%s AND [RANDNUM1]=[RANDNUM2]*/" % version)
found = False
for candidate in versions:
result = inject.checkBooleanExpression("[RANDNUM]=[RANDNUM]/*!%d AND [RANDNUM1]=[RANDNUM2]*/" % candidate[0])
if result:
if not result:
found = True
break
else:
index += 1
if index >= 0:
prevVer = None
for version in xrange(versions[index][0], versions[index][1] + 1):
if found:
for version in xrange(candidate[1], candidate[0] - 1, -1):
version = getUnicode(version)
result = inject.checkBooleanExpression("[RANDNUM]=[RANDNUM]/*!%s AND [RANDNUM1]=[RANDNUM2]*/" % version)
if result:
if not prevVer:
prevVer = version
if not result:
if version[0] == "3":
midVer = prevVer[1:3]
midVer = version[1:3]
else:
midVer = prevVer[2]
midVer = version[2]
trueVer = "%s.%s.%s" % (prevVer[0], midVer, prevVer[3:])
trueVer = "%s.%s.%s" % (version[0], midVer, version[3:])
return trueVer
prevVer = version
return None
def getFingerprint(self):

View File

@ -115,7 +115,9 @@ class Fingerprint(GenericFingerprint):
infoMsg = "actively fingerprinting %s" % DBMS.PGSQL
logger.info(infoMsg)
if inject.checkBooleanExpression("SHA256(NULL) IS NULL"):
if inject.checkBooleanExpression("SINH(0)=0"):
Backend.setVersion(">= 12.0")
elif inject.checkBooleanExpression("SHA256(NULL) IS NULL"):
Backend.setVersion(">= 11.0")
elif inject.checkBooleanExpression("XMLTABLE(NULL) IS NULL"):
Backend.setVersionList([">= 10.0", "< 11.0"])