Created
June 9, 2015 19:42
-
-
Save godevnet/804650b72f3b1644c045 to your computer and use it in GitHub Desktop.
Bash script to test shadow user (sha512) with awk and python crypt getpass modules
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/bin/bash | |
# testpwd.sh | |
user=$1 | |
dic=$2 | |
shadow=/etc/shadow | |
original=$(<$shadow awk -v user=$user -F : 'user == $1 {print $2}') | |
prefix=${original%"${original#\$*\$*\$}"} | |
for pass in $(cat $dic); do | |
echo "Password : $pass" | |
computed=$(python -c "import crypt, getpass, pwd; print crypt.crypt('$pass', '$prefix')") | |
echo "Original : $original"; echo "Computed : $computed" | |
if [ "$computed" = "$original" ]; then echo "Matched !!!" ; else echo "No match"; fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment