Since I wanted to have some rainbowtables for some experiments on my local machines and being too lazy to care for the ones on freerainbowtables.org, I created a small (potentially ugly) script in my favourite scripting language to accomodate my wish for a rainbowtable.

#!/usr/bin/perl + + + our $VERSION = ''; use 5.010_000; use strict; use warnings; my @letters = ("0","1","2","3","4","5","6","7","8","9","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"); my ($word,$i,$i1,$i2,$i3,$i4,$i5,$i6,$i7); open(FILE,'>',"list"); for ( $i = 0;$i<36; $i++ ) { for ( $i1 = 0;$i1<36; $i1++ ) { for ( $i2 = 0;$i2<36; $i2++ ) { for ( $i3 = 0;$i3<36; $i3++ ) { for ( $i4 = 0;$i4<36; $i4++ ) { for ( $i5 = 0;$i5<36; $i5++ ) { for ( $i6 = 0;$i6<36; $i6++ ) { for ( $i7 = 0;$i7<36; $i7++ ) { print FILE $letters[$i].$letters[$i1].$letters[$i2].$l +etters[$i3].$letters[$i4].$letters[$i5].$letters[$i6].$letters[$i7]." +\n"; } } } } } } } } close(FILE);

Replies are listed 'Best First'.
Re: Simple way to create a rainbow table
by BrowserUk (Patriarch) on Sep 18, 2011 at 16:41 UTC

    I think you may have missed the point of what rainbow tables are. What you are producing isn't they.

    And what you are producing will be 36**8 = 2,821,109,907,456 lines, occupying ~27 terabytes, and taking ~1 month to run assuming you have that amount of free disk.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
Re: Simple way to create a rainbow table
by AnomalousMonk (Archbishop) on Sep 18, 2011 at 17:40 UTC

    While not, as BrowserUk points out, a 'rainbow table', what you have is certainly a permutation and is also a good first approximation to an infinite stream. Dominus's Higher Order Perl is a very good discussion of iterator-based approaches to these topics (for which, see the index) and quite a few others, and is available as a free download here.

Re: Simple way to create a rainbow table
by jwkrahn (Abbot) on Sep 18, 2011 at 23:24 UTC
    my @letters = ("0","1","2","3","4","5","6","7","8","9","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"); my ($word,$i,$i1,$i2,$i3,$i4,$i5,$i6,$i7); open(FILE,'>',"list"); for ( $i = 0;$i<36; $i++ ) { for ( $i1 = 0;$i1<36; $i1++ ) { for ( $i2 = 0;$i2<36; $i2++ ) { for ( $i3 = 0;$i3<36; $i3++ ) { for ( $i4 = 0;$i4<36; $i4++ ) { for ( $i5 = 0;$i5<36; $i5++ ) { for ( $i6 = 0;$i6<36; $i6++ ) { for ( $i7 = 0;$i7<36; $i7++ ) { print FILE $letters[$i].$letters[$i1].$letters[$i2].$l +etters[$i3].$letters[$i4].$letters[$i5].$letters[$i6].$letters[$i7]." +\n"; } } } } } } } } close(FILE);

    More readable as:

    my @letters = ( 0 .. 9, 'a' .. 'z' ); open FILE, '>', 'list' or die "Cannot open 'list' because: $!"; for my $i0 ( @letters ) { for my $i1 ( @letters ) { for my $i2 ( @letters ) { for my $i3 ( @letters ) { for my $i4 ( @letters ) { for my $i5 ( @letters ) { for my $i6 ( @letters ) { for my $i7 ( @letters ) { print FILE "$i0$i1$i2$i3$i4$i5$i6$i7\n"; } } } } } } } } close FILE;

      Or avoiding code duplication:

      use strict; use warnings; use 5.010; use Algorithm::Loops qw/NestedLoops/; my @letters = ( 0 .. 9, 'a' .. 'z' ); NestedLoops( [ (\@letters) x 8 ], sub { say @_ } );
Re: Simple way to create a rainbow table
by toolic (Bishop) on Sep 18, 2011 at 23:21 UTC