|
34 | 34 | from lib.core.enums import DBMS |
35 | 35 | from lib.core.enums import HASH |
36 | 36 | from lib.core.exception import sqlmapUserQuitException |
| 37 | +from lib.core.settings import COMMON_PASSWORD_SUFFIXES |
37 | 38 | from lib.core.settings import DUMMY_USER_PREFIX |
38 | 39 |
|
39 | 40 | def mysql_passwd(password, uppercase=True): |
@@ -336,86 +337,113 @@ def dictionaryAttack(attack_dict): |
336 | 337 | logger.info(infoMsg) |
337 | 338 | kb.wordlist = getFileItems(dictpath, None, False) |
338 | 339 |
|
| 340 | + message = "do you want to use common password suffixes? (slow!) [y/N] " |
| 341 | + test = readInput(message, default="N") |
| 342 | + |
| 343 | + suffix_list = [""] |
| 344 | + if test[0] in ("y", "Y"): |
| 345 | + suffix_list = COMMON_PASSWORD_SUFFIXES |
| 346 | + |
339 | 347 | infoMsg = "starting dictionary attack (%s)" % __functions__[hash_regex].func_name |
340 | 348 | logger.info(infoMsg) |
341 | 349 |
|
342 | 350 | for item in attack_info: |
343 | 351 | ((user, _), _) = item |
344 | 352 | kb.wordlist.append(getUnicode(user)) |
345 | 353 |
|
346 | | - length = len(kb.wordlist) |
| 354 | + length = len(kb.wordlist) * len(suffix_list) |
347 | 355 |
|
348 | 356 | if hash_regex in (HASH.MYSQL, HASH.MYSQL_OLD, HASH.MD5_GENERIC, HASH.SHA1_GENERIC): |
349 | 357 | count = 0 |
350 | 358 |
|
351 | | - for word in kb.wordlist: |
352 | | - count += 1 |
| 359 | + for suffix in suffix_list: |
| 360 | + for word in kb.wordlist: |
| 361 | + count += 1 |
| 362 | + |
| 363 | + if suffix: |
| 364 | + word = word + suffix |
353 | 365 |
|
354 | | - try: |
355 | | - current = __functions__[hash_regex](password = word, uppercase = False) |
| 366 | + try: |
| 367 | + current = __functions__[hash_regex](password = word, uppercase = False) |
356 | 368 |
|
357 | | - for item in attack_info: |
358 | | - ((user, hash_), _) = item |
| 369 | + for item in attack_info: |
| 370 | + ((user, hash_), _) = item |
359 | 371 |
|
360 | | - if hash_ == current: |
361 | | - results.append((user, hash_, word)) |
362 | | - clearConsoleLine() |
| 372 | + if hash_ == current: |
| 373 | + results.append((user, hash_, word)) |
| 374 | + clearConsoleLine() |
363 | 375 |
|
364 | | - infoMsg = "[%s] [INFO] found: '%s'" % (time.strftime("%X"), word) |
| 376 | + infoMsg = "[%s] [INFO] found: '%s'" % (time.strftime("%X"), word) |
365 | 377 |
|
366 | | - if user and not user.startswith(DUMMY_USER_PREFIX): |
367 | | - infoMsg += " for user: '%s'\n" % user |
368 | | - else: |
369 | | - infoMsg += " for hash: '%s'\n" % hash_ |
| 378 | + if user and not user.startswith(DUMMY_USER_PREFIX): |
| 379 | + infoMsg += " for user: '%s'\n" % user |
| 380 | + else: |
| 381 | + infoMsg += " for hash: '%s'\n" % hash_ |
370 | 382 |
|
371 | | - dataToStdout(infoMsg, True) |
| 383 | + dataToStdout(infoMsg, True) |
372 | 384 |
|
373 | | - attack_info.remove(item) |
| 385 | + attack_info.remove(item) |
374 | 386 |
|
375 | | - elif count % 1117 == 0 or count == length or hash_regex in (HASH.ORACLE_OLD): |
376 | | - status = '%d/%d words (%d%s)' % (count, length, round(100.0*count/length), '%') |
377 | | - dataToStdout("\r[%s] [INFO] %s" % (time.strftime("%X"), status)) |
| 387 | + elif count % 1117 == 0 or count == length or hash_regex in (HASH.ORACLE_OLD): |
| 388 | + status = '%d/%d words (%d%s)' % (count, length, round(100.0*count/length), '%') |
| 389 | + dataToStdout("\r[%s] [INFO] %s" % (time.strftime("%X"), status)) |
378 | 390 |
|
379 | | - except: |
380 | | - warnMsg = "there was a problem while hashing entry: %s. " % repr(word) |
381 | | - warnMsg += "Please report by e-mail to [email protected]." |
382 | | - logger.critical(warnMsg) |
| 391 | + except KeyboardInterrupt: |
| 392 | + raise |
| 393 | + |
| 394 | + except: |
| 395 | + warnMsg = "there was a problem while hashing entry: %s. " % repr(word) |
| 396 | + warnMsg += "Please report by e-mail to [email protected]." |
| 397 | + logger.critical(warnMsg) |
383 | 398 |
|
384 | 399 | clearConsoleLine() |
385 | 400 |
|
386 | 401 | else: |
387 | 402 | for ((user, hash_), kwargs) in attack_info: |
388 | 403 | count = 0 |
| 404 | + found = False |
389 | 405 |
|
390 | | - for word in kb.wordlist: |
391 | | - current = __functions__[hash_regex](password = word, uppercase = False, **kwargs) |
392 | | - count += 1 |
393 | | - try: |
394 | | - if hash_ == current: |
395 | | - if regex == HASH.ORACLE_OLD: #only for cosmetic purposes |
396 | | - word = word.upper() |
397 | | - results.append((user, hash_, word)) |
398 | | - clearConsoleLine() |
| 406 | + for suffix in suffix_list: |
| 407 | + if found: |
| 408 | + break |
399 | 409 |
|
400 | | - infoMsg = "[%s] [INFO] found: '%s'" % (time.strftime("%X"), word) |
| 410 | + for word in kb.wordlist: |
| 411 | + current = __functions__[hash_regex](password = word, uppercase = False, **kwargs) |
| 412 | + count += 1 |
401 | 413 |
|
402 | | - if user and not user.startswith(DUMMY_USER_PREFIX): |
403 | | - infoMsg += " for user: '%s'\n" % user |
404 | | - else: |
405 | | - infoMsg += " for hash: '%s'\n" % hash_ |
| 414 | + if suffix: |
| 415 | + word = word + suffix |
406 | 416 |
|
407 | | - dataToStdout(infoMsg, True) |
| 417 | + try: |
| 418 | + if hash_ == current: |
| 419 | + if regex == HASH.ORACLE_OLD: #only for cosmetic purposes |
| 420 | + word = word.upper() |
| 421 | + results.append((user, hash_, word)) |
| 422 | + clearConsoleLine() |
408 | 423 |
|
409 | | - break |
| 424 | + infoMsg = "[%s] [INFO] found: '%s'" % (time.strftime("%X"), word) |
410 | 425 |
|
411 | | - elif count % 1117 == 0 or count == length or hash_regex in (HASH.ORACLE_OLD): |
412 | | - status = '%d/%d words (%d%s) (user: %s)' % (count, length, round(100.0*count/length), '%', user) |
413 | | - dataToStdout("\r[%s] [INFO] %s" % (time.strftime("%X"), status)) |
| 426 | + if user and not user.startswith(DUMMY_USER_PREFIX): |
| 427 | + infoMsg += " for user: '%s'\n" % user |
| 428 | + else: |
| 429 | + infoMsg += " for hash: '%s'\n" % hash_ |
414 | 430 |
|
415 | | - except: |
416 | | - warnMsg = "there was a problem while hashing entry: %s. " % repr(word) |
417 | | - warnMsg += "Please report by e-mail to [email protected]." |
418 | | - logger.critical(warnMsg) |
| 431 | + dataToStdout(infoMsg, True) |
| 432 | + |
| 433 | + found = True |
| 434 | + break |
| 435 | + |
| 436 | + elif count % 1117 == 0 or count == length or hash_regex in (HASH.ORACLE_OLD): |
| 437 | + status = '%d/%d words (%d%s) (user: %s)' % (count, length, round(100.0*count/length), '%', user) |
| 438 | + dataToStdout("\r[%s] [INFO] %s" % (time.strftime("%X"), status)) |
| 439 | + |
| 440 | + except KeyboardInterrupt: |
| 441 | + raise |
| 442 | + |
| 443 | + except: |
| 444 | + warnMsg = "there was a problem while hashing entry: %s. " % repr(word) |
| 445 | + warnMsg += "Please report by e-mail to [email protected]." |
| 446 | + logger.critical(warnMsg) |
419 | 447 |
|
420 | 448 | clearConsoleLine() |
421 | 449 |
|
|
0 commit comments