HackTricks
Search…
Pentesting
Powered By GitBook
Bruteforce hash (few chars)
1
import hashlib
2
3
target = '2f2e2e' #/..
4
candidate = 0
5
while True:
6
plaintext = str(candidate)
7
hash = hashlib.md5(plaintext.encode('ascii')).hexdigest()
8
if hash[-1*(len(target)):] == target: #End in target
9
print('plaintext:"' + plaintext + '", md5:' + hash)
10
break
11
candidate = candidate + 1
Copied!
1
#From isHaacK
2
import hashlib
3
from multiprocessing import Process, Queue, cpu_count
4
5
6
def loose_comparison(queue, num):
7
target = '0e'
8
plaintext = f"a_prefix{str(num)}a_suffix"
9
hash = hashlib.md5(plaintext.encode('ascii')).hexdigest()
10
11
if hash[:len(target)] == target and not any(x in "abcdef" for x in hash[2:]):
12
print('plaintext: ' + plaintext + ', md5: ' + hash)
13
queue.put("done") # triggers program exit
14
15
def worker(queue, thread_i, threads):
16
for num in range(thread_i, 100**50, threads):
17
loose_comparison(queue, num)
18
19
def main():
20
procs = []
21
queue = Queue()
22
threads = cpu_count() # 2
23
24
for thread_i in range(threads):
25
proc = Process(target=worker, args=(queue, thread_i, threads ))
26
proc.daemon = True # kill all subprocess when main process exits.
27
procs.append(proc)
28
proc.start()
29
30
while queue.empty(): # exits when a subprocess is done
31
pass
32
return 0
33
34
main()
Copied!
Last modified 6mo ago
Copy link