@@ -201,6 +201,9 @@ def getPasswordHashes(self):
201
201
else :
202
202
values = inject .getValue (query , blind = False , time = False )
203
203
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
+
204
207
for user , password in filterPairValues (values ):
205
208
if not user or user == " " :
206
209
continue
@@ -213,6 +216,8 @@ def getPasswordHashes(self):
213
216
kb .data .cachedUsersPasswords [user ].append (password )
214
217
215
218
if not kb .data .cachedUsersPasswords and isInferenceAvailable () and not conf .direct :
219
+ fallback = False
220
+
216
221
if not len (users ):
217
222
users = self .getUsers ()
218
223
@@ -263,6 +268,10 @@ def getPasswordHashes(self):
263
268
264
269
count = inject .getValue (query , union = False , error = False , expected = EXPECTED .INT , charsetType = CHARSET_TYPE .DIGITS )
265
270
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
+
266
275
if not isNumPosStrValue (count ):
267
276
warnMsg = "unable to retrieve the number of password "
268
277
warnMsg += "hashes for user '%s'" % user
@@ -283,10 +292,16 @@ def getPasswordHashes(self):
283
292
query = rootQuery .blind .query2 % (user , index , user )
284
293
else :
285
294
query = rootQuery .blind .query % (user , index , user )
295
+
296
+ if fallback :
297
+ query = query .replace ("master.dbo.fn_varbintohexstr" , "sys.fn_sqlvarbasetostr" )
298
+
286
299
elif Backend .isDbms (DBMS .INFORMIX ):
287
300
query = rootQuery .blind .query % (user ,)
301
+
288
302
elif Backend .isDbms (DBMS .HSQLDB ):
289
303
query = rootQuery .blind .query % (index , user )
304
+
290
305
else :
291
306
query = rootQuery .blind .query % (user , index )
292
307
0 commit comments