iterating over arrays with map - problem

From: Mothra (mothra_at_mothra.com)
Date: 05/19/04


Date: Wed, 19 May 2004 11:46:08 GMT

Trying (just for fun) to write my own Perl version of 'Crack' but am
stumbling a bit trying to iterate over my dictionary file to generate
possible passwords. When I run the code below with "dictionary.txt"
containing the single word "password", I get around 4,000 entries, most
of which are identical, even though on most occassions there is no
subsitution to be made.

I tried using next in the map block, but it won't let me. What I would
like it to generate (for each word in the dictionary file) all possible
letter/number substitution combinations, that is, not to simply
accumulate changes, but nor to needlessly repeat them either.

The best I can get is either:
password
p4ssword
p455word
p455w0rd

which is useless; the only other result I get is thousands of redundant
entries.

What is the more efficient way I should be writing this (see below)?

---------------------------------
sub init_dictionary {
         open(DICT,"dictionary.txt");
         chomp(@dict=<DICT>);
         close DICT;

         push @dict, map { s/[aA]/4/g;$_ } @dict;
         push @dict, map { s/[bB]/8/g;$_ } @dict;
         push @dict, map { s/[eE]/3/g;$_ } @dict;
         push @dict, map { s/[gG]/6/g;$_ } @dict;
         push @dict, map { s/[iI]/1/g;$_ } @dict;
         push @dict, map { s/[lL]/1/g;$_ } @dict;
         push @dict, map { s/[oO]/0/g;$_ } @dict;
         push @dict, map { s/[sS]/5/g;$_ } @dict;
         push @dict, map { s/[tT]/7/g;$_ } @dict;
         push @dict, map { s/[zZ]/2/g;$_ } @dict;

}



Relevant Pages

  • iterating over arrays with map - problem
    ... stumbling a bit trying to iterate over my dictionary file to generate ... containing the single word "password", I get around 4,000 entries, most ... like it to generate (for each word in the dictionary file) all possible ...
    (comp.lang.perl.misc)
  • Re: Listbox / Database Question
    ... I am writing a dictionary program with a ... > Dictionary file has over 60000 entries. ... > End if he types GAD listbox will show ...
    (microsoft.public.vb.general.discussion)
  • Re: Dictionary / Listbox
    ... I am writing a dictionary program with a ... > Dictionary file has over 60000 entries. ... > End if he types GAD listbox will show ...
    (microsoft.public.dotnet.languages.vb)
  • Listbox / Database
    ... I am writing a dictionary program with a Dictionary file has over ... End if he types GAD listbox will show ... I also provide user ability to use arrows so that he can move in the listbox up and down and go through ... [Another good example is Microsoft Encarta where encyclopedia entries in a listbox change ...
    (microsoft.public.dotnet.languages.vb)
  • Re: iterating over arrays with map - problem
    ... >>stumbling a bit trying to iterate over my dictionary file to generate ...
    (comp.lang.perl.misc)