Please don't delete code from your original question or change it otherwise without stating so.
When you have problems formatting content for PM please see Writeup Formatting Tips as frodo72 already stated.

Referring to offsite code (on your own server) isn't a good idea either, you would probably not keep it there forever, and other monks will get a different picture of this thread when you're changing the OP afterwards.

In fact, you changed even your code on your server, taking snippets from my last reply and now it looks like I just took out a few spaces and posted a neater version of yours.

I thought in posting a refactored, tidier and more compact version you could compare your efforts with someone elses try.

In your current version of your offsite code (http://as.switch2hosting.com/perl.txt) you took snippets and ideas from our replies and included following statement now:

You are free to customize this script as you wish, but do not
redistribute without written permission from TipoNaSoft.

Huh?
Is it really so special that one needs a written permission from you?

I'm adding your original code now below just that I don't stand here as a fool.

Original posting (OP) from RayQ:
#!/usr/bin/perl -T use Getopt::Std; use Digest::SHA qw(sha1_hex sha224_hex sha256_hex sha384_hex sha512_he +x); use Digest::MD5 qw(md5_hex); getopts('d:h:f:m:a'); my $dictionary = $opt_d; my $hash = $opt_h; my $mode = $opt_m; my $help = $opt_a; my $passfile = $opt_f; if($mode == ""){$mode = "md5";} my $algo = $mode; my %length; $length{'md5'} = 32; $length{'sha1'} = 40; $length{'sha224'} = 56; $length{'sha256'} = 64; $length{'sha384'} = 96; $length{'sha512'} = 128; if($help && (!$hash && !$passfile) || (!$hash && !$passfile)){help();e +xit(1);} &main; sub main { if($dictionary eq "") { $dictionary = "/usr/share/dict/words"; } if($hash) { if(length($hash) != $length{$algo}) { print STDERR "Invalid hash length!\nLength for an $algo ha +sh should be $length{$algo}!\nSee $0 -a for details.\n"; exit(1); } print "Cracking....\n"; } if($passfile eq "") { open DICT, $dictionary or die(" Could not open dictionary file : $dictionary. Please make sure the file exists and you have read access +to it. Error occured"); while(<DICT>) { chomp($_); if(hash($algo, $_) eq $hash) { print "\nMatch found!\nPlainText : " . $_ . "\n\n"; exit(0); } } } else { open PASS, $passfile or die(" Could not open password file : $passfile. Please make sure the file exists and you have read access +to it. Error occured"); print "Cracking....\n"; while(<PASS>) { open DICT, $dictionary or die(" Could not open dictionary file : $dictionary. Please make sure the file exists and you have read acc +ess to it. Error occured"); my $curpass = $_; chomp($curpass); chop($curpass); while(<DICT>) { my $word = $_; chomp($word); chop($word); #print $number."\n"; if(hash($algo, $word) eq $curpass) { print "$curpass :: $word\n"; close(DICT); } } } close(PASS); } exit(1); } sub help { print " Usage: $0 [-d dictionary] [-h hash|-f file] [-m mode]\n Crack [hash] or [file] using [mode] hashing, and [dictionary] +file.\n Currently, supported hashing methods are: MD5 SHA1 SHA224 SHA256 SHA384 SHA512 If no dictionary file is specified, /usr/share/dict/words will + be used.\n If no mode is specified, MD5 will be used. Example: $0 -h a94a8fe5ccb19ba61c4c0873d391e987982fbbd3 -m sha1 $0 -d /usr/local/Wordlist -h 098f6bcd4621d373cade4e832627b4f6 $0 -f /usr/bin/passwords.txt -d /usr/local/Wordlist \n"; } sub hash # hash($algo, $_) { if($_[0] eq "md5") { return md5_hex($_[1]); } elsif($_[0] eq "sha1") { return sha1_hex($_[1]); } elsif($_[0] eq "sha224") { return sha224_hex($_[1]); } elsif($_[0] eq "sha256") { return sha256_hex($_[1]); } elsif($_[0] eq "sha384") { return sha384_hex($_[1]); } elsif($_[0] eq "sha512") { return sha512_hex($_[1]); } }

In reply to Re: Double loop? by Dietz
in thread Double loop? by RayQ

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.