Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- # -*- coding: utf-8 -*-
- import sys, hashlib
- from os import isatty
- def usage(i=1):
- print("Usage: ./cracktrunc.py hashlist < wordlist")
- exit(i)
- def compHash(hashlist, md5, plain):
- for h in hashlist:
- if md5.startswith(h):
- print(h + ":" + plain.decode("utf-8"))
- return [x for x in hashlist if x != h]
- return hashlist
- if len(sys.argv) is not 2:
- usage()
- hashlist = sys.argv[1]
- # we only want to read files, no interactive input
- if isatty(0):
- usage()
- # make stream binary, hahslib needs binary data
- stdin = sys.stdin.detach()
- with open(hashlist, "r") as f:
- hashlist = list(map(lambda x: x.rstrip("\r\n"), list(f)))
- for word in stdin:
- # remove newline stuff
- word = word.rstrip(b"\r\n")
- # hash the candidate
- md5 = hashlib.md5(word).hexdigest()
- hashlist = compHash(hashlist, md5, word)
- if not hashlist:
- print("Everything recovered.")
- exit(0)
- print("### Not found ###")
- for h in hashlist:
- print(h)
- exit(5)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement