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

Skip to content

Commit 194c911

Browse files
committed
Another update for #4367
1 parent e621d7e commit 194c911

2 files changed

Lines changed: 38 additions & 39 deletions

File tree

lib/core/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from thirdparty.six import unichr as _unichr
1919

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

lib/utils/hash.py

Lines changed: 37 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,41 @@ def _encode64(input_, count):
583583
HASH.SHA512_BASE64: sha512_generic_passwd,
584584
}
585585

586+
def _finalize(retVal, results, processes, attack_info=None):
587+
if _multiprocessing:
588+
gc.enable()
589+
590+
# NOTE: https://github.com/sqlmapproject/sqlmap/issues/4367
591+
# NOTE: https://dzone.com/articles/python-101-creating-multiple-processes
592+
for process in processes:
593+
try:
594+
process.terminate()
595+
process.join()
596+
except (OSError, AttributeError):
597+
pass
598+
599+
if retVal:
600+
removals = set()
601+
602+
if conf.hashDB:
603+
conf.hashDB.beginTransaction()
604+
605+
while not retVal.empty():
606+
user, hash_, word = item = retVal.get(block=False)
607+
results.append(item)
608+
removals.add((user, hash_))
609+
hashDBWrite(hash_, word)
610+
611+
for item in attack_info or []:
612+
if (item[0][0], item[0][1]) in removals:
613+
attack_info.remove(item)
614+
615+
if conf.hashDB:
616+
conf.hashDB.endTransaction()
617+
618+
if hasattr(retVal, "close"):
619+
retVal.close()
620+
586621
def storeHashesToFile(attack_dict):
587622
if not attack_dict:
588623
return
@@ -1148,30 +1183,7 @@ def dictionaryAttack(attack_dict):
11481183
logger.warn(warnMsg)
11491184

11501185
finally:
1151-
if _multiprocessing:
1152-
gc.enable()
1153-
1154-
# NOTE: https://github.com/sqlmapproject/sqlmap/issues/4367
1155-
# NOTE: https://dzone.com/articles/python-101-creating-multiple-processes
1156-
for process in processes:
1157-
try:
1158-
process.terminate()
1159-
process.join()
1160-
except (OSError, AttributeError):
1161-
pass
1162-
1163-
if retVal:
1164-
if conf.hashDB:
1165-
conf.hashDB.beginTransaction()
1166-
1167-
while not retVal.empty():
1168-
user, hash_, word = item = retVal.get(block=False)
1169-
attack_info = [_ for _ in attack_info if _[0][0] != user or _[0][1] != hash_]
1170-
hashDBWrite(hash_, word)
1171-
results.append(item)
1172-
1173-
if conf.hashDB:
1174-
conf.hashDB.endTransaction()
1186+
_finalize(retVal, results, processes, attack_info)
11751187

11761188
clearConsoleLine()
11771189

@@ -1253,20 +1265,7 @@ class Value(object):
12531265
pass
12541266

12551267
finally:
1256-
if _multiprocessing:
1257-
gc.enable()
1258-
1259-
if retVal and conf.hashDB:
1260-
if conf.hashDB:
1261-
conf.hashDB.beginTransaction()
1262-
1263-
while not retVal.empty():
1264-
user, hash_, word = item = retVal.get(block=False)
1265-
hashDBWrite(hash_, word)
1266-
results.append(item)
1267-
1268-
if conf.hashDB:
1269-
conf.hashDB.endTransaction()
1268+
_finalize(retVal, results, processes, attack_info)
12701269

12711270
clearConsoleLine()
12721271

0 commit comments

Comments
 (0)