|
Vulnerability Development
mailing list archives
Re: dictionary
From: ejb3 () cornell edu
Date: Wed, 18 Sep 2002 14:17:00 -0400 (EDT)
If your set of chars is contiguous, as this one is, then this can be
simplified.
---------
#!/usr/local/bin/perl -w
my $len = shift;
my $start = 'a' x $len;
my $end = 'z' x $len;
print join "\n", ($start .. $end);
--------
For non-contiguous char sets, it's simpler to have the script write out a
set of nested foreach loops (nested as deep as the length you specify),
and eval() that.
ericb
On Wed, 18 Sep 2002, Mark Ellzey wrote:
I have written a quick perl program that will generate all possible
'words' for X number of chars, where X = a number supplied at the
arg, this is good for making dictionary lists of great size.
For other char sets just add to the @chars array.
#!/usr/bin/perl -w
# Word generator
# Mark Ellzey (mark () rdi st) - 9/18/02
use strict;
my $how_many_words = $ARGV[0];
my @chars = qw/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 %hash;
my $num_of_chars = @chars;
foreach my $char (@chars) {
for(my $i = 1; $i <= $how_many_words; $i++) {
push @{$hash{$char}}, $char;
}
}
foreach my $entry (keys %hash) {
my $word;
foreach my $thing(@{$hash{$entry}}) {
$word .= $thing;
}
print "$word\n";
for(my $i = 1; $i <= $how_many_words-1;$i++) {
change_array($i,$entry,$hash{$entry});
}
}
sub change_array {
my $offset = shift;
my $letter = shift;
my $array = shift;
my @arrayz = @$array;
foreach my $char (@chars) {
next if $char eq $letter;
#print "$letter - $char $offset\n";
$arrayz[$offset] = $char;
my $word;
foreach my $thing (@arrayz) {
$word .= $thing;
}
print "$word\n";
if($offset+1 != $how_many_words) {
change_array($offset+1,$char,\ () arrayz);
}
}
}
By Date
By Thread
Current thread:
|