| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861 |
- #!/usr/bin/perl
- ##
- ## Author......: Jens Steube <jens.steube@gmail.com>
- ## License.....: MIT
- ##
- use strict;
- use warnings;
- use Digest::MD5 qw (md5_hex);
- use Digest::SHA1 qw (sha1_hex);
- use MIME::Base64;
- my $tmp_hash = "hash";
- my $tmp_word = "word";
- my $tmp_out = "out";
- #my $hashcat = "./hashcat-cli.bin";
- my $hashcat = "hashcat-cli.exe";
- my $runs_per_test = 1;
- my $num_words_min = 100;
- my $num_words_max = 104;
- my $word_len_min = 1;
- my $word_len_max = 55;
- my $word_chr_min = 0x20;
- my $word_chr_max = 0x7e;
- my $salt_len_min = 1;
- my $salt_len_max = 54;
- test14 ();
- exit;
- sub simple_generate
- {
- for (1..$runs_per_test)
- {
- my $num_words = get_random_num ($num_words_min, $num_words_max);
- my %dupe;
- my $left = 10;
- while ($left)
- {
- ##
- ## word
- ##
- my $word_len = get_random_num ($word_len_min, 16);
- my @word_arr;
- for (my $i = 0; $i < $word_len; $i++)
- {
- push (@word_arr, get_random_chr (0x61, 0x7a));
- }
- my $word_buf = join ("", @word_arr);
- ##
- ## dupe
- ##
- next if exists $dupe{$word_buf};
- $dupe{$word_buf} = undef;
- ##
- ## store
- ##
- print $word_buf, "\n";
- $left--;
- }
- }
- }
- sub test24
- {
- my $test_num = 24;
- my $tmp_word = "examples/A0.M300.word";
- my $tmp_hash = "examples/A0.M300.hash";
- for (1..$runs_per_test)
- {
- my $num_words = get_random_num ($num_words_min, $num_words_max);
- open (OUTP, ">", $tmp_word) or die ("$tmp_word: $!\n");
- open (OUTH, ">", $tmp_hash) or die ("$tmp_hash: $!\n");
- my %dupe;
- my $left = $num_words;
- while ($left)
- {
- ##
- ## word
- ##
- my $word_len = get_random_num ($word_len_min, $word_len_max);
- my @word_arr;
- for (my $i = 0; $i < $word_len; $i++)
- {
- push (@word_arr, get_random_chr ($word_chr_min, $word_chr_max));
- }
- my $word_buf = join ("", @word_arr);
- ##
- ## dupe
- ##
- next if exists $dupe{$word_buf};
- $dupe{$word_buf} = undef;
- ##
- ## store
- ##
- print OUTP $word_buf, "\n";
- my $ctx = Digest::SHA1->new;
- $ctx->add ($word_buf);
- my $hash_buf = sha1_hex ($ctx->digest);
- print OUTH $hash_buf, "\n";
- $left--;
- }
- close (OUTH);
- close (OUTP);
- unlink ($tmp_out);
- }
- }
- sub test23
- {
- my $test_num = 23;
- my $tmp_word = "examples/A0.M700.word";
- my $tmp_hash = "examples/A0.M700.hash";
- for (1..$runs_per_test)
- {
- my $num_words = get_random_num ($num_words_min, $num_words_max);
- open (OUTP, ">", $tmp_word) or die ("$tmp_word: $!\n");
- open (OUTH, ">", $tmp_hash) or die ("$tmp_hash: $!\n");
- my %dupe;
- my $left = $num_words;
- while ($left)
- {
- ##
- ## salt
- ##
- my $salt_len = 8;
- my @salt_arr;
- for (my $i = 0; $i < $salt_len; $i++)
- {
- push (@salt_arr, get_random_chr ($word_chr_min, $word_chr_max));
- }
- my $salt_buf = join ("", @salt_arr);
- ##
- ## word
- ##
- my $word_len = get_random_num ($word_len_min, $word_len_max - 8);
- my @word_arr;
- for (my $i = 0; $i < $word_len; $i++)
- {
- push (@word_arr, get_random_chr ($word_chr_min, $word_chr_max));
- }
- my $word_buf = join ("", @word_arr);
- ##
- ## dupe
- ##
- next if exists $dupe{$word_buf};
- $dupe{$word_buf} = undef;
- ##
- ## store
- ##
- print OUTP $word_buf, "\n";
- my $ctx = Digest::SHA1->new;
- $ctx->add ($word_buf);
- $ctx->add ($salt_buf);
- my $hash_buf = "{SSHA}" . encode_base64 ($ctx->digest . $salt_buf);
- print OUTH $hash_buf;
- $left--;
- }
- close (OUTH);
- close (OUTP);
- unlink ($tmp_out);
- }
- }
- sub test22
- {
- my $test_num = 22;
- my $tmp_word = "examples/A0.M600.word";
- my $tmp_hash = "examples/A0.M600.hash";
- for (1..$runs_per_test)
- {
- my $num_words = get_random_num ($num_words_min, $num_words_max);
- open (OUTP, ">", $tmp_word) or die ("$tmp_word: $!\n");
- open (OUTH, ">", $tmp_hash) or die ("$tmp_hash: $!\n");
- my %dupe;
- my $left = $num_words;
- while ($left)
- {
- ##
- ## word
- ##
- my $word_len = get_random_num ($word_len_min, $word_len_max);
- my @word_arr;
- for (my $i = 0; $i < $word_len; $i++)
- {
- push (@word_arr, get_random_chr ($word_chr_min, $word_chr_max));
- }
- my $word_buf = join ("", @word_arr);
- ##
- ## dupe
- ##
- next if exists $dupe{$word_buf};
- $dupe{$word_buf} = undef;
- ##
- ## store
- ##
- print OUTP $word_buf, "\n";
- my $ctx = Digest::SHA1->new;
- $ctx->add ($word_buf);
- my $hash_buf = "{SHA}" . encode_base64 ($ctx->digest);
- print OUTH $hash_buf;
- $left--;
- }
- close (OUTH);
- close (OUTP);
- unlink ($tmp_out);
- }
- }
- sub test21
- {
- my $test_num = 21;
- my $tmp_word = "examples/A0.M5.VBULLSALT.word";
- my $tmp_hash = "examples/A0.M5.VBULLSALT.hash";
- for (1..$runs_per_test)
- {
- my $num_words = get_random_num ($num_words_min, $num_words_max);
- open (OUTP, ">", $tmp_word) or die ("$tmp_word: $!\n");
- open (OUTH, ">", $tmp_hash) or die ("$tmp_hash: $!\n");
- my %dupe;
- my $left = $num_words;
- while ($left)
- {
- ##
- ## salt
- ##
- my $salt_len = get_random_num (3, 3);
- my @salt_arr;
- for (my $i = 0; $i < $salt_len; $i++)
- {
- push (@salt_arr, get_random_chr (0x20, 0x7e));
- }
- my $salt_buf = join ("", @salt_arr);
- ##
- ## word
- ##
- my $word_len = get_random_num ($word_len_min, 30);
- my @word_arr;
- for (my $i = 0; $i < $word_len; $i++)
- {
- push (@word_arr, get_random_chr ($word_chr_min, $word_chr_max));
- }
- my $word_buf = join ("", @word_arr);
- ##
- ## dupe
- ##
- next if exists $dupe{$word_buf};
- $dupe{$word_buf} = undef;
- ##
- ## store
- ##
- print OUTP $word_buf, "\n";
- my $hash_buf = md5_hex (md5_hex ($word_buf) . $salt_buf);
- print OUTH $hash_buf, "\n";
- $left--;
- }
- close (OUTH);
- close (OUTP);
- unlink ($tmp_out);
- }
- }
- sub test20
- {
- my $test_num = 20;
- my $tmp_word = "examples/A0.M104.word";
- my $tmp_hash = "examples/A0.M104.hash";
- for (1..$runs_per_test)
- {
- my $num_words = get_random_num ($num_words_min, $num_words_max);
- open (OUTP, ">", $tmp_word) or die ("$tmp_word: $!\n");
- open (OUTH, ">", $tmp_hash) or die ("$tmp_hash: $!\n");
- my %dupe;
- my $left = $num_words;
- while ($left)
- {
- ##
- ## word
- ##
- my $word_len = get_random_num ($word_len_min, $word_len_max);
- my @word_arr;
- for (my $i = 0; $i < $word_len; $i++)
- {
- push (@word_arr, get_random_chr ($word_chr_min, $word_chr_max));
- }
- my $word_buf = join ("", @word_arr);
- ##
- ## dupe
- ##
- next if exists $dupe{$word_buf};
- $dupe{$word_buf} = undef;
- ##
- ## store
- ##
- print OUTP $word_buf, "\n";
- my $hash_buf = sha1_hex (sha1_hex (sha1_hex ($word_buf)));
- print OUTH $hash_buf, "\n";
- $left--;
- }
- close (OUTH);
- close (OUTP);
- }
- }
- sub test19
- {
- my $test_num = 19;
- my $tmp_word = "examples/A0.M103.word";
- my $tmp_hash = "examples/A0.M103.hash";
- for (1..$runs_per_test)
- {
- my $num_words = get_random_num ($num_words_min, $num_words_max);
- open (OUTP, ">", $tmp_word) or die ("$tmp_word: $!\n");
- open (OUTH, ">", $tmp_hash) or die ("$tmp_hash: $!\n");
- my %dupe;
- my $left = $num_words;
- while ($left)
- {
- ##
- ## word
- ##
- my $word_len = get_random_num ($word_len_min, $word_len_max);
- my @word_arr;
- for (my $i = 0; $i < $word_len; $i++)
- {
- push (@word_arr, get_random_chr ($word_chr_min, $word_chr_max));
- }
- my $word_buf = join ("", @word_arr);
- ##
- ## dupe
- ##
- next if exists $dupe{$word_buf};
- $dupe{$word_buf} = undef;
- ##
- ## store
- ##
- print OUTP $word_buf, "\n";
- my $hash_buf = sha1_hex (sha1_hex ($word_buf));
- print OUTH $hash_buf, "\n";
- $left--;
- }
- close (OUTH);
- close (OUTP);
- }
- }
- sub test18
- {
- my $test_num = 18;
- my $tmp_word = "examples/A3.M0.word";
- my $tmp_hash = "examples/A3.M0.hash";
- for (1..$runs_per_test)
- {
- my $num_words = get_random_num ($num_words_min, $num_words_max);
- open (OUTP, ">", $tmp_word) or die ("$tmp_word: $!\n");
- open (OUTH, ">", $tmp_hash) or die ("$tmp_hash: $!\n");
- my %dupe;
- my $left = $num_words;
- while ($left)
- {
- ##
- ## word
- ##
- my $word_len = 5;
- my @word_arr;
- for (my $i = 0; $i < $word_len; $i++)
- {
- push (@word_arr, get_random_chr (0x61, 0x7a));
- }
- my $word_buf = join ("", @word_arr);
- ##
- ## dupe
- ##
- next if exists $dupe{$word_buf};
- $dupe{$word_buf} = undef;
- ##
- ## store
- ##
- print OUTP $word_buf, "\n";
- my $hash_buf = md5_hex ($word_buf);
- print OUTH $hash_buf, "\n";
- $left--;
- }
- close (OUTH);
- close (OUTP);
- }
- }
- sub test16
- {
- my $test_num = 16;
- my $tmp_word = "examples/A0.M11.word";
- my $tmp_hash = "examples/A0.M11.hash";
- for (1..$runs_per_test)
- {
- my $num_words = get_random_num ($num_words_min, $num_words_max);
- open (OUTP, ">", $tmp_word) or die ("$tmp_word: $!\n");
- open (OUTH, ">", $tmp_hash) or die ("$tmp_hash: $!\n");
- my %dupe;
- my $left = $num_words;
- while ($left)
- {
- ##
- ## salt
- ##
- my $salt_len = get_random_num (1, 10);
- my @salt_arr;
- for (my $i = 0; $i < $salt_len; $i++)
- {
- push (@salt_arr, get_random_chr ($word_chr_min, $word_chr_max));
- }
- my $salt_buf = join ("", @salt_arr);
- ##
- ## word
- ##
- my $word_len = 10;
- my @word_arr;
- for (my $i = 0; $i < $word_len; $i++)
- {
- push (@word_arr, get_random_chr ($word_chr_min, $word_chr_max));
- }
- my $word_buf = join ("", @word_arr);
- ##
- ## dupe
- ##
- next if exists $dupe{$word_buf};
- $dupe{$word_buf} = undef;
- ##
- ## store
- ##
- print OUTP $word_buf, "\n";
- my $hash_buf = md5_hex ($salt_buf . md5_hex ($salt_buf . $word_buf));
- print OUTH $hash_buf, ":", $salt_buf, "\n";
- $left--;
- }
- close (OUTH);
- close (OUTP);
- }
- }
- sub test17
- {
- my $test_num = 17;
- my $tmp_word = "examples/A0.M12.word";
- my $tmp_hash = "examples/A0.M12.hash";
- for (1..$runs_per_test)
- {
- my $num_words = get_random_num ($num_words_min, $num_words_max);
- open (OUTP, ">", $tmp_word) or die ("$tmp_word: $!\n");
- open (OUTH, ">", $tmp_hash) or die ("$tmp_hash: $!\n");
- my %dupe;
- my $left = $num_words;
- while ($left)
- {
- ##
- ## salt
- ##
- my $salt_len = 10;
- my @salt_arr;
- for (my $i = 0; $i < $salt_len; $i++)
- {
- push (@salt_arr, get_random_chr ($word_chr_min, $word_chr_max));
- }
- my $salt_buf = join ("", @salt_arr);
- ##
- ## word
- ##
- my $word_len = 10;
- my @word_arr;
- for (my $i = 0; $i < $word_len; $i++)
- {
- push (@word_arr, get_random_chr ($word_chr_min, $word_chr_max));
- }
- my $word_buf = join ("", @word_arr);
- ##
- ## dupe
- ##
- next if exists $dupe{$word_buf};
- $dupe{$word_buf} = undef;
- ##
- ## store
- ##
- print OUTP $word_buf, "\n";
- my $hash_buf = md5_hex ($salt_buf . md5_hex ($word_buf . $salt_buf));
- print OUTH $hash_buf, ":", $salt_buf, "\n";
- $left--;
- }
- close (OUTH);
- close (OUTP);
- }
- }
- sub test13
- {
- my $test_num = 13;
- my $tmp_word = "examples/A0.M100.word";
- my $tmp_hash = "examples/A0.M100.hash";
- for (1..$runs_per_test)
- {
- my $num_words = get_random_num ($num_words_min, $num_words_max);
- open (OUTP, ">", $tmp_word) or die ("$tmp_word: $!\n");
- open (OUTH, ">", $tmp_hash) or die ("$tmp_hash: $!\n");
- my %dupe;
- my $left = $num_words;
- while ($left)
- {
- my $word_len = get_random_num ($word_len_min, $word_len_max);
- my @word_arr;
- for (my $i = 0; $i < $word_len; $i++)
- {
- push (@word_arr, get_random_chr ($word_chr_min, $word_chr_max));
- }
- my $word_buf = join ("", @word_arr);
- next if exists $dupe{$word_buf};
- $dupe{$word_buf} = undef;
- print OUTP $word_buf, "\n";
- my $hash_buf = sha1_hex ($word_buf);
- print OUTH $hash_buf, "\n";
- $left--;
- }
- close (OUTH);
- close (OUTP);
- }
- }
- sub test14
- {
- my $test_num = 14;
- my $tmp_word = "examples/A0.M101.word";
- my $tmp_hash = "examples/A0.M101.hash";
- for (1..$runs_per_test)
- {
- my $num_words = get_random_num ($num_words_min, $num_words_max);
- open (OUTP, ">", $tmp_word) or die ("$tmp_word: $!\n");
- open (OUTH, ">", $tmp_hash) or die ("$tmp_hash: $!\n");
- my %dupe;
- my $left = $num_words;
- while ($left)
- {
- ##
- ## salt
- ##
- my $salt_len = get_random_num ($salt_len_min, $salt_len_max);
- my @salt_arr;
- for (my $i = 0; $i < $salt_len; $i++)
- {
- push (@salt_arr, get_random_chr ($word_chr_min, $word_chr_max));
- }
- my $salt_buf = join ("", @salt_arr);
- ##
- ## word
- ##
- my $word_len = get_random_num ($word_len_min, $word_len_max - $salt_len);
- my @word_arr;
- for (my $i = 0; $i < $word_len; $i++)
- {
- push (@word_arr, get_random_chr ($word_chr_min, $word_chr_max));
- }
- my $word_buf = join ("", @word_arr);
- ##
- ## dupe
- ##
- next if exists $dupe{$word_buf};
- $dupe{$word_buf} = undef;
- ##
- ## store
- ##
- print OUTP $word_buf, "\n";
- my $hash_buf = sha1_hex ($word_buf . $salt_buf);
- print OUTH $hash_buf, ":", $salt_buf, "\n";
- $left--;
- }
- close (OUTH);
- close (OUTP);
- }
- }
- sub test15
- {
- my $test_num = 15;
- my $tmp_word = "examples/A0.M102.word";
- my $tmp_hash = "examples/A0.M102.hash";
- for (1..$runs_per_test)
- {
- my $num_words = get_random_num ($num_words_min, $num_words_max);
- open (OUTP, ">", $tmp_word) or die ("$tmp_word: $!\n");
- open (OUTH, ">", $tmp_hash) or die ("$tmp_hash: $!\n");
- my %dupe;
- my $left = $num_words;
- while ($left)
- {
- ##
- ## salt
- ##
- my $salt_len = get_random_num ($salt_len_min, $salt_len_max);
- my @salt_arr;
- for (my $i = 0; $i < $salt_len; $i++)
- {
- push (@salt_arr, get_random_chr ($word_chr_min, $word_chr_max));
- }
- my $salt_buf = join ("", @salt_arr);
- ##
- ## word
- ##
- my $word_len = get_random_num ($word_len_min, $word_len_max - $salt_len);
- my @word_arr;
- for (my $i = 0; $i < $word_len; $i++)
- {
- push (@word_arr, get_random_chr ($word_chr_min, $word_chr_max));
- }
- my $word_buf = join ("", @word_arr);
- ##
- ## dupe
- ##
- next if exists $dupe{$word_buf};
- $dupe{$word_buf} = undef;
- ##
- ## store
- ##
- print OUTP $word_buf, "\n";
- my $hash_buf = sha1_hex ($salt_buf . $word_buf);
- print OUTH $hash_buf, ":", $salt_buf, "\n";
- $left--;
- }
- close (OUTH);
- close (OUTP);
- }
- }
- ##
- ## test1 : random number of passwords, random word length, random chars, 10 times
- ## : simple out -a 0 -m 0.
- ##
- sub test1
- {
- my $test_num = 1;
- my $tmp_word = "examples/A0.M0.word";
- my $tmp_hash = "examples/A0.M0.hash";
- for (1..$runs_per_test)
- {
- my $num_words = get_random_num ($num_words_min, $num_words_max);
- open (OUTP, ">", $tmp_word) or die ("$tmp_word: $!\n");
- open (OUTH, ">", $tmp_hash) or die ("$tmp_hash: $!\n");
- my %dupe;
- my $left = $num_words;
- while ($left)
- {
- my $word_len = get_random_num ($word_len_min, $word_len_max);
- my @word_arr;
- for (my $i = 0; $i < $word_len; $i++)
- {
- push (@word_arr, get_random_chr ($word_chr_min, $word_chr_max));
- }
- my $word_buf = join ("", @word_arr);
- next if exists $dupe{$word_buf};
- $dupe{$word_buf} = undef;
- print OUTP $word_buf, "\n";
- my $hash_buf = md5_hex ($word_buf);
- print OUTH $hash_buf, "\n";
- $left--;
- }
- close (OUTH);
- close (OUTP);
- }
- }
- ##
- ## test2 : random number of passwords, random word length, random chars, 10 times
- ## : simple out -a 0 -m 1.
- ##
- sub test2
- {
- my $test_num = 2;
- my $tmp_word = "examples/A0.M1.word";
- my $tmp_hash = "examples/A0.M1.hash";
- for (1..$runs_per_test)
- {
- my $num_words = get_random_num ($num_words_min, $num_words_max);
- open (OUTP, ">", $tmp_word) or die ("$tmp_word: $!\n");
- open (OUTH, ">", $tmp_hash) or die ("$tmp_hash: $!\n");
- my %dupe;
- my $left = $num_words;
- while ($left)
- {
- ##
- ## salt
- ##
- my $salt_len = get_random_num ($salt_len_min, $salt_len_max);
- my @salt_arr;
- for (my $i = 0; $i < $salt_len; $i++)
- {
- push (@salt_arr, get_random_chr ($word_chr_min, $word_chr_max));
- }
- my $salt_buf = join ("", @salt_arr);
- ##
- ## word
- ##
- my $word_len = get_random_num ($word_len_min, $word_len_max - $salt_len);
- my @word_arr;
- for (my $i = 0; $i < $word_len; $i++)
- {
- push (@word_arr, get_random_chr ($word_chr_min, $word_chr_max));
- }
- my $word_buf = join ("", @word_arr);
- ##
- ## dupe
- ##
- next if exists $dupe{$word_buf};
- $dupe{$word_buf} = undef;
- ##
- ## store
- ##
- print OUTP $word_buf, "\n";
- my $hash_buf = md5_hex ($word_buf . $salt_buf);
- print OUTH $hash_buf, ":", $salt_buf, "\n";
- $left--;
- }
- close (OUTH);
- close (OUTP);
- }
- }
- ##
- ## test3 : random number of passwords, random word length, random chars, 10 times
- ## : simple out -a 0 -m 2.
- ##
- sub test3
- {
- my $test_num = 3;
- my $tmp_word = "examples/A0.M2.word";
- my $tmp_hash = "examples/A0.M2.hash";
- for (1..$runs_per_test)
- {
- my $num_words = get_random_num ($num_words_min, $num_words_max);
- open (OUTP, ">", $tmp_word) or die ("$tmp_word: $!\n");
- open (OUTH, ">", $tmp_hash) or die ("$tmp_hash: $!\n");
- my %dupe;
- my $left = $num_words;
- while ($left)
- {
- ##
- ## salt
- ##
- my $salt_len = get_random_num ($salt_len_min, $salt_len_max);
- my @salt_arr;
- for (my $i = 0; $i < $salt_len; $i++)
- {
- push (@salt_arr, get_random_chr ($word_chr_min, $word_chr_max));
- }
- my $salt_buf = join ("", @salt_arr);
- ##
- ## word
- ##
- my $word_len = get_random_num ($word_len_min, $word_len_max - $salt_len);
- my @word_arr;
- for (my $i = 0; $i < $word_len; $i++)
- {
- push (@word_arr, get_random_chr ($word_chr_min, $word_chr_max));
- }
- my $word_buf = join ("", @word_arr);
- ##
- ## dupe
- ##
- next if exists $dupe{$word_buf};
- $dupe{$word_buf} = undef;
- ##
- ## store
- ##
- print OUTP $word_buf, "\n";
- my $hash_buf = md5_hex ($salt_buf . $word_buf);
- print OUTH $hash_buf, ":", $salt_buf, "\n";
- $left--;
- }
- close (OUTH);
- close (OUTP);
- unlink ($tmp_out);
- }
- }
- ##
- ## test4 : random number of passwords, random word length, random chars, 10 times
- ## : simple out -a 0 -m 3.
- ##
- sub test4
- {
- my $test_num = 4;
- my $tmp_word = "examples/A0.M3.word";
- my $tmp_hash = "examples/A0.M3.hash";
- for (1..$runs_per_test)
- {
- my $num_words = get_random_num ($num_words_min, $num_words_max);
- open (OUTP, ">", $tmp_word) or die ("$tmp_word: $!\n");
- open (OUTH, ">", $tmp_hash) or die ("$tmp_hash: $!\n");
- my %dupe;
- my $left = $num_words;
- while ($left)
- {
- ##
- ## word
- ##
- my $word_len = get_random_num ($word_len_min, $word_len_max);
- my @word_arr;
- for (my $i = 0; $i < $word_len; $i++)
- {
- push (@word_arr, get_random_chr ($word_chr_min, $word_chr_max));
- }
- my $word_buf = join ("", @word_arr);
- ##
- ## dupe
- ##
- next if exists $dupe{$word_buf};
- $dupe{$word_buf} = undef;
- ##
- ## store
- ##
- print OUTP $word_buf, "\n";
- my $hash_buf = md5_hex (md5_hex ($word_buf));
- print OUTH $hash_buf, "\n";
- $left--;
- }
- close (OUTH);
- close (OUTP);
- }
- }
- ##
- ## test5 : random number of passwords, random word length, random chars, 10 times
- ## : simple out -a 0 -m 4.
- ##
- sub test5
- {
- my $test_num = 5;
- my $tmp_word = "examples/A0.M4.word";
- my $tmp_hash = "examples/A0.M4.hash";
- for (1..$runs_per_test)
- {
- my $num_words = get_random_num ($num_words_min, $num_words_max);
- open (OUTP, ">", $tmp_word) or die ("$tmp_word: $!\n");
- open (OUTH, ">", $tmp_hash) or die ("$tmp_hash: $!\n");
- my %dupe;
- my $left = $num_words;
- while ($left)
- {
- ##
- ## word
- ##
- my $word_len = get_random_num ($word_len_min, $word_len_max);
- my @word_arr;
- for (my $i = 0; $i < $word_len; $i++)
- {
- push (@word_arr, get_random_chr ($word_chr_min, $word_chr_max));
- }
- my $word_buf = join ("", @word_arr);
- ##
- ## dupe
- ##
- next if exists $dupe{$word_buf};
- $dupe{$word_buf} = undef;
- ##
- ## store
- ##
- print OUTP $word_buf, "\n";
- my $hash_buf = md5_hex (md5_hex (md5_hex ($word_buf)));
- print OUTH $hash_buf, "\n";
- $left--;
- }
- close (OUTH);
- close (OUTP);
- }
- }
- ##
- ## test6 : random number of passwords, random word length, random chars, 10 times
- ## : simple out -a 0 -m 5.
- ##
- sub test6
- {
- my $test_num = 6;
- my $tmp_word = "examples/A0.M5.word";
- my $tmp_hash = "examples/A0.M5.hash";
- for (1..$runs_per_test)
- {
- my $num_words = get_random_num ($num_words_min, $num_words_max);
- open (OUTP, ">", $tmp_word) or die ("$tmp_word: $!\n");
- open (OUTH, ">", $tmp_hash) or die ("$tmp_hash: $!\n");
- my %dupe;
- my $left = $num_words;
- while ($left)
- {
- ##
- ## salt
- ##
- my $salt_len = get_random_num (1, 10);
- my @salt_arr;
- for (my $i = 0; $i < $salt_len; $i++)
- {
- push (@salt_arr, get_random_chr ($word_chr_min, $word_chr_max));
- }
- my $salt_buf = join ("", @salt_arr);
- ##
- ## word
- ##
- my $word_len = get_random_num (1, 40);
- my @word_arr;
- for (my $i = 0; $i < $word_len; $i++)
- {
- push (@word_arr, get_random_chr ($word_chr_min, $word_chr_max));
- }
- my $word_buf = join ("", @word_arr);
- ##
- ## dupe
- ##
- next if exists $dupe{$word_buf};
- $dupe{$word_buf} = undef;
- ##
- ## store
- ##
- print OUTP $word_buf, "\n";
- my $hash_buf = md5_hex (md5_hex ($word_buf) . $salt_buf);
- print OUTH $hash_buf, ":", $salt_buf, "\n";
- $left--;
- }
- close (OUTH);
- close (OUTP);
- }
- }
- ##
- ## test7 : random number of passwords, random word length, random chars, 10 times
- ## : simple out -a 0 -m 6.
- ##
- sub test7
- {
- my $test_num = 7;
- my $tmp_word = "examples/A0.M6.word";
- my $tmp_hash = "examples/A0.M6.hash";
- for (1..$runs_per_test)
- {
- my $num_words = get_random_num ($num_words_min, $num_words_max);
- open (OUTP, ">", $tmp_word) or die ("$tmp_word: $!\n");
- open (OUTH, ">", $tmp_hash) or die ("$tmp_hash: $!\n");
- my %dupe;
- my $left = $num_words;
- while ($left)
- {
- ##
- ## salt
- ##
- my $salt_len = 32;
- my @salt_arr;
- for (my $i = 0; $i < $salt_len; $i++)
- {
- push (@salt_arr, get_random_chr ($word_chr_min, $word_chr_max));
- }
- my $salt_buf = join ("", @salt_arr);
- ##
- ## word
- ##
- my $word_len = get_random_num ($word_len_min, $word_len_max - 32);
- my @word_arr;
- for (my $i = 0; $i < $word_len; $i++)
- {
- push (@word_arr, get_random_chr ($word_chr_min, $word_chr_max));
- }
- my $word_buf = join ("", @word_arr);
- ##
- ## dupe
- ##
- next if exists $dupe{$word_buf};
- $dupe{$word_buf} = undef;
- ##
- ## store
- ##
- print OUTP $word_buf, "\n";
- my $hash_buf = md5_hex (md5_hex ($salt_buf) . $word_buf);
- print OUTH $hash_buf, ":", $salt_buf, "\n";
- $left--;
- }
- close (OUTH);
- close (OUTP);
- }
- }
- ##
- ## test8 : random number of passwords, random word length, random chars, 10 times
- ## : simple out -a 1.
- ##
- sub test8
- {
- my $test_num = 8;
- my $tmp_word = "examples/A1.M0.word";
- my $tmp_hash = "examples/A1.M0.hash";
- for (1..$runs_per_test)
- {
- my $num_words = get_random_num ($num_words_min, $num_words_max);
- open (OUTP, ">", $tmp_word) or die ("$tmp_word: $!\n");
- open (OUTH, ">", $tmp_hash) or die ("$tmp_hash: $!\n");
- my %dupe;
- my $left = $num_words;
- while ($left)
- {
- ##
- ## word
- ##
- my $word_len = get_random_num (6, 14);
- my @word_arr;
- for (my $i = 0; $i < $word_len; $i++)
- {
- push (@word_arr, get_random_chr ($word_chr_min, $word_chr_max));
- }
- my $word_buf = join ("", @word_arr);
- my $word_buf_sep = int ($word_len / 2);
- my $word_buf_left = substr ($word_buf, 0, $word_buf_sep);
- my $word_buf_right = substr ($word_buf, $word_buf_sep);
- ##
- ## dupe
- ##
- next if exists $dupe{$word_buf};
- $dupe{$word_buf} = undef;
- ##
- ## store
- ##
- print OUTP $word_buf_left, "\n";
- print OUTP $word_buf_right, "\n";
- my $hash_buf = md5_hex ($word_buf);
- print OUTH $hash_buf, "\n";
- $left--;
- }
- close (OUTH);
- close (OUTP);
- }
- }
- ##
- ## test9 : random number of passwords, random word length, random chars, 10 times
- ## : simple out -a 0 -m 7.
- ##
- sub test9
- {
- my $test_num = 9;
- my $tmp_word = "examples/A0.M7.word";
- my $tmp_hash = "examples/A0.M7.hash";
- for (1..$runs_per_test)
- {
- my $num_words = get_random_num ($num_words_min, $num_words_max);
- open (OUTP, ">", $tmp_word) or die ("$tmp_word: $!\n");
- open (OUTH, ">", $tmp_hash) or die ("$tmp_hash: $!\n");
- my %dupe;
- my $left = $num_words;
- while ($left)
- {
- ##
- ## salt
- ##
- my $salt_len = get_random_num ($salt_len_min, $salt_len_max - 32);
- my @salt_arr;
- for (my $i = 0; $i < $salt_len; $i++)
- {
- push (@salt_arr, get_random_chr ($word_chr_min, $word_chr_max));
- }
- my $salt_buf = join ("", @salt_arr);
- ##
- ## word
- ##
- my $word_len = get_random_num ($word_len_min, $word_len_max - $salt_len);
- my @word_arr;
- for (my $i = 0; $i < $word_len; $i++)
- {
- push (@word_arr, get_random_chr ($word_chr_min, $word_chr_max));
- }
- my $word_buf = join ("", @word_arr);
- ##
- ## dupe
- ##
- next if exists $dupe{$word_buf};
- $dupe{$word_buf} = undef;
- ##
- ## store
- ##
- print OUTP $word_buf, "\n";
- my $hash_buf = md5_hex ($salt_buf . md5_hex ($word_buf));
- print OUTH $hash_buf, ":", $salt_buf, "\n";
- $left--;
- }
- close (OUTH);
- close (OUTP);
- }
- }
- ##
- ## test10 : random number of passwords, random word length, random chars, 10 times
- ## : simple out -a 0 -m 8.
- ##
- sub test10
- {
- my $test_num = 10;
- my $tmp_word = "examples/A0.M8.word";
- my $tmp_hash = "examples/A0.M8.hash";
- for (1..$runs_per_test)
- {
- my $num_words = get_random_num ($num_words_min, $num_words_max);
- open (OUTP, ">", $tmp_word) or die ("$tmp_word: $!\n");
- open (OUTH, ">", $tmp_hash) or die ("$tmp_hash: $!\n");
- my %dupe;
- my $left = $num_words;
- while ($left)
- {
- ##
- ## salt
- ##
- my $salt_len = 10;
- my @salt_arr;
- for (my $i = 0; $i < $salt_len; $i++)
- {
- push (@salt_arr, get_random_chr ($word_chr_min, $word_chr_max));
- }
- my $salt_buf = join ("", @salt_arr);
- ##
- ## word
- ##
- my $word_len = get_random_num ($word_len_min, $word_len_max - ($salt_len * 2));
- my @word_arr;
- for (my $i = 0; $i < $word_len; $i++)
- {
- push (@word_arr, get_random_chr ($word_chr_min, $word_chr_max));
- }
- my $word_buf = join ("", @word_arr);
- ##
- ## dupe
- ##
- next if exists $dupe{$word_buf};
- $dupe{$word_buf} = undef;
- ##
- ## store
- ##
- print OUTP $word_buf, "\n";
- my $hash_buf = md5_hex ($salt_buf . $word_buf . $salt_buf);
- print OUTH $hash_buf, ":", $salt_buf, "\n";
- $left--;
- }
- close (OUTH);
- close (OUTP);
- }
- }
- ##
- ## test11 : random number of passwords, random word length, random chars, 10 times
- ## : simple out -a 0 -m 9.
- ##
- sub test11
- {
- my $test_num = 11;
- my $tmp_word = "examples/A0.M9.word";
- my $tmp_hash = "examples/A0.M9.hash";
- for (1..$runs_per_test)
- {
- my $num_words = get_random_num ($num_words_min, $num_words_max);
- open (OUTP, ">", $tmp_word) or die ("$tmp_word: $!\n");
- open (OUTH, ">", $tmp_hash) or die ("$tmp_hash: $!\n");
- my %dupe;
- my $left = $num_words;
- while ($left)
- {
- ##
- ## salt
- ##
- my $salt_len = 10;
- my @salt_arr;
- for (my $i = 0; $i < $salt_len; $i++)
- {
- push (@salt_arr, get_random_chr ($word_chr_min, $word_chr_max));
- }
- my $salt_buf = join ("", @salt_arr);
- ##
- ## word
- ##
- my $word_len = 10;
- my @word_arr;
- for (my $i = 0; $i < $word_len; $i++)
- {
- push (@word_arr, get_random_chr ($word_chr_min, $word_chr_max));
- }
- my $word_buf = join ("", @word_arr);
- ##
- ## dupe
- ##
- next if exists $dupe{$word_buf};
- $dupe{$word_buf} = undef;
- ##
- ## store
- ##
- print OUTP $word_buf, "\n";
- my $hash_buf = md5_hex (md5_hex ($salt_buf) . md5_hex ($word_buf));
- print OUTH $hash_buf, ":", $salt_buf, "\n";
- $left--;
- }
- close (OUTH);
- close (OUTP);
- }
- }
- sub test12
- {
- my $test_num = 12;
- my $tmp_word = "examples/A0.M10.word";
- my $tmp_hash = "examples/A0.M10.hash";
- for (1..$runs_per_test)
- {
- my $num_words = get_random_num ($num_words_min, $num_words_max);
- open (OUTP, ">", $tmp_word) or die ("$tmp_word: $!\n");
- open (OUTH, ">", $tmp_hash) or die ("$tmp_hash: $!\n");
- my %dupe;
- my $left = $num_words;
- while ($left)
- {
- ##
- ## salt
- ##
- my $salt_len = 10;
- my @salt_arr;
- for (my $i = 0; $i < $salt_len; $i++)
- {
- push (@salt_arr, get_random_chr ($word_chr_min, $word_chr_max));
- }
- my $salt_buf = join ("", @salt_arr);
- ##
- ## word
- ##
- my $word_len = 10;
- my @word_arr;
- for (my $i = 0; $i < $word_len; $i++)
- {
- push (@word_arr, get_random_chr ($word_chr_min, $word_chr_max));
- }
- my $word_buf = join ("", @word_arr);
- ##
- ## dupe
- ##
- next if exists $dupe{$word_buf};
- $dupe{$word_buf} = undef;
- ##
- ## store
- ##
- print OUTP $word_buf, "\n";
- my $hash_buf = md5_hex (md5_hex ($word_buf) . md5_hex ($salt_buf));
- print OUTH $hash_buf, ":", $salt_buf, "\n";
- $left--;
- }
- close (OUTH);
- close (OUTP);
- }
- }
- ##
- ## subs
- ##
- sub comword
- {
- my $test_num = shift;
- my $msg = shift;
- die ("$test_num: $msg\n");
- }
- sub get_lines_in_file
- {
- my $file = shift;
- my $count = 0;
- open (IN, $file) or die ("$file: $!\n");
- while (<IN>) { $count++ }
- close (IN);
- return $count;
- }
- sub get_random_num
- {
- my $min = shift;
- my $max = shift;
- return int ((rand ($max - $min)) + $min);
- }
- sub get_random_chr
- {
- return chr get_random_num (@_);
- }
|