Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import itertools
- import hashlib
- def md5_crack(target_hash, min_length, max_length):
- charset = [chr(i) for i in range(ord('a'), ord('z')+1)] + \
- [chr(i) for i in range(ord('A'), ord('Z')+1)] + \
- [chr(i) for i in range(ord('0'), ord('9')+1)] + \
- list('!@#$%^&*()_-+=[]{}|;:,.<>?')
- for length in range(min_length, max_length + 1):
- for attempt in itertools.product(charset, repeat=length):
- attempt_str = ''.join(attempt)
- if hashlib.md5(attempt_str.encode()).hexdigest() == target_hash:
- return attempt_str
- return None
- target = '900150983cd24fb0d6963f7d28e17f72' # MD5 hash of 'abc'
- result = md5_crack(target, 1, 4)
- if result:
- print(f"Password found: {result}")
- else:
- print("Password not found within the specified range and character set.")
Advertisement
Add Comment
Please, Sign In to add comment