Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl -w
- use strict;
- use Getopt::Long;
- use Carp;
- use Term::ANSIColor qw/:constants/;
- our $VERSION = 0.0.0.0.0.0000004;
- #
- # usage:
- # hash-utils --wordlist /tmp/wordlist --md5 098f6bcd4621d373cade4e832627b4f6
- # hash-utils --wordlist /tmp/wordlist --sha1 a94a8fe5ccb19ba61c4c0873d391e987982fbbd3
- # hash-utils --wordlist /tmp/wordlist --sha2 9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08
- # echo -n 'test' |./hash-utils --sha256 9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08
- # cat /tmp/wordlist |./hash-utils --sha256 9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08
- #
- # * hash-utils (streamed)
- # m0user at 2013-09
- #
- croak "$0 --[md5|sha224|sha256|sha384|sha512|sha2][=]hash --wordlist[=]path\n\n" unless scalar @ARGV;
- my $set =+{
- 'wordlist' => 'no',
- 'md5-hex' => 'no',
- 'sha224-hex' => 'no',
- 'sha256-hex' => 'no',
- 'sha384-hex' => 'no',
- 'sha512-hex' => 'no',
- 'sha1-hex' => 'no',
- 'sha2_256-hex' => 'no',
- 'time' => time,
- };
- GetOptions( "wordlist=s" => \$set->{'wordlist'},
- 'md5=s' => \$set->{'md5-hex'},
- 'sha224=s' => \$set->{'sha224-hex'},
- 'sha256=s' => \$set->{'sha256-hex'},
- 'sha384=s' => \$set->{'sha384-hex'},
- 'sha512=s' => \$set->{'sha512-hex'},
- 'sha1=s' => \$set->{'sha1-hex'},
- 'sha2=s' => \$set->{'sha2_256-hex'},
- );
- open WL, "<", $set->{'wordlist'} or croak "$!\n\n"
- unless $set->{'wordlist'} eq 'no';
- *WL = \*STDIN if $set->{'wordlist'} eq 'no'; # STDIN STREAM
- # md4
- &md5_hex_util($set, \*WL) if $set->{'md5-hex'} ne 'no'; #stdlib
- &sha224_hex_util($set, \*WL) if $set->{'sha224-hex'} ne 'no'; #stdlib
- &sha256_hex_util($set, \*WL) if $set->{'sha256-hex'} ne 'no'; #stdlib
- &sha384_hex_util($set, \*WL) if $set->{'sha384-hex'} ne 'no'; #stdlib
- &sha512_hex_util($set, \*WL) if $set->{'sha512-hex'} ne 'no'; #stdlib
- &sha1_hex_util($set, \*WL) if $set->{'sha1-hex'} ne 'no'; #stdlib
- &sha2_hex_util($set, \*WL) if $set->{'sha2_256-hex'} ne 'no'; #CPAN
- # sha-3
- close WL if $set->{'wordlist'} ne 'no';
- exit;
- # equal to SHA256
- # SHA2-hex crack tool
- # test = 9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08
- sub sha2_hex_util {
- use Digest::SHA2;
- croak 'sha2_256_hex_util($set, \*HANDLE)', "\n\n" if scalar @_ != 2;
- my ($set, $HANDLE) = (shift, shift);
- my $sha2obj = new Digest::SHA2 256;
- foreach(<$HANDLE>) {
- chomp;
- print "`$_'";
- $sha2obj->add($_);
- if ($set->{'sha2_256-hex'} eq $sha2obj->hexdigest) {
- print GREEN " Got password!", RESET, "\n\n";
- print "SHA2_256-hex `$set->{'sha2_256-hex'}'\n";
- print "Password `$_'\n";
- print "Elapsed, ", time - $set->{'time'}, " seconds\n\n";
- close WL and exit;
- }
- print RED " WRONG", RESET, "\n";
- $sha2obj->reset;
- }
- print "\n\n", RED "password not found!", RESET, "\n" and return;
- }
- #
- # SHA1-hex crack tool
- #
- sub sha1_hex_util {
- use Digest::SHA qw/sha1_hex/;
- croak 'sha1_hex_util($set, \*HANDLE)', "\n\n" if scalar @_ != 2;
- my ($set, $HANDLE) = (shift, shift);
- foreach(<$HANDLE>) {
- chomp;
- print "`$_'";
- if ($set->{'sha1-hex'} eq sha1_hex($_)) {
- print GREEN " Got password!", RESET, "\n\n";
- print "SHA1-hex `$set->{'sha1-hex'}'\n";
- print "Password `$_'\n";
- print "Elapsed, ", time - $set->{'time'}, " seconds\n\n";
- close WL and exit;
- }
- print RED " WRONG", RESET, "\n";
- }
- print "\n\n", RED "password not found!", RESET, "\n" and return;
- }
- #
- # sha224-hex cracking util
- # test = 90a3ed9e32b2aaf4c61c410eb925426119e1a9dc53d4286ade99a809
- sub sha224_hex_util {
- use Digest::SHA qw/sha224_hex/;
- croak 'sha224_hex_util($set, \*HANDLE)', "\n\n" if scalar @_ != 2;
- my ($set, $HANDLE) = (shift, shift);
- foreach(<$HANDLE>) {
- chomp;
- print "`$_'";
- if ($set->{'sha224-hex'} eq sha224_hex($_)) {
- print GREEN " Got password!", RESET, "\n\n";
- print "SHA224-hex `$set->{'sha224-hex'}'\n";
- print "Password `$_'\n";
- print "Elapsed, ", time - $set->{'time'}, " seconds\n\n";
- close WL and exit;
- }
- print RED " WRONG", RESET, "\n";
- }
- print "\n\n", RED "password not found!", RESET, "\n" and return;
- }
- #
- # SHA256-hex crack tool
- #
- sub sha256_hex_util {
- use Digest::SHA qw/sha256_hex/;
- croak 'sha256_hex_util($set, \*HANDLE)', "\n\n" if scalar @_ != 2;
- my ($set, $HANDLE) = (shift, shift);
- foreach(<$HANDLE>) {
- chomp;
- print "`$_'";
- if ($set->{'sha256-hex'} eq sha256_hex($_)) {
- print GREEN " Got password!", RESET, "\n\n";
- print "SHA256-hex `$set->{'sha256-hex'}'\n";
- print "Password `$_'\n";
- print "Elapsed, ", time - $set->{'time'}, " seconds\n\n";
- close WL and exit;
- }
- print RED " WRONG", RESET, "\n";
- }
- print "\n\n", RED "password not found!", RESET, "\n" and return;
- }
- #
- # SHA384-hex crack tool
- # test = 768412320f7b0aa5812fce428dc4706b3cae50e02a64caa16a782249bfe8efc4b7ef1ccb126255d196047dfedf17a0a9
- sub sha384_hex_util {
- use Digest::SHA qw/sha384_hex/;
- croak 'sha384_hex_util($set, \*HANDLE)', "\n\n" if scalar @_ != 2;
- my ($set, $HANDLE) = (shift, shift);
- foreach(<$HANDLE>) {
- chomp;
- print "`$_'";
- if ($set->{'sha384-hex'} eq sha384_hex($_)) {
- print GREEN " Got password!", RESET, "\n\n";
- print "SHA384-hex `$set->{'sha384-hex'}'\n";
- print "Password `$_'\n";
- print "Elapsed, ", time - $set->{'time'}, " seconds\n\n";
- close WL and exit;
- }
- print RED " WRONG", RESET, "\n";
- }
- print "\n\n", RED "password not found!", RESET, "\n" and return;
- }
- #
- # SHA512-hex crack tool
- # test = ee26b0dd4af7e749aa1a8ee3c10ae9923f618980772e473f8819a5d4940e0db27ac185f8a0e1d5f84f88bc887fd67b143732c304cc5fa9ad8e6f57f50028a8ff
- sub sha512_hex_util {
- use Digest::SHA qw/sha512_hex/;
- croak 'sha512_hex_util($set, \*HANDLE)', "\n\n" if scalar @_ != 2;
- my ($set, $HANDLE) = (shift, shift);
- foreach(<$HANDLE>) {
- chomp;
- print "`$_'";
- if ($set->{'sha512-hex'} eq sha512_hex($_)) {
- print GREEN " Got password!", RESET, "\n\n";
- print "sha512-hex `$set->{'sha512-hex'}'\n";
- print "Password `$_'\n";
- print "Elapsed, ", time - $set->{'time'}, " seconds\n\n";
- close WL and exit;
- }
- print RED " WRONG", RESET, "\n";
- }
- print "\n\n", RED "password not found!", RESET, "\n" and return;
- }
- #
- # MD5-hex crack tool
- #
- sub md5_hex_util {
- use Digest::MD5 qw/md5_hex/;
- croak 'md5_hex_util($set, \*HANDLE)', "\n\n" if scalar @_ != 2;
- my ($set, $HANDLE) = (shift, shift);
- foreach(<$HANDLE>) {
- chomp;
- print "`$_'";
- if ($set->{'md5-hex'} eq md5_hex($_)) {
- print GREEN " Got password!", RESET, "\n\n";
- print "MD5-hex `$set->{'md5-hex'}'\n";
- print "Password `$_'\n";
- print "Elapsed, ", time - $set->{'time'}, " seconds\n\n";
- close WL and exit;
- }
- print RED " WRONG", RESET, "\n";
- }
- print "\n\n", RED "password not found!", RESET, "\n" and return;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement