Hello fellow monks, it's sure been a while.

I'm preparing for a Security+ Comptia exam on the 15th of this month and after going through the resources, brute force password breaking is a fairly big issue. I've never been too interested in playing with it myself but I figured it'd be a good learning experience to see the difference in breaking a 3 character password vs a 5+ character password.

Below is my first attempt. It works fairly well on passwords 1-3 characters long. A 3 character password took about 20 minutes (sometimes as much as 40). And to my shocker I was able to snatch a 4 character password in just over 12 hours (it took 12,000,000 password tries to solve it).

Not happpy yet, I decided to try with a 5 character password. After about 16 hours it locked up saying "OUT OF MEMORY".

Anyway, I have a few questions and please keep in mind it's not perfect (it doesn't read a dictionary as I want this to be a totally random brute force and it doesn't have every character a password can have).

1) I have a hash set up that stores every attempted password which seemed good for short 1-3 character passwords. I know this is why the password solver ran out of memory but would the script work the same without it? My initial assumption is it could ultimately take infinite tries to crack the password unless it's told to find new ones. What are your thoughts on this?

2) I never got into multithreading or anything of that nature but would this be a prime example of something that could be improved by using it?

3) Share your experiences in doing this with Perl. How fast has yours solved your passwords for you? Anything you can share will help me find a base line to improve this script and give me more experience/knowledge for my Security+ exam.

Below is my script in its entirety.

#!/usr/bin/perl use warnings; use strict; my $length = 5; my $password = "passw"; my @chars = ('a' .. 'z', 'A' .. 'Z', 0-9, '!', '@', '#', '$', '%', '^' +, '&', '*', ' '); my %tried; my $tries = 0; my $starttime = time(); while(1) { my @temp_chars; for (1 .. $length) { my @character = shuffle(@chars); my $char = $character[0]; push(@temp_chars, $char); } my $guess = join("", @temp_chars); if (exists $tried{$guess}) { print "\tSkipping $guess - already attempted\n\n"; } $tries++; $tried{$guess} = "1"; if ($guess eq $password) { my $endtime = time(); my $time_took = $endtime - $starttime; print "We found your password. It is $guess!\n"; print "It took $time_took seconds and $tries tries"; exit; } else { print "Guessing: $guess\t\tTry # $tries\n\n"; } } sub shuffle { return @_ if !@_ || ref $_ [0] eq 'ARRAY' && !@{$_ [0]}; my $array = @_ == 1 && ref $_ [0] eq 'ARRAY' ? shift : [@_]; for (my $i = @$array; -- $i;) { my $r = int rand ($i + 1); ($array -> [$i], $array -> [$r]) = ($array -> [$r], $array -> [ +$i]); } wantarray ? @$array : $array; }


"Age is nothing more than an inaccurate number bestowed upon us at birth as just another means for others to judge and classify us"

sulfericacid

In reply to Improve password solver by sulfericacid

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.