Skip to content

Commit de0df99

Browse files
committed
Update regarding #3418 (fallback for MsSQL's --passwords)
1 parent ddee027 commit de0df99

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

lib/core/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from lib.core.enums import OS
2020

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

plugins/generic/users.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,9 @@ def getPasswordHashes(self):
201201
else:
202202
values = inject.getValue(query, blind=False, time=False)
203203

204+
if isNoneValue(values) and Backend.isDbms(DBMS.MSSQL):
205+
values = inject.getValue(query.replace("master.dbo.fn_varbintohexstr", "sys.fn_sqlvarbasetostr"), blind=False, time=False)
206+
204207
for user, password in filterPairValues(values):
205208
if not user or user == " ":
206209
continue
@@ -213,6 +216,8 @@ def getPasswordHashes(self):
213216
kb.data.cachedUsersPasswords[user].append(password)
214217

215218
if not kb.data.cachedUsersPasswords and isInferenceAvailable() and not conf.direct:
219+
fallback = False
220+
216221
if not len(users):
217222
users = self.getUsers()
218223

@@ -263,6 +268,10 @@ def getPasswordHashes(self):
263268

264269
count = inject.getValue(query, union=False, error=False, expected=EXPECTED.INT, charsetType=CHARSET_TYPE.DIGITS)
265270

271+
if not isNumPosStrValue(count) and Backend.isDbms(DBMS.MSSQL):
272+
fallback = True
273+
count = inject.getValue(query.replace("master.dbo.fn_varbintohexstr", "sys.fn_sqlvarbasetostr"), union=False, error=False, expected=EXPECTED.INT, charsetType=CHARSET_TYPE.DIGITS)
274+
266275
if not isNumPosStrValue(count):
267276
warnMsg = "unable to retrieve the number of password "
268277
warnMsg += "hashes for user '%s'" % user
@@ -283,10 +292,16 @@ def getPasswordHashes(self):
283292
query = rootQuery.blind.query2 % (user, index, user)
284293
else:
285294
query = rootQuery.blind.query % (user, index, user)
295+
296+
if fallback:
297+
query = query.replace("master.dbo.fn_varbintohexstr", "sys.fn_sqlvarbasetostr")
298+
286299
elif Backend.isDbms(DBMS.INFORMIX):
287300
query = rootQuery.blind.query % (user,)
301+
288302
elif Backend.isDbms(DBMS.HSQLDB):
289303
query = rootQuery.blind.query % (index, user)
304+
290305
else:
291306
query = rootQuery.blind.query % (user, index)
292307

txt/checksum.md5

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ c8c386d644d57c659d74542f5f57f632 lib/core/patch.py
4949
0c3eef46bdbf87e29a3f95f90240d192 lib/core/replication.py
5050
a7db43859b61569b601b97f187dd31c5 lib/core/revision.py
5151
fcb74fcc9577523524659ec49e2e964b lib/core/session.py
52-
03f706e4caefe69887515d9e7cb56748 lib/core/settings.py
52+
eb8b62b1dc94be51a6c3d44d47af8f4a lib/core/settings.py
5353
a971ce157d04de96ba6e710d3d38a9a8 lib/core/shell.py
5454
a7edc9250d13af36ac0108f259859c19 lib/core/subprocessng.py
5555
1581be48127a3a7a9fd703359b6e7567 lib/core/target.py
@@ -223,7 +223,7 @@ f7874230e5661910d5fd21544c7d1022 plugins/generic/misc.py
223223
30b421f06dc98998ddc1923a9048b7fc plugins/generic/search.py
224224
a70cc0ada4b0cc9e7df23cb6d48a4a0c plugins/generic/syntax.py
225225
f990d799e578dfbc3cde5728655a7854 plugins/generic/takeover.py
226-
1265241e309da72bb82c3863a4c1b4bd plugins/generic/users.py
226+
8ab0b84fda105459913715b98e1b8a4a plugins/generic/users.py
227227
1e5532ede194ac9c083891c2f02bca93 plugins/__init__.py
228228
5dc693e22f5d020c5c568d7325bd4226 shell/backdoors/backdoor.asp_
229229
158bfa168128393dde8d6ed11fe9a1b8 shell/backdoors/backdoor.aspx_

0 commit comments

Comments
 (0)