Bound crack memory: cap wordlist sort, chunk target loading
- prepare_candidates: use sort -S 1G --parallel 4 (was unbounded, OOM-prone on large --passwords-from datasets) - crack: add --max-hashes to stream large hash files in bounded chunks, so the in-RAM target index no longer scales with the whole input - docs + regression test for chunked cracking
This commit is contained in:
1 parent
1ead58173c
commit
3b7011f433
4 files changed
+119
-36
No files matched your search
@@ -72,6 +72,29 @@ class CrackTest(unittest.TestCase):
|
||||
self.assertEqual(1, total)
|
||||
self.assertEqual([b"[email protected]:reused"], out.read_bytes().splitlines())
|
||||
|
||||
def test_crack_chunks_hash_file(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
hashes = Path(tmp) / "hashes.txt"
|
||||
hashes.write_bytes(
|
||||
b"[email protected]:" + hashlib.md5(b"hunter2").hexdigest().encode() + b"\n"
|
||||
b"[email protected]:" + hashlib.sha1(b"secret").hexdigest().encode() + b"\n"
|
||||
)
|
||||
wordlist = Path(tmp) / "words.txt"
|
||||
wordlist.write_bytes(b"hunter2\nsecret\n")
|
||||
out = Path(tmp) / "cracked.txt"
|
||||
total = crack(
|
||||
str(hashes),
|
||||
str(out),
|
||||
wordlists=[str(wordlist)],
|
||||
workers=1,
|
||||
max_hashes=1,
|
||||
)
|
||||
self.assertEqual(2, total)
|
||||
self.assertEqual(
|
||||
{b"[email protected]:hunter2", b"[email protected]:secret"},
|
||||
set(out.read_bytes().splitlines()),
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user