1313except ImportError , _ :
1414 from extra .fcrypt .fcrypt import crypt
1515
16+ import os
1617import re
1718import time
1819
3334from lib .core .common import normalizeUnicode
3435from lib .core .common import paths
3536from lib .core .common import readInput
37+ from lib .core .common import singleTimeLogMessage
38+ from lib .core .common import Wordlist
3639from lib .core .convert import hexdecode
3740from lib .core .convert import hexencode
3841from lib .core .convert import utf8encode
@@ -363,7 +366,6 @@ def dictionaryAttack(attack_dict):
363366 continue
364367
365368 if not kb .wordlist :
366-
367369 while not kb .wordlist :
368370 message = "what dictionary do you want to use?\n "
369371 message += "[1] Default (Press Enter)\n "
@@ -386,15 +388,10 @@ def dictionaryAttack(attack_dict):
386388 else :
387389 dictPaths = [paths .WORDLIST ]
388390
389- kb .wordlist = []
390-
391391 for dictPath in dictPaths :
392392 checkFile (dictPath )
393393
394- infoMsg = "loading dictionary from: '%s'" % dictPath
395- logger .info (infoMsg )
396-
397- kb .wordlist .extend (getFileItems (dictPath , None , False ))
394+ kb .wordlist = Wordlist (dictPaths )
398395
399396 except sqlmapFilePathException , msg :
400397 warnMsg = "there was a problem while loading dictionaries"
@@ -416,15 +413,20 @@ def dictionaryAttack(attack_dict):
416413 if user :
417414 kb .wordlist .append (normalizeUnicode (user ))
418415
419- length = len (kb .wordlist ) * len (suffix_list )
420-
421416 if hash_regex in (HASH .MYSQL , HASH .MYSQL_OLD , HASH .MD5_GENERIC , HASH .SHA1_GENERIC ):
422417 count = 0
423418
424419 for suffix in suffix_list :
425420 if not attack_info :
426421 break
427422
423+ if suffix :
424+ clearConsoleLine ()
425+ infoMsg = "using suffix: '%s'" % suffix
426+ logger .info (infoMsg )
427+
428+ kb .wordlist .rewind ()
429+
428430 for word in kb .wordlist :
429431 if not attack_info :
430432 break
@@ -458,8 +460,8 @@ def dictionaryAttack(attack_dict):
458460
459461 attack_info .remove (item )
460462
461- elif count % HASH_MOD_ITEM_DISPLAY == 0 or count == length or hash_regex in (HASH .ORACLE_OLD ) or hash_regex == HASH .CRYPT_GENERIC and IS_WIN :
462- status = '%d/%d words (%d%s )' % (count , length , round ( 100.0 * count / length ), '%' )
463+ elif count % HASH_MOD_ITEM_DISPLAY == 0 or hash_regex in (HASH .ORACLE_OLD ) or hash_regex == HASH .CRYPT_GENERIC and IS_WIN :
464+ status = 'current status: %d%s (%s... )' % (kb . wordlist . percentage ( ), '%' , word . ljust ( 5 )[: 5 ] )
463465 dataToStdout ("\r [%s] [INFO] %s" % (time .strftime ("%X" ), status ))
464466
465467 except KeyboardInterrupt :
@@ -484,6 +486,13 @@ def dictionaryAttack(attack_dict):
484486 if found :
485487 break
486488
489+ if suffix :
490+ clearConsoleLine ()
491+ infoMsg = "using suffix: '%s'" % suffix
492+ logger .info (infoMsg )
493+
494+ kb .wordlist .rewind ()
495+
487496 for word in kb .wordlist :
488497 current = __functions__ [hash_regex ](password = word , uppercase = False , ** kwargs )
489498 count += 1
@@ -512,8 +521,8 @@ def dictionaryAttack(attack_dict):
512521
513522 found = True
514523 break
515- elif count % HASH_MOD_ITEM_DISPLAY == 0 or count == length or hash_regex in (HASH .ORACLE_OLD ) or hash_regex == HASH .CRYPT_GENERIC and IS_WIN :
516- status = '%d/%d words (%d%s )' % (count , length , round ( 100.0 * count / length ), '%' )
524+ elif count % HASH_MOD_ITEM_DISPLAY == 0 or hash_regex in (HASH .ORACLE_OLD ) or hash_regex == HASH .CRYPT_GENERIC and IS_WIN :
525+ status = 'current status: %d%s (%s... )' % (kb . wordlist . percentage ( ), '%' , word . ljust ( 5 )[: 5 ] )
517526 if not user .startswith (DUMMY_USER_PREFIX ):
518527 status += ' (user: %s)' % user
519528 dataToStdout ("\r [%s] [INFO] %s" % (time .strftime ("%X" ), status ))
0 commit comments