Thursday, October 19, 2006

password generator

Wrote dictionary generator script for brute force my route passwd...I know I can use C4S3y's module to make the whole work easier and make some cool script, but I just want to get my hands dirty and review a little bit perl script...
#!/usr/bin/perl

# Author: insistkool
# Date: Oct-19-2006
# Purpose: password generator - Upper and Lower Case
use strict;
use Getopt::Std;

#The for loop here is to create a alpha lists

#for(1..9){
# print ",";
# print "\"".$_."\"";
#
#}
#
#for($i=65;$i<=90;$i++){
# print ",";
# print "\"".chr($i)."\"";
#
#}
#
#for($a=97;$a<=122;$a++){
# print ",";
# print "\"".chr($a)."\"";
#
#}



my @chars =("A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P",
"Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i",
"j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","1","2",
"3","4","5","6","7","8","9");

my ($x,$y,$z,$a,$b,$c,$dict,%opts);

getopts('h:o:', \%opts);

if(defined($opts{'o'})) {
$dict = $opts{'o'};
}
else {
$dict = "dict.txt";
}

if(defined($opts{'h'})) {
usage();
}

sub usage{
print "Usage: $0 -o dict.txt\n";
print " \t -h man page\n";
print "If output file is not specified, it will be saved to dict.txt\n";
exit 31337;
}

open(dict,">$dict");


for($x=0;$x<@chars;$x++){
for($y=0;$y<@chars;$y++){
for($z=0;$z<@chars;$z++){
for($a=0;$a<@chars;$a++){
print dict "$chars[$x]$chars[$y]$chars[$z]$chars[$a]\n";
}
}
}
}
print "Check $dict!\n";
close(dict);

No comments: