@@ -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
0 commit comments