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

Skip to content

Commit 615ac3b

Browse files
committed
Minor optimizations
1 parent b2d6ab2 commit 615ac3b

3 files changed

Lines changed: 26 additions & 35 deletions

File tree

lib/core/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from thirdparty.six import unichr as _unichr
1919

2020
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
21-
VERSION = "1.4.1.50"
21+
VERSION = "1.4.1.51"
2222
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
2323
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}
2424
VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)

plugins/dbms/mysql/fingerprint.py

Lines changed: 22 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -45,54 +45,43 @@ def _commentCheck(self):
4545
# Reference: https://dev.mysql.com/doc/relnotes/mysql/<major>.<minor>/en/
4646

4747
versions = (
48-
(32200, 32235), # MySQL 3.22
49-
(32300, 32359), # MySQL 3.23
50-
(40000, 40032), # MySQL 4.0
51-
(40100, 40131), # MySQL 4.1
52-
(50000, 50097), # MySQL 5.0
53-
(50100, 50174), # MySQL 5.1
54-
(50400, 50404), # MySQL 5.4
55-
(50500, 50562), # MySQL 5.5
56-
(50600, 50648), # MySQL 5.6
57-
(50700, 50730), # MySQL 5.7
58-
(60000, 60014), # MySQL 6.0
5948
(80000, 80021), # MySQL 8.0
49+
(60000, 60014), # MySQL 6.0
50+
(50700, 50731), # MySQL 5.7
51+
(50600, 50649), # MySQL 5.6
52+
(50500, 50563), # MySQL 5.5
53+
(50400, 50404), # MySQL 5.4
54+
(50100, 50174), # MySQL 5.1
55+
(50000, 50097), # MySQL 5.0
56+
(40100, 40131), # MySQL 4.1
57+
(40000, 40032), # MySQL 4.0
58+
(32300, 32359), # MySQL 3.23
59+
(32200, 32235), # MySQL 3.22
6060
)
6161

62-
index = -1
63-
for i in xrange(len(versions)):
64-
element = versions[i]
65-
version = element[0]
66-
version = getUnicode(version)
67-
result = inject.checkBooleanExpression("[RANDNUM]=[RANDNUM]/*!%s AND [RANDNUM1]=[RANDNUM2]*/" % version)
62+
found = False
63+
for candidate in versions:
64+
result = inject.checkBooleanExpression("[RANDNUM]=[RANDNUM]/*!%d AND [RANDNUM1]=[RANDNUM2]*/" % candidate[0])
6865

69-
if result:
66+
if not result:
67+
found = True
7068
break
71-
else:
72-
index += 1
73-
74-
if index >= 0:
75-
prevVer = None
7669

77-
for version in xrange(versions[index][0], versions[index][1] + 1):
70+
if found:
71+
for version in xrange(candidate[1], candidate[0] - 1, -1):
7872
version = getUnicode(version)
7973
result = inject.checkBooleanExpression("[RANDNUM]=[RANDNUM]/*!%s AND [RANDNUM1]=[RANDNUM2]*/" % version)
8074

81-
if result:
82-
if not prevVer:
83-
prevVer = version
84-
75+
if not result:
8576
if version[0] == "3":
86-
midVer = prevVer[1:3]
77+
midVer = version[1:3]
8778
else:
88-
midVer = prevVer[2]
79+
midVer = version[2]
8980

90-
trueVer = "%s.%s.%s" % (prevVer[0], midVer, prevVer[3:])
81+
trueVer = "%s.%s.%s" % (version[0], midVer, version[3:])
9182

9283
return trueVer
9384

94-
prevVer = version
95-
9685
return None
9786

9887
def getFingerprint(self):

plugins/dbms/postgresql/fingerprint.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,9 @@ def checkDbms(self):
115115
infoMsg = "actively fingerprinting %s" % DBMS.PGSQL
116116
logger.info(infoMsg)
117117

118-
if inject.checkBooleanExpression("SHA256(NULL) IS NULL"):
118+
if inject.checkBooleanExpression("SINH(0)=0"):
119+
Backend.setVersion(">= 12.0")
120+
elif inject.checkBooleanExpression("SHA256(NULL) IS NULL"):
119121
Backend.setVersion(">= 11.0")
120122
elif inject.checkBooleanExpression("XMLTABLE(NULL) IS NULL"):
121123
Backend.setVersionList([">= 10.0", "< 11.0"])

0 commit comments

Comments
 (0)