?
Solved

Script Question

Posted on 2004-11-06
2
Medium Priority
?
320 Views
Last Modified: 2010-03-05
Remembering: This is only for educational purposes.

I got a script that tries do decode Unix Passwords. Want to pu a RESUME option to it. Its possible? and options of chr´s.. for exemple -l lower case, -u upper case and -n numerical. tnx!

Here de script:

#!/usr/bin/perl -w
# Apoc-Crack.pl by Adam Rogoyski (apoc@laker.net) Temperanc on EFNet irc
# Copyright (C) 1997 Adam Rogoyski
# Simple brute force attack on a unix encrypted password. checks all
# printable 7-bit ascii characters.  
# give it a file on the command line containing just an encrypted pw.
# warning: this program may take thousands of years to finish one run.
# bash-2.00$ ./apoc-crack.pl happy.pw
# --- GNU General Public License Disclamer ---
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

use strict;
my ($encrypted, $salt, $temp, $flag, $i, $j, $k, $l, $m, $n, $o, $p, $beep);
$encrypted = <>;
$salt = substr($encrypted, 0, 2);
$temp = "";
$flag = 0;
for ($i = 33; $i < 126; $i++)
{
   $temp = crypt( chr($i), $salt);
   if ($encrypted eq $temp)
   {
      $beep = chr(7);
      printf "$encrypted = %s $beep\n", chr($i);
      $flag = 1;
      last;
   }  
}
if ($flag) { exit 0; }
else { print "Password is at least 2 Characters Long\n"; }

for ($i = 33; $i < 126; $i++) {
   if ($flag) { exit 0; }
for ($j = 33; $j < 126; $j++)
{
   $temp = crypt( chr($i) . chr($j), $salt);
   if ($encrypted eq $temp)
   {
      $beep = chr(7);
      printf "$encrypted = %s $beep\n", chr($i) . chr($j);
      $flag = 1;
      last;
   }
} }
if ($flag) { exit 0; }
else { print "Password is at least 3 Characters Long\n"; }

for ($i = 33; $i < 126; $i++) {
for ($j = 33; $j < 126; $j++) {
   if ($flag) { exit 0; }
for ($k = 33; $k < 126; $k++)
{
   $temp = crypt( chr($i) . chr($j) . chr($k), $salt);
   if ($encrypted eq $temp)
   {
      $beep = chr(7);
      printf "$encrypted = %s $beep\n", chr($i) . chr($j) . chr($k);
      $flag = 1;
      last;
   }
} } }
if ($flag) { exit 0; }
else { print "Password is at least 4 Characters Long\n"; }




for ($i = 33; $i < 126; $i++) {
for ($j = 33; $j < 126; $j++) {
for ($k = 33; $k < 126; $k++) {
   if ($flag) { exit 0; }
for ($l = 33; $l < 126; $l++)
{
   $temp = crypt( chr($i) . chr($j) . chr($k) . chr($l), $salt);
   if ($encrypted eq $temp)
   {
      $beep = chr(7);
      printf "$encrypted = %s $beep\n", chr($i) . chr($j) . chr($k)
                                      . chr($l);
      $flag = 1;
      last;
   }
} } } }
if ($flag) { exit 0; }
else { print "Password is at least 5 Characters Long\n"; }



for ($i = 33; $i < 126; $i++) {
for ($j = 33; $j < 126; $j++) {
for ($k = 33; $k < 126; $k++) {
for ($l = 33; $l < 126; $l++) {
   if ($flag) { exit 0; }
for ($m = 33; $m < 126; $m++)
{
   $temp = crypt( chr($i) . chr($j) . chr($k) . chr($l)
                . chr($m), $salt);
   if ($encrypted eq $temp)
   {
      $beep = chr(7);
      printf "$encrypted = %s $beep\n", chr($i) . chr($j) . chr($k)
                                      . chr($l) . chr($m);
      $flag = 1;
      last;
   }
} } } } }
if ($flag) { exit 0; }
else { print "Password is at least 6 Characters Long\n"; }



for ($i = 33; $i < 126; $i++) {
for ($j = 33; $j < 126; $j++) {
for ($k = 33; $k < 126; $k++) {
for ($l = 33; $l < 126; $l++) {
for ($m = 33; $m < 126; $m++) {
   if ($flag) { exit 0; }
for ($n = 33; $n < 126; $n++)
{
   $temp = crypt( chr($i) . chr($j) . chr($k) . chr($l)
                . chr($m) . chr($n), $salt);
   if ($encrypted eq $temp)
   {
      $beep = chr(7);
      printf "$encrypted = %s $beep\n", chr($i) . chr($j) . chr($k)
                                      . chr($l) . chr($m) . chr($n);
      $flag = 1;
      last;
   }
} } } } } }
if ($flag) { exit 0; }
else { print "Password is at least 7 Characters Long\n"; }



for ($i = 33; $i < 126; $i++) {
for ($j = 33; $j < 126; $j++) {
for ($k = 33; $k < 126; $k++) {
for ($l = 33; $l < 126; $l++) {
for ($m = 33; $m < 126; $m++) {
for ($n = 33; $n < 126; $n++) {
   if ($flag) { exit 0; }
for ($o = 33; $o < 126; $o++)
{
   $temp = crypt( chr($i) . chr($j) . chr($k) . chr($l)
                . chr($m) . chr($n) . chr($o), $salt);
   if ($encrypted eq $temp)
   {
      $beep = chr(7);
      printf "$encrypted = %s $beep\n", chr($i) . chr($j) . chr($k)
                                      . chr($l) . chr($m) . chr($n)
                                      . chr($o);
      $flag = 1;
      last;
   }
} } } } } } }
if ($flag) { exit 0; }
else { print "Password is at least 8 Characters Long\n"; }



for ($i = 33; $i < 126; $i++) {
for ($j = 33; $j < 126; $j++) {
for ($k = 33; $k < 126; $k++) {
for ($l = 33; $l < 126; $l++) {
for ($m = 33; $m < 126; $m++) {
for ($n = 33; $n < 126; $n++) {
for ($o = 33; $o < 126; $o++) {
   if ($flag) { exit 0; }
for ($p = 33; $p < 126; $p++)
{
   $temp = crypt( chr($i) . chr($j) . chr($k) . chr($l)
                . chr($m) . chr($n) . chr($o) . chr($p), $salt);
   if ($encrypted eq $temp)
   {
      $beep = chr(7);
      printf "$encrypted = %s $beep\n", chr($i) . chr($j) . chr($k)
                                      . chr($l) . chr($m) . chr($n)
                                      . chr($o) . chr($p);
      $flag = 1;
      last;
   }
} } } } } } } }
if ($flag) { exit 0; }
else { print "Password uses characters other than 7-bit Ascii\n"; }

exit 0;
0
Comment
Question by:cels9
2 Comments
 
LVL 85

Accepted Solution

by:
ozo earned 2000 total points
ID: 12516356
use strict;
use Getopt::Std;
my ($encrypted, $salt, $temp, $flag, $i, $j, $k, $l, $m, $n, $o, $p, $beep);
my %opts;
getopts('lunR:', \%opts);
chomp($encrypted = <>);
$salt = substr($encrypted, 0, 2);
my @charset;
push @charset,'0'..'9' if $opts{n};
push @charset,'A'..'Z' if $opts{u};
push @charset,'a'..'z' if $opts{l};
@charset = map{chr}33..126 unless @charset;
my %next;
@next{'',@charset}=(@charset,$charset[0]);
my @temp = split//,$opts{R}||$charset[0];
$j=1;
$SIG{INT}=$SIG{QUIT}=sub{
    print "\n`$0",$opts{n}&&" -n",$opts{u}&&" -u",$opts{l}&&" -l",$temp&&" -R \Q$temp\E","`\n$encrypted\nto resume\n";
    exit;
};
while( @temp <= 8 ){
   $temp = join'',@temp;
   #print "$temp\n";
   if( $encrypted eq crypt $temp, $salt ){
      $beep = chr(7);
      printf "$encrypted = %s $beep\n", $temp;
      exit;
   }  
   for$i(1..8){
         if( $i > @temp ){
             print "Password is at least $i Characters Long\n";
             unshift @temp,$charset[0];
             last;
         }
         last if ($temp[-$i]=$next{$temp[-$i]}) ne $charset[0];
    }
}
print "Password uses characters other than",(($opts{n}&&" digits").($opts{u}&&" uppercase").($opts{l}," lowercase"))||"printable Ascii","\n";
exit 0;
0
 

Author Comment

by:cels9
ID: 12518671
And when find the pass, send a email and write in a file? tnx. ozo = t.best
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
Article by: Tammy
MySQLTuner is a script written in Perl that allows you to review a MySQL installation quickly and make adjustments to increase performance and stability. The current configuration variables and status data is retrieved and presented in a brief forma…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans
Suggested Courses

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question