2010-11-20 16:14:13 +03:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
"""
|
|
|
|
$Id$
|
|
|
|
|
|
|
|
Copyright (c) 2006-2010 sqlmap developers (http://sqlmap.sourceforge.net/)
|
|
|
|
See the file 'doc/COPYING' for copying permission
|
|
|
|
"""
|
|
|
|
|
2010-11-23 16:24:02 +03:00
|
|
|
import re
|
|
|
|
import time
|
|
|
|
|
2010-11-20 16:14:13 +03:00
|
|
|
from hashlib import md5
|
|
|
|
from hashlib import sha1
|
2010-11-23 16:58:01 +03:00
|
|
|
from zipfile import ZipFile
|
2010-11-20 16:14:13 +03:00
|
|
|
|
|
|
|
from extra.pydes.pyDes import des
|
|
|
|
from extra.pydes.pyDes import CBC
|
2010-11-23 17:50:47 +03:00
|
|
|
from lib.core.common import checkFile
|
2010-11-23 23:54:40 +03:00
|
|
|
from lib.core.common import clearConsoleLine
|
2010-11-23 16:24:02 +03:00
|
|
|
from lib.core.common import dataToStdout
|
2010-12-27 13:56:28 +03:00
|
|
|
from lib.core.common import getCompiledRegex
|
2010-11-23 16:24:02 +03:00
|
|
|
from lib.core.common import getFileItems
|
2011-01-28 19:36:09 +03:00
|
|
|
from lib.core.common import Backend
|
2010-11-23 16:58:01 +03:00
|
|
|
from lib.core.common import getPublicTypeMembers
|
2011-01-11 15:16:20 +03:00
|
|
|
from lib.core.common import getUnicode
|
2010-11-23 16:24:02 +03:00
|
|
|
from lib.core.common import paths
|
|
|
|
from lib.core.common import readInput
|
2010-11-20 16:14:13 +03:00
|
|
|
from lib.core.convert import hexdecode
|
|
|
|
from lib.core.convert import hexencode
|
2010-11-23 16:24:02 +03:00
|
|
|
from lib.core.data import kb
|
|
|
|
from lib.core.data import logger
|
|
|
|
from lib.core.enums import DBMS
|
|
|
|
from lib.core.enums import HASH
|
2010-12-27 13:56:28 +03:00
|
|
|
from lib.core.exception import sqlmapUserQuitException
|
2011-01-15 18:56:11 +03:00
|
|
|
from lib.core.settings import COMMON_PASSWORD_SUFFIXES
|
2010-12-27 13:56:28 +03:00
|
|
|
from lib.core.settings import DUMMY_USER_PREFIX
|
2011-01-30 14:36:03 +03:00
|
|
|
from lib.core.settings import UNICODE_ENCODING
|
2010-11-20 16:14:13 +03:00
|
|
|
|
2010-11-20 16:22:59 +03:00
|
|
|
def mysql_passwd(password, uppercase=True):
|
2010-11-20 16:14:13 +03:00
|
|
|
"""
|
|
|
|
Reference(s):
|
|
|
|
http://csl.sublevel3.org/mysql-password-function/
|
|
|
|
|
2010-11-20 16:22:59 +03:00
|
|
|
>>> mysql_passwd(password='testpass', uppercase=True)
|
2010-11-20 16:14:13 +03:00
|
|
|
'*00E247AC5F9AF26AE0194B41E1E769DEE1429A29'
|
|
|
|
"""
|
|
|
|
|
|
|
|
retVal = "*%s" % sha1(sha1(password).digest()).hexdigest()
|
|
|
|
|
|
|
|
return retVal.upper() if uppercase else retVal.lower()
|
|
|
|
|
2010-11-20 16:22:59 +03:00
|
|
|
def mysql_old_passwd(password, uppercase=True): # prior to version '4.1'
|
2010-11-20 16:14:13 +03:00
|
|
|
"""
|
|
|
|
Reference(s):
|
|
|
|
http://www.sfr-fresh.com/unix/privat/tpop3d-1.5.5.tar.gz:a/tpop3d-1.5.5/password.c
|
|
|
|
http://voidnetwork.org/5ynL0rd/darkc0de/python_script/darkMySQLi.html
|
|
|
|
|
2010-11-20 16:22:59 +03:00
|
|
|
>>> mysql_old_passwd(password='testpass', uppercase=True)
|
2010-11-20 16:14:13 +03:00
|
|
|
'7DCDA0D57290B453'
|
|
|
|
"""
|
|
|
|
|
|
|
|
a, b, c = 1345345333, 7, 0x12345671
|
|
|
|
|
|
|
|
for d in password:
|
|
|
|
if d == ' ' or d == '\t':
|
|
|
|
continue
|
|
|
|
|
|
|
|
e = ord(d)
|
|
|
|
a ^= (((a & 63) + b) * e) + (a << 8)
|
|
|
|
c += (c << 8) ^ a
|
|
|
|
b += e
|
|
|
|
|
|
|
|
retVal = "%08lx%08lx" % (a & ((1 << 31) - 1), c & ((1 << 31) - 1))
|
|
|
|
|
|
|
|
return retVal.upper() if uppercase else retVal.lower()
|
|
|
|
|
2010-11-20 16:22:59 +03:00
|
|
|
def postgres_passwd(password, username, uppercase=False):
|
2010-11-20 16:14:13 +03:00
|
|
|
"""
|
|
|
|
Reference(s):
|
|
|
|
http://pentestmonkey.net/blog/cracking-postgres-hashes/
|
|
|
|
|
2010-11-20 16:22:59 +03:00
|
|
|
>>> postgres_passwd(password='testpass', username='testuser', uppercase=False)
|
2010-11-20 16:14:13 +03:00
|
|
|
'md599e5ea7a6f7c3269995cba3927fd0093'
|
|
|
|
"""
|
|
|
|
|
|
|
|
retVal = "md5%s" % md5(password + username).hexdigest()
|
|
|
|
|
|
|
|
return retVal.upper() if uppercase else retVal.lower()
|
|
|
|
|
2010-11-20 16:22:59 +03:00
|
|
|
def mssql_passwd(password, salt, uppercase=False):
|
2010-11-20 16:14:13 +03:00
|
|
|
"""
|
|
|
|
Reference(s):
|
|
|
|
http://www.leidecker.info/projects/phrasendrescher/mssql.c
|
|
|
|
https://www.evilfingers.com/tools/GSAuditor.php
|
|
|
|
|
2010-11-20 16:22:59 +03:00
|
|
|
>>> mssql_passwd(password='testpass', salt='4086ceb6', uppercase=False)
|
2010-11-20 16:14:13 +03:00
|
|
|
'0x01004086ceb60c90646a8ab9889fe3ed8e5c150b5460ece8425a'
|
|
|
|
"""
|
|
|
|
|
|
|
|
binsalt = hexdecode(salt)
|
|
|
|
unistr = "".join("%s\0" % c for c in password)
|
|
|
|
|
|
|
|
retVal = "0100%s%s" % (salt, sha1(unistr + binsalt).hexdigest())
|
|
|
|
|
|
|
|
return "0x%s" % (retVal.upper() if uppercase else retVal.lower())
|
|
|
|
|
2010-11-20 16:22:59 +03:00
|
|
|
def mssql_old_passwd(password, salt, uppercase=True): # prior to version '2005'
|
2010-11-20 16:14:13 +03:00
|
|
|
"""
|
|
|
|
Reference(s):
|
|
|
|
www.exploit-db.com/download_pdf/15537/
|
|
|
|
http://www.leidecker.info/projects/phrasendrescher/mssql.c
|
|
|
|
https://www.evilfingers.com/tools/GSAuditor.php
|
|
|
|
|
2010-11-20 16:22:59 +03:00
|
|
|
>>> mssql_old_passwd(password='testpass', salt='4086ceb6', uppercase=True)
|
2010-11-20 16:14:13 +03:00
|
|
|
'0x01004086CEB60C90646A8AB9889FE3ED8E5C150B5460ECE8425AC7BB7255C0C81D79AA5D0E93D4BB077FB9A51DA0'
|
|
|
|
"""
|
|
|
|
|
|
|
|
binsalt = hexdecode(salt)
|
|
|
|
unistr = "".join("%s\0" % c for c in password)
|
|
|
|
|
|
|
|
retVal = "0100%s%s%s" % (salt, sha1(unistr + binsalt).hexdigest(), sha1(unistr.upper() + binsalt).hexdigest())
|
|
|
|
|
|
|
|
return "0x%s" % (retVal.upper() if uppercase else retVal.lower())
|
|
|
|
|
2010-11-20 16:22:59 +03:00
|
|
|
def oracle_passwd(password, salt, uppercase=True):
|
2010-11-20 16:14:13 +03:00
|
|
|
"""
|
|
|
|
Reference(s):
|
|
|
|
https://www.evilfingers.com/tools/GSAuditor.php
|
|
|
|
http://www.notesbit.com/index.php/scripts-oracle/oracle-11g-new-password-algorithm-is-revealed-by-seclistsorg/
|
|
|
|
http://seclists.org/bugtraq/2007/Sep/304
|
|
|
|
|
2010-11-20 16:22:59 +03:00
|
|
|
>>> oracle_passwd(password='SHAlala', salt='1B7B5F82B7235E9E182C', uppercase=True)
|
2010-11-20 16:14:13 +03:00
|
|
|
'S:2BFCFDF5895014EE9BB2B9BA067B01E0389BB5711B7B5F82B7235E9E182C'
|
|
|
|
"""
|
|
|
|
|
|
|
|
binsalt = hexdecode(salt)
|
|
|
|
|
|
|
|
retVal="s:%s%s" % (sha1(password + binsalt).hexdigest(), salt)
|
|
|
|
|
|
|
|
return retVal.upper() if uppercase else retVal.lower()
|
|
|
|
|
2010-11-20 16:22:59 +03:00
|
|
|
def oracle_old_passwd(password, username, uppercase=True): # prior to version '11g'
|
2010-11-20 16:14:13 +03:00
|
|
|
"""
|
|
|
|
Reference(s):
|
|
|
|
http://www.notesbit.com/index.php/scripts-oracle/oracle-11g-new-password-algorithm-is-revealed-by-seclistsorg/
|
|
|
|
|
2010-11-20 16:22:59 +03:00
|
|
|
>>> oracle_old_passwd(password='tiger', username='scott', uppercase=True)
|
2010-11-20 16:14:13 +03:00
|
|
|
'F894844C34402B67'
|
|
|
|
"""
|
|
|
|
IV, pad = "\0"*8, "\0"
|
2010-11-24 00:17:01 +03:00
|
|
|
|
|
|
|
if isinstance(username, unicode):
|
2011-01-30 14:36:03 +03:00
|
|
|
username = unicode.encode(username, UNICODE_ENCODING) #pyDes has issues with unicode strings
|
2010-11-24 00:17:01 +03:00
|
|
|
|
2010-11-20 16:14:13 +03:00
|
|
|
unistr = "".join("\0%s" % c for c in (username + password).upper())
|
|
|
|
|
|
|
|
cipher = des(hexdecode("0123456789ABCDEF"), CBC, IV, pad)
|
|
|
|
encrypted = cipher.encrypt(unistr)
|
|
|
|
cipher = des(encrypted[-8:], CBC, IV, pad)
|
|
|
|
encrypted = cipher.encrypt(unistr)
|
|
|
|
|
|
|
|
retVal = hexencode(encrypted[-8:])
|
|
|
|
|
|
|
|
return retVal.upper() if uppercase else retVal.lower()
|
2010-11-23 16:24:02 +03:00
|
|
|
|
|
|
|
def md5_generic_passwd(password, uppercase=False):
|
|
|
|
"""
|
|
|
|
>>> md5_generic_passwd(password='testpass', uppercase=False)
|
|
|
|
'179ad45c6ce2cb97cf1029e212046e81'
|
|
|
|
"""
|
|
|
|
|
|
|
|
retVal = md5(password).hexdigest()
|
|
|
|
|
|
|
|
return retVal.upper() if uppercase else retVal.lower()
|
|
|
|
|
|
|
|
def sha1_generic_passwd(password, uppercase=False):
|
|
|
|
"""
|
|
|
|
>>> sha1_generic_passwd(password='testpass', uppercase=False)
|
|
|
|
'206c80413b9a96c1312cc346b7d2517b84463edd'
|
|
|
|
"""
|
|
|
|
|
|
|
|
retVal = sha1(password).hexdigest()
|
|
|
|
|
|
|
|
return retVal.upper() if uppercase else retVal.lower()
|
|
|
|
|
|
|
|
__functions__ = {
|
2010-11-23 22:21:30 +03:00
|
|
|
HASH.MYSQL: mysql_passwd,
|
|
|
|
HASH.MYSQL_OLD: mysql_old_passwd,
|
|
|
|
HASH.POSTGRES: postgres_passwd,
|
|
|
|
HASH.MSSQL: mssql_passwd,
|
|
|
|
HASH.MSSQL_OLD: mssql_old_passwd,
|
|
|
|
HASH.ORACLE: oracle_passwd,
|
|
|
|
HASH.ORACLE_OLD: oracle_old_passwd,
|
|
|
|
HASH.MD5_GENERIC: md5_generic_passwd,
|
|
|
|
HASH.SHA1_GENERIC: sha1_generic_passwd
|
2010-11-23 16:24:02 +03:00
|
|
|
}
|
|
|
|
|
2010-12-27 13:56:28 +03:00
|
|
|
def attackCachedUsersPasswords():
|
|
|
|
if kb.data.cachedUsersPasswords:
|
|
|
|
results = dictionaryAttack(kb.data.cachedUsersPasswords)
|
2011-01-07 20:25:22 +03:00
|
|
|
|
2010-12-27 13:56:28 +03:00
|
|
|
for (user, hash_, password) in results:
|
|
|
|
for i in xrange(len(kb.data.cachedUsersPasswords[user])):
|
|
|
|
if kb.data.cachedUsersPasswords[user][i] and hash_.lower() in kb.data.cachedUsersPasswords[user][i].lower():
|
|
|
|
kb.data.cachedUsersPasswords[user][i] += "%s clear-text password: %s" % ('\n' if kb.data.cachedUsersPasswords[user][i][-1] != '\n' else '', password)
|
2010-11-23 16:24:02 +03:00
|
|
|
|
2010-12-27 13:56:28 +03:00
|
|
|
def attackDumpedTable():
|
|
|
|
if kb.data.dumpedTable:
|
|
|
|
table = kb.data.dumpedTable
|
|
|
|
columns = table.keys()
|
|
|
|
count = table["__infos__"]["count"]
|
2010-11-23 16:24:02 +03:00
|
|
|
|
2010-12-27 13:56:28 +03:00
|
|
|
colUser = ''
|
|
|
|
attack_dict = {}
|
2010-11-23 16:24:02 +03:00
|
|
|
|
2010-12-27 13:56:28 +03:00
|
|
|
for column in columns:
|
|
|
|
if column and column.lower() in ('user', 'username', 'user_name'):
|
|
|
|
colUser = column
|
|
|
|
break
|
2010-11-23 22:21:30 +03:00
|
|
|
|
2010-12-27 13:56:28 +03:00
|
|
|
for i in range(count):
|
|
|
|
for column in columns:
|
|
|
|
if column == colUser or column == '__infos__':
|
2010-11-23 17:50:47 +03:00
|
|
|
continue
|
2011-01-07 20:25:22 +03:00
|
|
|
|
2011-01-04 02:36:35 +03:00
|
|
|
if len(table[column]['values']) <= i:
|
|
|
|
continue
|
|
|
|
|
2010-12-27 13:56:28 +03:00
|
|
|
value = table[column]['values'][i]
|
2011-01-07 20:25:22 +03:00
|
|
|
|
2010-12-27 13:56:28 +03:00
|
|
|
if hashRecognition(value):
|
|
|
|
if colUser:
|
|
|
|
if table[colUser]['values'][i] not in attack_dict:
|
|
|
|
attack_dict[table[colUser]['values'][i]] = []
|
2011-01-07 20:25:22 +03:00
|
|
|
|
2010-12-27 13:56:28 +03:00
|
|
|
attack_dict[table[colUser]['values'][i]].append(value)
|
|
|
|
else:
|
|
|
|
attack_dict['%s%d' % (DUMMY_USER_PREFIX, i)] = [value]
|
|
|
|
|
|
|
|
if attack_dict:
|
|
|
|
message = "recognized possible password hash values. "
|
|
|
|
message += "do you want to use dictionary attack on retrieved table items? [Y/n/q]"
|
|
|
|
test = readInput(message, default="Y")
|
|
|
|
|
|
|
|
if test[0] in ("n", "N"):
|
|
|
|
return
|
|
|
|
elif test[0] in ("q", "Q"):
|
|
|
|
raise sqlmapUserQuitException
|
|
|
|
|
|
|
|
results = dictionaryAttack(attack_dict)
|
2011-01-07 20:25:22 +03:00
|
|
|
|
2010-12-27 13:56:28 +03:00
|
|
|
for (user, hash_, password) in results:
|
|
|
|
for i in range(count):
|
|
|
|
for column in columns:
|
|
|
|
if column == colUser or column == '__infos__':
|
|
|
|
continue
|
2011-01-04 02:36:35 +03:00
|
|
|
if len(table[column]['values']) <= i:
|
|
|
|
continue
|
|
|
|
|
2010-12-27 13:56:28 +03:00
|
|
|
value = table[column]['values'][i]
|
2011-01-07 20:25:22 +03:00
|
|
|
|
2010-12-27 13:56:28 +03:00
|
|
|
if value.lower() == hash_.lower():
|
|
|
|
table[column]['values'][i] += " (%s)" % password
|
2011-01-07 21:07:18 +03:00
|
|
|
table[column]['length'] = max(table[column]['length'], len(table[column]['values'][i]))
|
2010-12-27 13:56:28 +03:00
|
|
|
|
|
|
|
def hashRecognition(value):
|
|
|
|
retVal = None
|
|
|
|
|
|
|
|
if value:
|
|
|
|
for name, regex in getPublicTypeMembers(HASH):
|
2011-01-13 20:36:54 +03:00
|
|
|
# Hashes for Oracle and old MySQL look the same hence these checks
|
2011-01-28 19:36:09 +03:00
|
|
|
if Backend.getIdentifiedDbms() == DBMS.ORACLE and regex == HASH.MYSQL_OLD:
|
2010-12-27 13:56:28 +03:00
|
|
|
continue
|
2011-01-28 19:36:09 +03:00
|
|
|
elif Backend.getIdentifiedDbms() == DBMS.MYSQL and regex == HASH.ORACLE_OLD:
|
2010-12-27 13:56:28 +03:00
|
|
|
continue
|
|
|
|
elif getCompiledRegex(regex).match(value):
|
|
|
|
retVal = regex
|
|
|
|
break
|
2010-11-23 22:21:30 +03:00
|
|
|
|
2010-12-27 13:56:28 +03:00
|
|
|
return retVal
|
2010-11-23 16:24:02 +03:00
|
|
|
|
2010-12-27 13:56:28 +03:00
|
|
|
def dictionaryAttack(attack_dict):
|
|
|
|
hash_regexes = []
|
|
|
|
results = []
|
|
|
|
|
|
|
|
for (_, hashes) in attack_dict.items():
|
|
|
|
for hash_ in hashes:
|
|
|
|
if not hash_:
|
|
|
|
continue
|
2011-01-07 20:25:22 +03:00
|
|
|
|
2010-12-27 13:56:28 +03:00
|
|
|
hash_ = hash_.split()[0]
|
|
|
|
regex = hashRecognition(hash_)
|
2011-01-07 20:25:22 +03:00
|
|
|
|
2011-01-07 20:38:28 +03:00
|
|
|
if regex and regex not in hash_regexes:
|
2010-12-27 13:56:28 +03:00
|
|
|
hash_regexes.append(regex)
|
|
|
|
infoMsg = "using hash method: '%s'" % __functions__[regex].func_name
|
|
|
|
logger.info(infoMsg)
|
2010-11-23 17:50:47 +03:00
|
|
|
|
2010-12-18 17:11:49 +03:00
|
|
|
for hash_regex in hash_regexes:
|
2010-12-18 17:31:41 +03:00
|
|
|
attack_info = []
|
|
|
|
|
2010-12-27 13:56:28 +03:00
|
|
|
for (user, hashes) in attack_dict.items():
|
2010-11-23 16:24:02 +03:00
|
|
|
for hash_ in hashes:
|
|
|
|
if not hash_:
|
|
|
|
continue
|
|
|
|
|
|
|
|
hash_ = hash_.split()[0]
|
|
|
|
|
2010-11-23 23:54:40 +03:00
|
|
|
if re.match(hash_regex, hash_):
|
2010-11-23 16:24:02 +03:00
|
|
|
hash_ = hash_.lower()
|
|
|
|
|
2010-11-23 23:54:40 +03:00
|
|
|
if hash_regex in (HASH.MYSQL, HASH.MYSQL_OLD, HASH.MD5_GENERIC, HASH.SHA1_GENERIC):
|
2010-11-23 16:24:02 +03:00
|
|
|
attack_info.append([(user, hash_), {}])
|
2010-11-23 21:57:00 +03:00
|
|
|
|
2010-11-23 23:54:40 +03:00
|
|
|
elif hash_regex in (HASH.ORACLE_OLD, HASH.POSTGRES):
|
2010-11-23 16:24:02 +03:00
|
|
|
attack_info.append([(user, hash_), {'username': user}])
|
2010-11-23 21:57:00 +03:00
|
|
|
|
2010-11-23 23:54:40 +03:00
|
|
|
elif hash_regex in (HASH.ORACLE):
|
2010-11-23 16:24:02 +03:00
|
|
|
attack_info.append([(user, hash_), {'salt': hash_[-20:]}])
|
2010-11-23 21:57:00 +03:00
|
|
|
|
2010-11-23 23:54:40 +03:00
|
|
|
elif hash_regex in (HASH.MSSQL, HASH.MSSQL_OLD):
|
2010-11-23 16:24:02 +03:00
|
|
|
attack_info.append([(user, hash_), {'salt': hash_[6:14]}])
|
|
|
|
|
2010-12-27 13:56:28 +03:00
|
|
|
if not kb.wordlist:
|
2010-12-18 17:11:49 +03:00
|
|
|
if hash_regex == HASH.ORACLE_OLD: #it's the slowest of all methods hence smaller default dict
|
|
|
|
message = "what's the dictionary's location? [%s]" % paths.ORACLE_DEFAULT_PASSWD
|
|
|
|
dictpath = readInput(message, default=paths.ORACLE_DEFAULT_PASSWD)
|
2010-11-23 17:50:47 +03:00
|
|
|
|
2010-12-18 17:11:49 +03:00
|
|
|
else:
|
|
|
|
message = "what's the dictionary's location? [%s]" % paths.WORDLIST
|
|
|
|
dictpath = readInput(message, default=paths.WORDLIST)
|
2010-11-23 17:50:47 +03:00
|
|
|
|
2010-12-18 17:11:49 +03:00
|
|
|
checkFile(dictpath)
|
2010-11-23 17:50:47 +03:00
|
|
|
|
2010-12-18 17:11:49 +03:00
|
|
|
infoMsg = "loading dictionary from: '%s'" % dictpath
|
|
|
|
logger.info(infoMsg)
|
2010-12-27 13:56:28 +03:00
|
|
|
kb.wordlist = getFileItems(dictpath, None, False)
|
2010-11-23 16:24:02 +03:00
|
|
|
|
2011-01-15 18:56:11 +03:00
|
|
|
message = "do you want to use common password suffixes? (slow!) [y/N] "
|
|
|
|
test = readInput(message, default="N")
|
|
|
|
|
|
|
|
suffix_list = [""]
|
|
|
|
if test[0] in ("y", "Y"):
|
2011-01-17 12:28:25 +03:00
|
|
|
suffix_list += COMMON_PASSWORD_SUFFIXES
|
2011-01-15 18:56:11 +03:00
|
|
|
|
2010-12-18 17:11:49 +03:00
|
|
|
infoMsg = "starting dictionary attack (%s)" % __functions__[hash_regex].func_name
|
|
|
|
logger.info(infoMsg)
|
2010-11-23 16:24:02 +03:00
|
|
|
|
2010-12-29 03:37:53 +03:00
|
|
|
for item in attack_info:
|
|
|
|
((user, _), _) = item
|
2011-01-11 15:16:20 +03:00
|
|
|
kb.wordlist.append(getUnicode(user))
|
|
|
|
|
2011-01-15 18:56:11 +03:00
|
|
|
length = len(kb.wordlist) * len(suffix_list)
|
2010-12-29 03:37:53 +03:00
|
|
|
|
2010-11-23 23:54:40 +03:00
|
|
|
if hash_regex in (HASH.MYSQL, HASH.MYSQL_OLD, HASH.MD5_GENERIC, HASH.SHA1_GENERIC):
|
2010-11-23 16:24:02 +03:00
|
|
|
count = 0
|
2010-11-23 21:57:00 +03:00
|
|
|
|
2011-01-15 18:56:11 +03:00
|
|
|
for suffix in suffix_list:
|
2011-01-17 12:41:25 +03:00
|
|
|
if not attack_info:
|
|
|
|
break
|
|
|
|
|
2011-01-15 18:56:11 +03:00
|
|
|
for word in kb.wordlist:
|
2011-01-17 12:41:25 +03:00
|
|
|
if not attack_info:
|
|
|
|
break
|
|
|
|
|
2011-01-15 18:56:11 +03:00
|
|
|
count += 1
|
|
|
|
|
|
|
|
if suffix:
|
|
|
|
word = word + suffix
|
2010-11-23 21:57:00 +03:00
|
|
|
|
2011-01-15 18:56:11 +03:00
|
|
|
try:
|
|
|
|
current = __functions__[hash_regex](password = word, uppercase = False)
|
2010-11-23 16:24:02 +03:00
|
|
|
|
2011-01-15 18:56:11 +03:00
|
|
|
for item in attack_info:
|
|
|
|
((user, hash_), _) = item
|
2011-01-11 15:16:20 +03:00
|
|
|
|
2011-01-15 18:56:11 +03:00
|
|
|
if hash_ == current:
|
|
|
|
results.append((user, hash_, word))
|
|
|
|
clearConsoleLine()
|
2011-01-07 20:25:22 +03:00
|
|
|
|
2011-01-15 18:56:11 +03:00
|
|
|
infoMsg = "[%s] [INFO] found: '%s'" % (time.strftime("%X"), word)
|
2011-01-07 20:25:22 +03:00
|
|
|
|
2011-01-15 18:56:11 +03:00
|
|
|
if user and not user.startswith(DUMMY_USER_PREFIX):
|
|
|
|
infoMsg += " for user: '%s'\n" % user
|
|
|
|
else:
|
|
|
|
infoMsg += " for hash: '%s'\n" % hash_
|
2010-12-27 13:56:28 +03:00
|
|
|
|
2011-01-15 18:56:11 +03:00
|
|
|
dataToStdout(infoMsg, True)
|
2010-11-23 16:24:02 +03:00
|
|
|
|
2011-01-15 18:56:11 +03:00
|
|
|
attack_info.remove(item)
|
2011-01-11 15:27:22 +03:00
|
|
|
|
2011-01-15 18:56:11 +03:00
|
|
|
elif count % 1117 == 0 or count == length or hash_regex in (HASH.ORACLE_OLD):
|
|
|
|
status = '%d/%d words (%d%s)' % (count, length, round(100.0*count/length), '%')
|
|
|
|
dataToStdout("\r[%s] [INFO] %s" % (time.strftime("%X"), status))
|
2011-01-11 15:27:22 +03:00
|
|
|
|
2011-01-15 18:56:11 +03:00
|
|
|
except KeyboardInterrupt:
|
|
|
|
raise
|
|
|
|
|
|
|
|
except:
|
|
|
|
warnMsg = "there was a problem while hashing entry: %s. " % repr(word)
|
|
|
|
warnMsg += "Please report by e-mail to sqlmap-users@lists.sourceforge.net."
|
|
|
|
logger.critical(warnMsg)
|
2010-11-23 21:57:00 +03:00
|
|
|
|
2010-11-23 23:54:40 +03:00
|
|
|
clearConsoleLine()
|
2010-11-23 21:57:00 +03:00
|
|
|
|
2010-11-23 16:24:02 +03:00
|
|
|
else:
|
|
|
|
for ((user, hash_), kwargs) in attack_info:
|
|
|
|
count = 0
|
2011-01-15 18:56:11 +03:00
|
|
|
found = False
|
2010-11-23 21:57:00 +03:00
|
|
|
|
2011-01-15 18:56:11 +03:00
|
|
|
for suffix in suffix_list:
|
|
|
|
if found:
|
|
|
|
break
|
2010-11-23 16:24:02 +03:00
|
|
|
|
2011-01-15 18:56:11 +03:00
|
|
|
for word in kb.wordlist:
|
|
|
|
current = __functions__[hash_regex](password = word, uppercase = False, **kwargs)
|
|
|
|
count += 1
|
2010-12-27 13:56:28 +03:00
|
|
|
|
2011-01-15 18:56:11 +03:00
|
|
|
if suffix:
|
|
|
|
word = word + suffix
|
2011-01-07 20:25:22 +03:00
|
|
|
|
2011-01-15 18:56:11 +03:00
|
|
|
try:
|
|
|
|
if hash_ == current:
|
|
|
|
if regex == HASH.ORACLE_OLD: #only for cosmetic purposes
|
|
|
|
word = word.upper()
|
|
|
|
results.append((user, hash_, word))
|
|
|
|
clearConsoleLine()
|
2011-01-07 20:25:22 +03:00
|
|
|
|
2011-01-15 18:56:11 +03:00
|
|
|
infoMsg = "[%s] [INFO] found: '%s'" % (time.strftime("%X"), word)
|
2010-12-27 13:56:28 +03:00
|
|
|
|
2011-01-15 18:56:11 +03:00
|
|
|
if user and not user.startswith(DUMMY_USER_PREFIX):
|
|
|
|
infoMsg += " for user: '%s'\n" % user
|
|
|
|
else:
|
|
|
|
infoMsg += " for hash: '%s'\n" % hash_
|
2010-11-23 16:24:02 +03:00
|
|
|
|
2011-01-15 18:56:11 +03:00
|
|
|
dataToStdout(infoMsg, True)
|
|
|
|
|
|
|
|
found = True
|
|
|
|
break
|
|
|
|
|
|
|
|
elif count % 1117 == 0 or count == length or hash_regex in (HASH.ORACLE_OLD):
|
|
|
|
status = '%d/%d words (%d%s) (user: %s)' % (count, length, round(100.0*count/length), '%', user)
|
|
|
|
dataToStdout("\r[%s] [INFO] %s" % (time.strftime("%X"), status))
|
|
|
|
|
|
|
|
except KeyboardInterrupt:
|
|
|
|
raise
|
|
|
|
|
|
|
|
except:
|
|
|
|
warnMsg = "there was a problem while hashing entry: %s. " % repr(word)
|
|
|
|
warnMsg += "Please report by e-mail to sqlmap-users@lists.sourceforge.net."
|
|
|
|
logger.critical(warnMsg)
|
2010-11-23 21:57:00 +03:00
|
|
|
|
2010-11-23 23:54:40 +03:00
|
|
|
clearConsoleLine()
|
2010-11-23 17:50:47 +03:00
|
|
|
|
2010-12-18 17:11:49 +03:00
|
|
|
if len(hash_regexes) == 0:
|
2011-01-28 19:36:09 +03:00
|
|
|
warnMsg = "unknown hash Format. "
|
2010-11-23 17:57:36 +03:00
|
|
|
warnMsg += "Please report by e-mail to sqlmap-users@lists.sourceforge.net."
|
|
|
|
logger.warn(warnMsg)
|
2010-12-27 13:56:28 +03:00
|
|
|
|
2010-12-27 18:39:27 +03:00
|
|
|
if len(results) == 0:
|
|
|
|
warnMsg = "no clear password(s) found"
|
|
|
|
logger.warn(warnMsg)
|
|
|
|
|
2010-12-27 13:56:28 +03:00
|
|
|
return results
|