Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3873d20

Browse files
committed
important update for dictionary attack
1 parent e17ac5f commit 3873d20

2 files changed

Lines changed: 78 additions & 47 deletions

File tree

lib/core/settings.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,3 +175,6 @@
175175
)
176176

177177
META_CHARSET_REGEX = r'<meta http-equiv="Content-Type" content="[^"]*?charset=(?P<result>[^"]+)" />'
178+
179+
# Reference: http://www.the-interweb.com/serendipity/index.php?/archives/94-A-brief-analysis-of-40,000-leaked-MySpace-passwords.html
180+
COMMON_PASSWORD_SUFFIXES = ["", "1", "2", "123", "12", "3", "7", "07", "11", "4", "5", "!", ".", "*", "!!", "?", ";", "..", "!!!", ",", "@"]

lib/utils/hash.py

Lines changed: 75 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
from lib.core.enums import DBMS
3535
from lib.core.enums import HASH
3636
from lib.core.exception import sqlmapUserQuitException
37+
from lib.core.settings import COMMON_PASSWORD_SUFFIXES
3738
from lib.core.settings import DUMMY_USER_PREFIX
3839

3940
def mysql_passwd(password, uppercase=True):
@@ -336,86 +337,113 @@ def dictionaryAttack(attack_dict):
336337
logger.info(infoMsg)
337338
kb.wordlist = getFileItems(dictpath, None, False)
338339

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+
339347
infoMsg = "starting dictionary attack (%s)" % __functions__[hash_regex].func_name
340348
logger.info(infoMsg)
341349

342350
for item in attack_info:
343351
((user, _), _) = item
344352
kb.wordlist.append(getUnicode(user))
345353

346-
length = len(kb.wordlist)
354+
length = len(kb.wordlist) * len(suffix_list)
347355

348356
if hash_regex in (HASH.MYSQL, HASH.MYSQL_OLD, HASH.MD5_GENERIC, HASH.SHA1_GENERIC):
349357
count = 0
350358

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
353365

354-
try:
355-
current = __functions__[hash_regex](password = word, uppercase = False)
366+
try:
367+
current = __functions__[hash_regex](password = word, uppercase = False)
356368

357-
for item in attack_info:
358-
((user, hash_), _) = item
369+
for item in attack_info:
370+
((user, hash_), _) = item
359371

360-
if hash_ == current:
361-
results.append((user, hash_, word))
362-
clearConsoleLine()
372+
if hash_ == current:
373+
results.append((user, hash_, word))
374+
clearConsoleLine()
363375

364-
infoMsg = "[%s] [INFO] found: '%s'" % (time.strftime("%X"), word)
376+
infoMsg = "[%s] [INFO] found: '%s'" % (time.strftime("%X"), word)
365377

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_
370382

371-
dataToStdout(infoMsg, True)
383+
dataToStdout(infoMsg, True)
372384

373-
attack_info.remove(item)
385+
attack_info.remove(item)
374386

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))
378390

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)
383398

384399
clearConsoleLine()
385400

386401
else:
387402
for ((user, hash_), kwargs) in attack_info:
388403
count = 0
404+
found = False
389405

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
399409

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
401413

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
406416

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()
408423

409-
break
424+
infoMsg = "[%s] [INFO] found: '%s'" % (time.strftime("%X"), word)
410425

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_
414430

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)
419447

420448
clearConsoleLine()
421449

0 commit comments

Comments
 (0)