#!/usr/bin/perl
use strict;
use warnings;
use Crypt ::PK::RSA;
my ( $p , $w ) = @ARGV ;
my $k = Crypt ::PK::RSA->new;
print "[+] SSH/SSL RSA Private Key Passphrase dictionary enumerator\n" ;
&banner and die "[!] Usage: perl $0 <PRIVATE RSA KEY> <WORDLIST>" if @ARGV != 2;
my $iskey = do {
open (PRIVKEY, " <$p" ) or die "[-] Error: $p $!" ;
<PRIVKEY>
};
&banner and print "[-] Error: The choosen file is empty" and exit if (-z $p );
&banner and print "[-] Error: The choosen file is not valid private RSA key\n" and exit if $iskey !~ /--BEGIN RSA PRIVATE KEY--/;
open (WORDLIST, " <$w" ) or die "[-] Error: $w $!" ;
die "[-] Error: The wordlist is empty" if (-z $w );
my @file = <WORDLIST>;
print "[*] ======\n" ;
foreach my $c ( @file )
{
chomp $c ;
if (! eval { $k ->import_key( $p , $c ) }) {
print "[?] $c != Passphrase\n" ;
} else {
&banner and die "[*] Passphrase for $p is $c\n" ;
}
}
close (WORDLIST);
&banner and print "[-] Sorry, I could not find the passphrase or the private key is corrupted!\n" and exit ;
sub banner{
print "[*] ======\n" ;
print "[!] Author: Todor Donev <todor.donev at gmail.com>\n" ;
print "[*] ======\n" ;
}
|