|
15 | 15 | from lib.core.common import isAdminFromPrivileges |
16 | 16 | from lib.core.common import isInferenceAvailable |
17 | 17 | from lib.core.common import isNoneValue |
| 18 | +from lib.core.common import isNullValue |
18 | 19 | from lib.core.common import isNumPosStrValue |
19 | 20 | from lib.core.common import isTechniqueAvailable |
20 | 21 | from lib.core.common import parsePasswordHash |
@@ -203,8 +204,10 @@ def getPasswordHashes(self): |
203 | 204 | else: |
204 | 205 | values = inject.getValue(query, blind=False, time=False) |
205 | 206 |
|
206 | | - if isNoneValue(values) and Backend.isDbms(DBMS.MSSQL): |
| 207 | + if Backend.isDbms(DBMS.MSSQL) and isNoneValue(values): |
207 | 208 | values = inject.getValue(query.replace("master.dbo.fn_varbintohexstr", "sys.fn_sqlvarbasetostr"), blind=False, time=False) |
| 209 | + elif Backend.isDbms(DBMS.MYSQL) and (isNoneValue(values) or all(len(value) == 2 and (isNullValue(value[1]) or isNoneValue(value[1])) for value in values)): |
| 210 | + values = inject.getValue(query.replace("authentication_string", "password"), blind=False, time=False) |
208 | 211 |
|
209 | 212 | for user, password in filterPairValues(values): |
210 | 213 | if not user or user == " ": |
@@ -270,9 +273,13 @@ def getPasswordHashes(self): |
270 | 273 |
|
271 | 274 | count = inject.getValue(query, union=False, error=False, expected=EXPECTED.INT, charsetType=CHARSET_TYPE.DIGITS) |
272 | 275 |
|
273 | | - if not isNumPosStrValue(count) and Backend.isDbms(DBMS.MSSQL): |
274 | | - fallback = True |
275 | | - count = inject.getValue(query.replace("master.dbo.fn_varbintohexstr", "sys.fn_sqlvarbasetostr"), union=False, error=False, expected=EXPECTED.INT, charsetType=CHARSET_TYPE.DIGITS) |
| 276 | + if not isNumPosStrValue(count): |
| 277 | + if Backend.isDbms(DBMS.MSSQL): |
| 278 | + fallback = True |
| 279 | + count = inject.getValue(query.replace("master.dbo.fn_varbintohexstr", "sys.fn_sqlvarbasetostr"), union=False, error=False, expected=EXPECTED.INT, charsetType=CHARSET_TYPE.DIGITS) |
| 280 | + elif Backend.isDbms(DBMS.MYSQL): |
| 281 | + fallback = True |
| 282 | + count = inject.getValue(query.replace("authentication_string", "password"), union=False, error=False, expected=EXPECTED.INT, charsetType=CHARSET_TYPE.DIGITS) |
276 | 283 |
|
277 | 284 | if not isNumPosStrValue(count): |
278 | 285 | warnMsg = "unable to retrieve the number of password " |
@@ -307,6 +314,10 @@ def getPasswordHashes(self): |
307 | 314 | else: |
308 | 315 | query = rootQuery.blind.query % (user, index) |
309 | 316 |
|
| 317 | + if Backend.isDbms(DBMS.MYSQL): |
| 318 | + if fallback: |
| 319 | + query = query.replace("authentication_string", "password") |
| 320 | + |
310 | 321 | password = unArrayizeValue(inject.getValue(query, union=False, error=False)) |
311 | 322 | password = parsePasswordHash(password) |
312 | 323 |
|
|
0 commit comments