viGuy,
I don't see this as un-ethical, but if the purpose is to provide a brute force crack against passwords - it is probably pretty silly. For instance - take a look at this thread for some numbers. If this is your goal, you would be much better off using a C compiled based program design for that effort. Even that is not un-ethical if the purpose is to ensure the integrity of the passwords of a given system you are responsible for the security of and you have ensured that it is legal. Since you didn't ask for that, I won't point you in the right direction.
Do you have something else in mind?
Cheers - L~R
Update: I was looking for an iterative solution an tye recommended Algorithm::Loops. Even though he hasn't uploaded it yet, the source is available here. My original sentiment stands, but this is how I would do it if I could think of a legitimate reason to do it.
#!/usr/bin/perl -w
use strict;
my @chars = ('a' .. 'z', 'A' .. 'Z', 0 .. 9);
my $length = 8;
my $get_combo = nestedLoops([ ([@chars]) x $length ]);
my @list;
while( @list= $get_combo->() ) {
print "@list\n";
}
# tye's nestedLoops code for future Algorithm::Loops
sub nestedLoops {
my( $loops, $params )= @_;
my $code= $params && $params->{Code};
my @list;
my $when= $params && $params->{OnlyWhen}
|| sub { @_ == @$loops };
my $i= -1;
my @idx;
my @vals= @$loops;
my $iter= sub {
while( 1 ) {
# Prepare to append one more value:
if( $i < $#$loops ) {
$idx[++$i]= -1;
$vals[$i]= $loops->[$i]->(@list)
if 'CODE' eq ref $loops->[$i];
}
# Increment furthest value, chopping if done there:
while( @{$vals[$i]} <= ++$idx[$i] ) {
# Return if all done:
return if --$i < 0;
pop @list;
}
$list[$i]= $vals[$i][$idx[$i]];
if( ! ref $when || $when->( @list ) ) {
return @list;
}
}
};
return $iter if ! $code;
while( $iter->() ) {
$code->( @list );
}
}
On my Mom's mediocre computer, this would take 555 years to complete - give or take a few months :-)
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|