by dpritchett · 14y ago · 0 comments
>>> from hashlib import sha1
>>> def check_pass(plaintext, offset=5):
hashed = sha1(plaintext).hexdigest()
return (hashed, '0' * offset + hashed[offset:])
>>> check_pass("linkedin")
('7728240c80b6bfd450849405e8500d6d207783b6',
'0000040c80b6bfd450849405e8500d6d207783b6')
Edit: I'm pretty sure JtR refers to this: http://en.wikipedia.org/wiki/John_the_Ripper perl -MDigest::SHA -le '$h = substr( Digest::SHA::sha1_hex($ARGV[0]) , 5 ); open F, "<combo_not.txt"; do { print "found $_" if grep(/$h/, $_) } while (<F>)' password
(for people without shells) grep `echo -n password | shasum | cut -c6-40` hacked.txt grep `read -sp "password: "; echo "$REPLY" | tr -d "\n" | shasum | cut -c6-40` hacked.txt kill -9 $$ $ echo linkedin | xargs node -e "var x = require('crypto').createHash('sha1').update(process.argv[1]).digest('hex'); console.log([x, '00000' + x.substring(5)]);"
7728240c80b6bfd450849405e8500d6d207783b6
0000040c80b6bfd450849405e8500d6d207783b6" xargs node -e "
do?
Thank you
- not portable
- useless use of backticks
printf password|openssl sha1|cut -c6-40|grep -f - hacked.txt
perl -MDigest::SHA=sha1_hex -le '$h = substr( sha1_hex(shift), 5 ); open F, "<combo_not.txt"; print "found $_" for grep /$h/, <F>' password
Or: perl -MDigest::SHA=sha1_hex -lne 'BEGIN {$pw = shift} $h = substr( sha1_hex($pw), 5 ); print "found $_" if /$h/' password combo_not.txtwhile read line; do echo -n $line | sha1sum | cut -c6-40 | awk '{print "00000" $0}'; done < rockyou.txt
I haven't tested that, but I think it'll work.
>>> import getpass
>>> password = getpass.getpass('Password: ')
http://docs.python.org/library/getpass.html