Last active
October 16, 2017 08:46
-
-
Save mschmitt/5729532 to your computer and use it in GitHub Desktop.
Check whether a given password matches a given salted hash from /etc/shadow.
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
#!/usr/bin/perl -w | |
use strict; | |
use diagnostics; | |
use Crypt::Passwd::XS; | |
print "Paste hash here: "; | |
my $hash = <>; | |
print "Enter password (will not echo): "; | |
system('stty', '-echo'); | |
my $pass = <>; | |
system('stty', 'echo'); | |
print "\n"; | |
chomp $hash; | |
chomp $pass; | |
if (Crypt::Passwd::XS::crypt($pass, $hash) eq $hash){ | |
print "OK: Password and hash match.\n"; | |
}else{ | |
print "SORRY: Password and hash DO NOT match.\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment