File: genrules.pl

package info (click to toggle)
cracklib2 2.7-8
  • links: PTS
  • area: main
  • in suites: potato
  • size: 424 kB
  • ctags: 113
  • sloc: ansic: 1,914; sh: 1,084; makefile: 166; perl: 63
file content (68 lines) | stat: -rwxr-xr-x 1,372 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/local/bin/perl

###
# This program is copyright Alec Muffett 1997. The author disclaims all
# responsibility or liability with respect to it's usage or its effect
# upon hardware or computer systems, and maintains copyright as set out
# in the "LICENCE" document which accompanies distributions of Crack v5.0
# and upwards.
###

%perms = ();

sub Permute
{
    my $depth = shift;
    my $i;

    if ($depth == 0)
    {
	@stack = ();
    }
    for ($i = 0; $i <= $#set; $i++)
    {
	$stack[$depth] = $set[$i];

	if ($depth == $#set)
	{
	    %output = ();
	    foreach (@stack) 
	    { 
		$output{$_}++; 
	    }
	    $perm = join(" ", sort(keys(%output)));
	    $perms{$perm}++;
	}
	else
	{
	    &Permute($depth + 1);
	}
    }
}

@maps = ([ '/$s$s', '/0s0o', '/2s2a', '/3s3e', '/5s5s', '/1s1i', '/4s4a' ],
	 [ '/$s$s', '/0s0o', '/2s2a', '/3s3e', '/5s5s', '/1s1i', '/4s4h' ],
	 [ '/$s$s', '/0s0o', '/2s2a', '/3s3e', '/5s5s', '/1s1l', '/4s4a' ],
	 [ '/$s$s', '/0s0o', '/2s2a', '/3s3e', '/5s5s', '/1s1l', '/4s4h' ]);

@set = (0 .. 5);

# why be elegant when you can use brute force?  moreover, it's easier
# to think brute-force at 1am in the morning, and leaves you with time
# for coffee...

&Permute(0);

foreach $perm (sort(keys(%perms)))
{
    foreach $aref (@maps)
    {
	foreach $i (split(" ", $perm))
	{
	    print ${$aref}[$i];
	}
	print "\n";
    }
}

exit 0;