发新话题
打印

[转载]encrypter/decrypter to password generator(支持MD5和DES)

[转载]encrypter/decrypter to password generator(支持MD5和DES)

文章作者:nuTshell
复制内容到剪贴板
代码:
#!/usr/bin/perl
#
# Cryptonite written by nuTshell
# [url]http://nutshell.gotfault.net[/url]
#
# Description: Cryptonite is [encrypter/decrypter<->password generator]
# Supported Algoriths are MD5 and DES.
#
# Criptonite can do things like:
# -Encrypt single password from command line;
# -Encrypt cleartext passwords from textfile;
# -Decrypt encrypted password taking cleartext passwords from textfile
#
# eg. MD5 decryption:
#
# # cat /etc/shadow |grep ^test
# test:$1$B0Z/2qHu$ukj7EmMbRC7NsT5UwlPLm1:12992:0:99999:7:::
# $ ./cryptonite.pl -decrypMD5 &#39;$1$B0Z/2qHu$ukj7EmMbRC7NsT5UwlPLm1&#39; wordlist
# [*] Testing: testing
# [*] Testing: areyouok
# [*] Testing: aracnophobia
# [*] Testing: kern3ltest1ng
# [*] Testing: hithere
# [*] Testing: hackme
#
# [:)] HACK HACK HACK lalalalala
# [!] $1$B0Z/2qHu$ukj7EmMbRC7NsT5UwlPLm1 cracked password is: hackme
# Execution time: 0s
# $
#
# eg. DES creation of single password:
#
# $ ./cryptonite.pl -DES hithere
# Algorithm: DES
# nb1o8FrXI7iAQ
# $
#
# TIP: You could use gen.pl <[url]http://nutshell.gotfault.net/geni/gen.html>[/url]
# to create wordlists!
#
# *************************************************************************
#
# IMPORTANT 1: When inserting encrypted passwords from command line ALWAYS
# use (&#39;) single quotations marks.. ALWAYS!!!!
#
# IMPORTANT 2: When using wordlist out there make sure to transform then
# in ASCII linux file, for example:
#
# BAD FILE:
# $ file Unix_dict.txt
# Unix_dict.txt: ASCII C program text, with CRLF line terminators
# GOD FILE:
# $ dos2unix Unix_dict.txt
# $ file Unix_dict.txt
# Unix_dict.txt: ASCII C program text
#
# dos2unix is a very handy tool :)
#
# *************************************************************************
#
# To do: support for more ciphers.
#
# For usage help just type: ./cryptonite.pl
#
# Greets to all of friends out there
#
use strict;
use Term::ANSIColor;

my ($x,$begintime,$endtime,$endtimefail,$endtimesuccess,$endtimeS,$endtimeF,$cleartext);
# Array for random salts
my @array = split(",","a,b,c,d,e,f,g,h,i,j,l,m,n,o,p,q,r,s,t,u,v,x,z,y,w,k,A,B,C,D,E,F,G,H,I,J,L,M,N,O,P,Q,R,S,T,U,V,X,Z,Y,W,K,,0,1,2,3,4,5,6,7,8,9");
# MD5 8 salts, same of /etc/shadow, you can increase or decrease, but never lower than 2
my $MD5salts = 8;
# DES 2 salts, you can increase it but never decrease it
my $DESsalts = 2;

if ($MD5salts < 2 || $DESsalts < 2) {
    die "Can`t use salt lower than 2. Change variable(s) and then try again\n"
}
   
sub usage() {
die <<EOF

Cryptonite written by nuTshell
Encrypted password[generator/cracker]

Usage: $0 [-MD5|-DES|]
Options:
-MD5            [passfrase|-input {input_file}{output_file}]
-DES            [passfrase|-input {input_file}{output_file}]
-decrypMD5        [&#39;cripted_password&#39; wordlist_file]
-decrypDES        [&#39;cripted_password&#39; wordlist_file]
EOF
}

sub crypmeMD5 () {
my $cleartext = $ARGV[1];
      if ($cleartext eq "-input") {
           my $inputfile = $ARGV[2] or &usage;
           my $outputfile = $ARGV[3] or &usage;
           open(INPUT, "<$inputfile") or die "$!\n";
           open(ZERO,">$outputfile") or die "$!\n";
           print(ZERO "Algorithm: MD5\n\n");
           close(ZERO);
           open(OUTPUT,">>$outputfile");
        print("Algorithm: MD5\n");
      foreach my $outline (<INPUT>) {
           for(1..$MD5salts) {
                my $array = $array[rand(@array)] ;
                $x .= $array;
           }
        chomp($outline);
        my $pass = crypt($outline,"\$1\$$x");
           chomp($outline);chomp($pass);
           print(OUTPUT "$outline : $pass\n");
           print("$outline : $pass\n");
           $x = "";
      }
      }
      else {
           for(1..$MD5salts) {
                my $array = $array[rand(@array)] ;
                $x .= $array;
           }
        my $pass = crypt($cleartext,"\$1\$$x");
        print("Algorithm: MD5\n");
           print "$pass\n"
      }

}


sub crypmeDES () {
my $cleartext = $ARGV[1];
    if ($cleartext eq "-input") {
        my $inputfile = $ARGV[2] or &usage;
        my $outputfile = $ARGV[3] or &usage;
        open(INPUT, "<$inputfile") or die "$!\n";
        open(ZERO,">$outputfile") or die "$!\n";
        print(ZERO "Algorithm: DES\n\n");
        close(ZERO);
        open(OUTPUT,">>$outputfile");
        print("Algorithm: DES\n");
    foreach my $outline (<INPUT>) {
        for(1..$DESsalts) {
              my $array = $array[rand(@array)] ;
              $x .= $array;
        }
        my $pass = crypt($outline,"$x");
        chomp($outline);chomp($pass);
        print(OUTPUT "$outline : $pass\n");
        print("$outline : $pass\n");
        $x = "";
    }
    }
    else {
        for(1..$DESsalts) {
            my $array = $array[rand(@array)] ;
            $x .= $array;
        }
        my $pass = crypt($cleartext,"$x");
        print("Algorithm: DES\n");
        print "$pass\n"
    }
        
}

sub decrypMD5() {
my $pass_to_crack = $ARGV[1] or die &usage;
my $inputpassfile = $ARGV[2] or die &usage;
open(INPUT, "<$inputpassfile") or die "$!\n";
$begintime = localtime();
    foreach my $try (<INPUT>) {
        chomp($try);
        my $check = crypt($try,$pass_to_crack);
        chomp($try);
        print("[*] Testing: $try\n");
        if ($check eq $pass_to_crack) {
                print("\nStarted time: $begintime\n");
                print("[:)] HACK HACK HACK lalalalala\n");
                      print("[!] $pass_to_crack cracked password is: ");
                print color(&#39;bold&#39;);
                print("$try\n");
                print color(&#39;reset&#39;);
                $endtimeS = localtime();
                print("Finished time: $endtimeS\n");
                exit(0);
            }
    }
close(INPUT);
$endtimeF = localtime();
print("\nStarted time: $begintime\n");
print("No passwords cracked. Better luck next time.\n");
print("Finished time: $endtimeF\n");
}


sub decrypDES() {
my $pass_to_crack = $ARGV[1] or die &usage;
my $inputpassfile = $ARGV[2] or die &usage;
open(INPUT, "<$inputpassfile") or die "$!\n";
$begintime = localtime();
      foreach my $try (<INPUT>) {
           my $check = crypt($try,$pass_to_crack);
           chomp($try);
           print("[*] Testing: $try\n");
           if ($check eq $pass_to_crack) {
                print("\nStarted time: $begintime\n");
                      print("[:)] HACK HACK HACK lalalalala\n");
                      print("[!] $pass_to_crack cracked password is: ");
                      print color(&#39;bold&#39;);
                      print("$try\n");
                      print color(&#39;reset&#39;);
                $endtimeS = localtime();
                print("Finished time: $endtimeS\n");
                      exit(0);
                }
      }
$endtimeF = localtime();
print("\nStarted time: $begintime\n");
print("No passwords cracked. Better luck next time.\n");
print("Finished time: $endtimeF\n");

}

my %cmd = (
      "-MD5" => \&crypmeMD5,
    "-decrypMD5" => \&decrypMD5,
      "-DES" => \&crypmeDES,
    "-decrypDES" => \&decrypDES,
      "-help" => \&usage,
);
   chomp(my $string = $ARGV[0]);
   if ($cmd{$string}) {
      $cmd{$string}->();
   } else {&usage}
#eof
曾几何时,有人对我说:装B遭雷劈。我说:去你妈的。于是,这个人又对我说:如果再说脏话,上帝会惩罚你的。我说:我操上帝。结论:彪悍的人生不需要上帝。

TOP

发新话题