rust lol
This commit is contained in:
18
enforcer.py
18
enforcer.py
@@ -1,3 +1,5 @@
|
||||
import sys
|
||||
import time
|
||||
from multiprocessing import Pool
|
||||
from hashlib import sha256
|
||||
|
||||
@@ -36,18 +38,23 @@ def main(real_file, fake_file, num_chars):
|
||||
all_fake_hashes = {}
|
||||
|
||||
found_collision = False
|
||||
total_hashes = 0
|
||||
batch_size = 100 # Number of combinations to process in parallel
|
||||
start_time = time.time() # Start time to measure hashes per second
|
||||
|
||||
# Use multiprocessing Pool
|
||||
with Pool() as pool:
|
||||
i = 0
|
||||
while not found_collision:
|
||||
# Prepare a batch of bit patterns to process in parallel
|
||||
batch_size = 100 # Number of combinations to process in parallel
|
||||
bit_patterns = [(real_og, fake_og, num_chars, pattern) for pattern in range(i, i + batch_size)]
|
||||
|
||||
# Process the batch in parallel
|
||||
results = pool.map(modify_and_hash, bit_patterns)
|
||||
|
||||
# Update the total count of hashes processed
|
||||
total_hashes += len(results)
|
||||
|
||||
# Check the results for a hash collision
|
||||
for real_hash, fake_hash, real_modified, fake_modified in results:
|
||||
all_real_hashes[real_hash] = real_modified
|
||||
@@ -55,7 +62,7 @@ def main(real_file, fake_file, num_chars):
|
||||
|
||||
if real_hash in all_fake_hashes or fake_hash in all_real_hashes:
|
||||
collision_hash = real_hash if real_hash in all_fake_hashes else fake_hash
|
||||
print(f"Collision found! {real_file}.out and {fake_file}.out have the same hash: {collision_hash}")
|
||||
print(f"\n[+] Collision found! {real_file}.out and {fake_file}.out have the same hash: {collision_hash}")
|
||||
|
||||
with open(f"{real_file}.out", 'w') as f_out:
|
||||
f_out.writelines("\n".join(all_real_hashes[collision_hash]))
|
||||
@@ -65,10 +72,15 @@ def main(real_file, fake_file, num_chars):
|
||||
found_collision = True
|
||||
break
|
||||
|
||||
# Update progress every batch
|
||||
elapsed_time = time.time() - start_time
|
||||
hashes_per_sec = total_hashes / elapsed_time
|
||||
print(f"\rProcessed {total_hashes} hashes in {elapsed_time:.2f} seconds, {hashes_per_sec:.2f} H/s", end='')
|
||||
|
||||
# Increment the bit pattern range
|
||||
i += batch_size
|
||||
|
||||
if __name__ == "__main__":
|
||||
import sys
|
||||
if len(sys.argv) != 4:
|
||||
print(f"Usage: {sys.argv[0]} <real_file> <fake_file> <num_chars>")
|
||||
sys.exit(1)
|
||||
|
||||
Reference in New Issue
Block a user