Skip to content

Commit 01d5da1

Browse files
committed
Adding experimental option --crack
1 parent b288bfd commit 01d5da1

File tree

6 files changed

+48
-18
lines changed

6 files changed

+48
-18
lines changed

lib/controller/controller.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
from lib.core.settings import USER_AGENT_ALIASES
7272
from lib.core.target import initTargetEnv
7373
from lib.core.target import setupTargetEnv
74+
from lib.utils.hash import crackHashFile
7475

7576
def _selectInjection():
7677
"""
@@ -268,6 +269,9 @@ def start():
268269
check if they are dynamic and SQL injection affected
269270
"""
270271

272+
if conf.hashFile:
273+
crackHashFile(conf.hashFile)
274+
271275
if conf.direct:
272276
initTargetEnv()
273277
setupTargetEnv()

lib/core/common.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4343,19 +4343,23 @@ def hashDBWrite(key, value, serialize=False):
43434343
Helper function for writing session data to HashDB
43444344
"""
43454345

4346-
_ = '|'.join((str(_) if not isinstance(_, basestring) else _) for _ in (conf.hostname, conf.path.strip('/') if conf.path is not None else conf.port, key, HASHDB_MILESTONE_VALUE))
4347-
conf.hashDB.write(_, value, serialize)
4346+
if conf.hashDB:
4347+
_ = '|'.join((str(_) if not isinstance(_, basestring) else _) for _ in (conf.hostname, conf.path.strip('/') if conf.path is not None else conf.port, key, HASHDB_MILESTONE_VALUE))
4348+
conf.hashDB.write(_, value, serialize)
43484349

43494350
def hashDBRetrieve(key, unserialize=False, checkConf=False):
43504351
"""
43514352
Helper function for restoring session data from HashDB
43524353
"""
43534354

4354-
_ = '|'.join((str(_) if not isinstance(_, basestring) else _) for _ in (conf.hostname, conf.path.strip('/') if conf.path is not None else conf.port, key, HASHDB_MILESTONE_VALUE))
4355-
retVal = conf.hashDB.retrieve(_, unserialize) if kb.resumeValues and not (checkConf and any((conf.flushSession, conf.freshQueries))) else None
4355+
retVal = None
4356+
4357+
if conf.hashDB:
4358+
_ = '|'.join((str(_) if not isinstance(_, basestring) else _) for _ in (conf.hostname, conf.path.strip('/') if conf.path is not None else conf.port, key, HASHDB_MILESTONE_VALUE))
4359+
retVal = conf.hashDB.retrieve(_, unserialize) if kb.resumeValues and not (checkConf and any((conf.flushSession, conf.freshQueries))) else None
43564360

4357-
if not kb.inferenceMode and not kb.fileReadMode and isinstance(retVal, basestring) and any(_ in retVal for _ in (PARTIAL_VALUE_MARKER, PARTIAL_HEX_VALUE_MARKER)):
4358-
retVal = None
4361+
if not kb.inferenceMode and not kb.fileReadMode and isinstance(retVal, basestring) and any(_ in retVal for _ in (PARTIAL_VALUE_MARKER, PARTIAL_HEX_VALUE_MARKER)):
4362+
retVal = None
43594363

43604364
return retVal
43614365

lib/core/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from lib.core.enums import OS
2020

2121
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
22-
VERSION = "1.2.12.25"
22+
VERSION = "1.2.12.26"
2323
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
2424
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}
2525
VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)

lib/parse/cmdline.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,10 @@ def cmdLineParser(argv=None):
668668
help="Simple wizard interface for beginner users")
669669

670670
# Hidden and/or experimental options
671+
parser.add_option("--crack", dest="hashFile",
672+
help=SUPPRESS_HELP)
673+
#help="Load and crack hashes from a file")
674+
671675
parser.add_option("--dummy", dest="dummy", action="store_true",
672676
help=SUPPRESS_HELP)
673677

@@ -884,7 +888,7 @@ def _(self, *args):
884888
if args.dummy:
885889
args.url = args.url or DUMMY_URL
886890

887-
if not any((args.direct, args.url, args.logFile, args.bulkFile, args.googleDork, args.configFile, args.requestFile, args.updateAll, args.smokeTest, args.liveTest, args.wizard, args.dependencies, args.purge, args.sitemapUrl, args.listTampers)):
891+
if not any((args.direct, args.url, args.logFile, args.bulkFile, args.googleDork, args.configFile, args.requestFile, args.updateAll, args.smokeTest, args.liveTest, args.wizard, args.dependencies, args.purge, args.sitemapUrl, args.listTampers, args.hashFile)):
888892
errMsg = "missing a mandatory option (-d, -u, -l, -m, -r, -g, -c, -x, --list-tampers, --wizard, --update, --purge or --dependencies). "
889893
errMsg += "Use -h for basic and -hh for advanced help\n"
890894
parser.error(errMsg)

lib/utils/hash.py

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1078,15 +1078,17 @@ def dictionaryAttack(attack_dict):
10781078
gc.enable()
10791079

10801080
if retVal:
1081-
conf.hashDB.beginTransaction()
1081+
if conf.hashDB:
1082+
conf.hashDB.beginTransaction()
10821083

10831084
while not retVal.empty():
10841085
user, hash_, word = item = retVal.get(block=False)
10851086
attack_info = filter(lambda _: _[0][0] != user or _[0][1] != hash_, attack_info)
10861087
hashDBWrite(hash_, word)
10871088
results.append(item)
10881089

1089-
conf.hashDB.endTransaction()
1090+
if conf.hashDB:
1091+
conf.hashDB.endTransaction()
10901092

10911093
clearConsoleLine()
10921094

@@ -1171,15 +1173,17 @@ class Value():
11711173
if _multiprocessing:
11721174
gc.enable()
11731175

1174-
if retVal:
1175-
conf.hashDB.beginTransaction()
1176+
if retVal and conf.hashDB:
1177+
if conf.hashDB:
1178+
conf.hashDB.beginTransaction()
11761179

11771180
while not retVal.empty():
11781181
user, hash_, word = item = retVal.get(block=False)
11791182
hashDBWrite(hash_, word)
11801183
results.append(item)
11811184

1182-
conf.hashDB.endTransaction()
1185+
if conf.hashDB:
1186+
conf.hashDB.endTransaction()
11831187

11841188
clearConsoleLine()
11851189

@@ -1194,3 +1198,17 @@ class Value():
11941198
logger.warn(warnMsg)
11951199

11961200
return results
1201+
1202+
def crackHashFile(hashFile):
1203+
i = 0
1204+
attack_dict = {}
1205+
1206+
for line in getFileItems(conf.hashFile):
1207+
if ':' in line:
1208+
user, hash_ = line.split(':', 1)
1209+
attack_dict[user] = [hash_]
1210+
else:
1211+
attack_dict["%s%d" % (DUMMY_USER_PREFIX, i)] = [line]
1212+
i += 1
1213+
1214+
dictionaryAttack(attack_dict)

txt/checksum.md5

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ b3e60ea4e18a65c48515d04aab28ff68 extra/sqlharvest/sqlharvest.py
2424
c1bccc94522d3425a372dcd57f78418e extra/wafdetectify/wafdetectify.py
2525
3459c562a6abb9b4bdcc36925f751f3e lib/controller/action.py
2626
0f0feede9750be810d2b8a7ab159b7b0 lib/controller/checks.py
27-
ad968ee04e93f6f850d6b7e5ac0073c5 lib/controller/controller.py
27+
ae444b08253e10bc4553f011d6100b28 lib/controller/controller.py
2828
988b548f6578adf9cec17afdeee8291c lib/controller/handler.py
2929
1e5532ede194ac9c083891c2f02bca93 lib/controller/__init__.py
3030
e62309b22a59e60b270e62586f169441 lib/core/agent.py
3131
c347f085bd561adfa26d3a9512e5f3b9 lib/core/bigarray.py
32-
a78c563bbaeebd958b25303d83dfe3f2 lib/core/common.py
32+
ae4bf844c42f9a36ebbe8444e89f7041 lib/core/common.py
3333
0d082da16c388b3445e656e0760fb582 lib/core/convert.py
3434
9f87391b6a3395f7f50830b391264f27 lib/core/data.py
3535
72016ea5c994a711a262fd64572a0fcd lib/core/datatype.py
@@ -49,7 +49,7 @@ c8c386d644d57c659d74542f5f57f632 lib/core/patch.py
4949
0c3eef46bdbf87e29a3f95f90240d192 lib/core/replication.py
5050
a7db43859b61569b601b97f187dd31c5 lib/core/revision.py
5151
fcb74fcc9577523524659ec49e2e964b lib/core/session.py
52-
3805f9f360e47798a3e6d4da977c83eb lib/core/settings.py
52+
758c731f879a5989288d8809a8d54567 lib/core/settings.py
5353
a971ce157d04de96ba6e710d3d38a9a8 lib/core/shell.py
5454
a7edc9250d13af36ac0108f259859c19 lib/core/subprocessng.py
5555
1581be48127a3a7a9fd703359b6e7567 lib/core/target.py
@@ -60,7 +60,7 @@ b35636650cfe721f5cc47fb91737c061 lib/core/update.py
6060
e772deb63270375e685fa5a7b775c382 lib/core/wordlist.py
6161
1e5532ede194ac9c083891c2f02bca93 lib/__init__.py
6262
7620f1f4b8791e13c7184c06b5421754 lib/parse/banner.py
63-
30d7cbada42154dcbb17f4ca969d812a lib/parse/cmdline.py
63+
cfd7938668213fef65a7570997b78403 lib/parse/cmdline.py
6464
fb2e2f05dde98caeac6ccf3e67192177 lib/parse/configfile.py
6565
3794ff139869f5ae8e81cfdbe5714f56 lib/parse/handler.py
6666
6bab53ea9d75bc9bb8169d3e8f3f149f lib/parse/headers.py
@@ -108,7 +108,7 @@ f9867bbfcd6d31916ca73e72e95fd881 lib/utils/deps.py
108108
f7af65aa47329d021e2b2cc8521b42a4 lib/utils/getch.py
109109
7af29f61302c8693cd6436d4b69e22d3 lib/utils/har.py
110110
1205648d55649accafae2cc77d647aa0 lib/utils/hashdb.py
111-
4b50c02e803c874c1d03873fd29d63ee lib/utils/hash.py
111+
eb2aa3fa9ebdf4cb6ac3e005f7df1e9b lib/utils/hash.py
112112
011d2dbf589e0faa0deca61a651239cc lib/utils/htmlentities.py
113113
1e5532ede194ac9c083891c2f02bca93 lib/utils/__init__.py
114114
527409077a094b63c88f3291138b1c81 lib/utils/pivotdumptable.py

0 commit comments

Comments
 (0)