test.pl 35 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991
  1. #!/usr/bin/perl
  2. ##
  3. ## Author......: Jens Steube <jens.steube@gmail.com>
  4. ## License.....: MIT
  5. ##
  6. use strict;
  7. use warnings;
  8. use Digest::MD5 qw (md5_hex);
  9. use Digest::SHA qw (sha1_hex);
  10. use MIME::Base64;
  11. my $tmp_hash = "hash";
  12. my $tmp_word = "word";
  13. my $tmp_out = "out";
  14. my $hashcat = "./hashcat-cli64.bin";
  15. #my $hashcat = "hashcat-cli64.exe";
  16. my $runs_per_test = 3;
  17. my $num_words_min = 1;
  18. my $num_words_max = 1111;
  19. my $word_len_min = 1;
  20. my $word_len_max = 55;
  21. my $word_chr_min = 0x20;
  22. my $word_chr_max = 0xff;
  23. my $salt_len_min = 1;
  24. my $salt_len_max = 54;
  25. print "test1\n";
  26. test1 ();
  27. print "test2\n";
  28. test2 ();
  29. print "test3\n";
  30. test3 ();
  31. print "test4\n";
  32. test4 ();
  33. print "test5\n";
  34. test5 ();
  35. print "test6\n";
  36. test6 ();
  37. print "test7\n";
  38. test7 ();
  39. print "test8\n";
  40. test8 ();
  41. print "test9\n";
  42. test9 ();
  43. print "test10\n";
  44. test10 ();
  45. print "test11\n";
  46. test11 ();
  47. #print "test12\n";
  48. #test12 ();
  49. print "test13\n";
  50. test13 ();
  51. #print "test14\n";
  52. #test14 ();
  53. #print "test15\n";
  54. #test15 ();
  55. print "test16\n";
  56. test16 ();
  57. print "test17\n";
  58. test17 ();
  59. #print "test18\n";
  60. #test18 ();
  61. print "test19\n";
  62. test19 ();
  63. print "test20\n";
  64. test20 ();
  65. print "test21\n";
  66. test21 ();
  67. print "test22\n";
  68. test22 ();
  69. print "test23\n";
  70. test23 ();
  71. sub test44
  72. {
  73. for (1..1)
  74. {
  75. my $left = 5;
  76. my %dupe;
  77. while ($left)
  78. {
  79. ##
  80. ## word
  81. ##
  82. my $word_len = 8;
  83. my @word_arr;
  84. for (my $i = 0; $i < $word_len; $i++)
  85. {
  86. push (@word_arr, get_random_chr (0x61, 0x7a));
  87. # push (@word_arr, get_random_chr (0x41, 0x4a));
  88. }
  89. my $word_buf = join ("", @word_arr);
  90. ##
  91. ## dupe
  92. ##
  93. next if exists $dupe{$word_buf};
  94. $dupe{$word_buf} = undef;
  95. ##
  96. ## store
  97. ##
  98. print md5_hex ($word_buf), "\n";
  99. $left--;
  100. }
  101. }
  102. }
  103. sub test23
  104. {
  105. my $test_num = 23;
  106. for (1..$runs_per_test)
  107. {
  108. my $num_words = get_random_num ($num_words_min, $num_words_max);
  109. open (OUTP, ">", $tmp_word) or die ("$tmp_word: $!\n");
  110. open (OUTH, ">", $tmp_hash) or die ("$tmp_hash: $!\n");
  111. my %dupe;
  112. my $left = $num_words;
  113. while ($left)
  114. {
  115. ##
  116. ## salt
  117. ##
  118. my $salt_len = 8;
  119. my @salt_arr;
  120. for (my $i = 0; $i < $salt_len; $i++)
  121. {
  122. push (@salt_arr, get_random_chr ($word_chr_min, $word_chr_max));
  123. }
  124. my $salt_buf = join ("", @salt_arr);
  125. ##
  126. ## word
  127. ##
  128. my $word_len = get_random_num ($word_len_min, $word_len_max - 8);
  129. my @word_arr;
  130. for (my $i = 0; $i < $word_len; $i++)
  131. {
  132. push (@word_arr, get_random_chr ($word_chr_min, $word_chr_max));
  133. }
  134. my $word_buf = join ("", @word_arr);
  135. ##
  136. ## dupe
  137. ##
  138. next if exists $dupe{$word_buf};
  139. $dupe{$word_buf} = undef;
  140. ##
  141. ## store
  142. ##
  143. print OUTP $word_buf, "\n";
  144. my $ctx = Digest::SHA->new;
  145. $ctx->add ($word_buf);
  146. $ctx->add ($salt_buf);
  147. my $hash_buf = "{SSHA}" . encode_base64 ($ctx->digest . $salt_buf);
  148. print OUTH $hash_buf, "\n";
  149. $left--;
  150. }
  151. close (OUTH);
  152. close (OUTP);
  153. unlink ($tmp_out);
  154. my $rc = system ($hashcat, "-a", "0", "-m", "111", "-o", $tmp_out, $tmp_hash, $tmp_word);
  155. comword ($test_num, "rc") if ($rc != 0);
  156. my $lines = get_lines_in_file ($tmp_out);
  157. comword ($test_num, "numlines") if ($lines != $num_words);
  158. }
  159. }
  160. sub test22
  161. {
  162. my $test_num = 22;
  163. for (1..$runs_per_test)
  164. {
  165. my $num_words = get_random_num ($num_words_min, $num_words_max);
  166. open (OUTP, ">", $tmp_word) or die ("$tmp_word: $!\n");
  167. open (OUTH, ">", $tmp_hash) or die ("$tmp_hash: $!\n");
  168. my %dupe;
  169. my $left = $num_words;
  170. while ($left)
  171. {
  172. ##
  173. ## word
  174. ##
  175. my $word_len = get_random_num ($word_len_min, $word_len_max);
  176. my @word_arr;
  177. for (my $i = 0; $i < $word_len; $i++)
  178. {
  179. push (@word_arr, get_random_chr ($word_chr_min, $word_chr_max));
  180. }
  181. my $word_buf = join ("", @word_arr);
  182. ##
  183. ## dupe
  184. ##
  185. next if exists $dupe{$word_buf};
  186. $dupe{$word_buf} = undef;
  187. ##
  188. ## store
  189. ##
  190. print OUTP $word_buf, "\n";
  191. my $ctx = Digest::SHA->new;
  192. $ctx->add ($word_buf);
  193. my $hash_buf = "{SHA}" . encode_base64 ($ctx->digest);
  194. print OUTH $hash_buf, "\n";
  195. $left--;
  196. }
  197. close (OUTH);
  198. close (OUTP);
  199. unlink ($tmp_out);
  200. my $rc = system ($hashcat, "-a", "0", "-m", "101", "-o", $tmp_out, $tmp_hash, $tmp_word);
  201. comword ($test_num, "rc") if ($rc != 0);
  202. my $lines = get_lines_in_file ($tmp_out);
  203. comword ($test_num, "numlines") if ($lines != $num_words);
  204. }
  205. }
  206. sub test21
  207. {
  208. my $test_num = 21;
  209. for (1..$runs_per_test)
  210. {
  211. my $num_words = get_random_num ($num_words_min, $num_words_max);
  212. open (OUTP, ">", $tmp_word) or die ("$tmp_word: $!\n");
  213. open (OUTH, ">", $tmp_hash) or die ("$tmp_hash: $!\n");
  214. my %dupe;
  215. my $left = $num_words;
  216. while ($left)
  217. {
  218. ##
  219. ## salt
  220. ##
  221. my $salt_len = get_random_num (2, 2);
  222. my @salt_arr;
  223. for (my $i = 0; $i < $salt_len; $i++)
  224. {
  225. push (@salt_arr, get_random_chr (0x30, 0x39));
  226. }
  227. my $salt_buf = join ("", @salt_arr);
  228. ##
  229. ## word
  230. ##
  231. my $word_len = get_random_num ($word_len_min, $word_len_max - $salt_len);
  232. my @word_arr;
  233. for (my $i = 0; $i < $word_len; $i++)
  234. {
  235. push (@word_arr, get_random_chr ($word_chr_min, $word_chr_max));
  236. }
  237. my $word_buf = join ("", @word_arr);
  238. ##
  239. ## dupe
  240. ##
  241. next if exists $dupe{$word_buf};
  242. $dupe{$word_buf} = undef;
  243. ##
  244. ## store
  245. ##
  246. print OUTP $word_buf, "\n";
  247. my $hash_buf = md5_hex (md5_hex ($word_buf) . $salt_buf);
  248. print OUTH $hash_buf, "\n";
  249. $left--;
  250. }
  251. close (OUTH);
  252. close (OUTP);
  253. unlink ($tmp_out);
  254. my $rc = system ($hashcat, "-a", "0", "-m", "2611", "-e", "salts/brute-oscommerce.salt", "-o", $tmp_out, $tmp_hash, $tmp_word);
  255. comword ($test_num, "rc") if ($rc != 0);
  256. my $lines = get_lines_in_file ($tmp_out);
  257. comword ($test_num, "numlines") if ($lines != $num_words);
  258. }
  259. }
  260. sub test20
  261. {
  262. my $test_num = 20;
  263. for (1..$runs_per_test)
  264. {
  265. my $num_words = get_random_num ($num_words_min, $num_words_max);
  266. open (OUTP, ">", $tmp_word) or die ("$tmp_word: $!\n");
  267. open (OUTH, ">", $tmp_hash) or die ("$tmp_hash: $!\n");
  268. my %dupe;
  269. my $left = $num_words;
  270. while ($left)
  271. {
  272. ##
  273. ## word
  274. ##
  275. my $word_len = get_random_num ($word_len_min, $word_len_max);
  276. my @word_arr;
  277. for (my $i = 0; $i < $word_len; $i++)
  278. {
  279. push (@word_arr, get_random_chr ($word_chr_min, $word_chr_max));
  280. }
  281. my $word_buf = join ("", @word_arr);
  282. ##
  283. ## dupe
  284. ##
  285. next if exists $dupe{$word_buf};
  286. $dupe{$word_buf} = undef;
  287. ##
  288. ## store
  289. ##
  290. print OUTP $word_buf, "\n";
  291. my $hash_buf = sha1_hex (sha1_hex (sha1_hex ($word_buf)));
  292. print OUTH $hash_buf, "\n";
  293. $left--;
  294. }
  295. close (OUTH);
  296. close (OUTP);
  297. unlink ($tmp_out);
  298. my $rc = system ($hashcat, "-a", "0", "-m", "4600", "-o", $tmp_out, $tmp_hash, $tmp_word);
  299. comword ($test_num, "rc") if ($rc != 0);
  300. my $lines = get_lines_in_file ($tmp_out);
  301. comword ($test_num, "numlines") if ($lines != $num_words);
  302. }
  303. }
  304. sub test19
  305. {
  306. my $test_num = 19;
  307. for (1..$runs_per_test)
  308. {
  309. my $num_words = get_random_num ($num_words_min, $num_words_max);
  310. open (OUTP, ">", $tmp_word) or die ("$tmp_word: $!\n");
  311. open (OUTH, ">", $tmp_hash) or die ("$tmp_hash: $!\n");
  312. my %dupe;
  313. my $left = $num_words;
  314. while ($left)
  315. {
  316. ##
  317. ## word
  318. ##
  319. my $word_len = get_random_num ($word_len_min, $word_len_max);
  320. my @word_arr;
  321. for (my $i = 0; $i < $word_len; $i++)
  322. {
  323. push (@word_arr, get_random_chr ($word_chr_min, $word_chr_max));
  324. }
  325. my $word_buf = join ("", @word_arr);
  326. ##
  327. ## dupe
  328. ##
  329. next if exists $dupe{$word_buf};
  330. $dupe{$word_buf} = undef;
  331. ##
  332. ## store
  333. ##
  334. print OUTP $word_buf, "\n";
  335. my $hash_buf = sha1_hex (sha1_hex ($word_buf));
  336. print OUTH $hash_buf, "\n";
  337. $left--;
  338. }
  339. close (OUTH);
  340. close (OUTP);
  341. unlink ($tmp_out);
  342. my $rc = system ($hashcat, "-a", "0", "-m", "4500", "-o", $tmp_out, $tmp_hash, $tmp_word);
  343. comword ($test_num, "rc") if ($rc != 0);
  344. my $lines = get_lines_in_file ($tmp_out);
  345. comword ($test_num, "numlines") if ($lines != $num_words);
  346. }
  347. }
  348. sub test18
  349. {
  350. my $test_num = 18;
  351. for (1..$runs_per_test)
  352. {
  353. my $num_words = get_random_num ($num_words_min, $num_words_max);
  354. open (OUTP, ">", $tmp_word) or die ("$tmp_word: $!\n");
  355. open (OUTH, ">", $tmp_hash) or die ("$tmp_hash: $!\n");
  356. my %dupe;
  357. my $left = $num_words;
  358. while ($left)
  359. {
  360. ##
  361. ## word
  362. ##
  363. my $word_len = 5;
  364. my @word_arr;
  365. for (my $i = 0; $i < $word_len; $i++)
  366. {
  367. push (@word_arr, get_random_chr (0x61, 0x7a));
  368. }
  369. my $word_buf = join ("", @word_arr);
  370. ##
  371. ## dupe
  372. ##
  373. next if exists $dupe{$word_buf};
  374. $dupe{$word_buf} = undef;
  375. ##
  376. ## store
  377. ##
  378. print OUTP $word_buf, "\n";
  379. my $hash_buf = md5_hex ($word_buf);
  380. print OUTH $hash_buf, "\n";
  381. $left--;
  382. }
  383. close (OUTH);
  384. close (OUTP);
  385. unlink ($tmp_out);
  386. my $rc = system ($hashcat, "-a", "3", "-m", "0", "-o", $tmp_out, $tmp_hash, "--pw-min=5", "--pw-max=5");
  387. comword ($test_num, "rc") if ($rc != 0);
  388. my $lines = get_lines_in_file ($tmp_out);
  389. comword ($test_num, "numlines") if ($lines != $num_words);
  390. }
  391. }
  392. sub test16
  393. {
  394. my $test_num = 16;
  395. for (1..$runs_per_test)
  396. {
  397. my $num_words = get_random_num ($num_words_min, $num_words_max);
  398. open (OUTP, ">", $tmp_word) or die ("$tmp_word: $!\n");
  399. open (OUTH, ">", $tmp_hash) or die ("$tmp_hash: $!\n");
  400. my %dupe;
  401. my $left = $num_words;
  402. while ($left)
  403. {
  404. ##
  405. ## salt
  406. ##
  407. my $salt_len = 10;
  408. my @salt_arr;
  409. for (my $i = 0; $i < $salt_len; $i++)
  410. {
  411. push (@salt_arr, get_random_chr ($word_chr_min, $word_chr_max));
  412. }
  413. my $salt_buf = join ("", @salt_arr);
  414. ##
  415. ## word
  416. ##
  417. my $word_len = 10;
  418. my @word_arr;
  419. for (my $i = 0; $i < $word_len; $i++)
  420. {
  421. push (@word_arr, get_random_chr ($word_chr_min, $word_chr_max));
  422. }
  423. my $word_buf = join ("", @word_arr);
  424. ##
  425. ## dupe
  426. ##
  427. next if exists $dupe{$word_buf};
  428. $dupe{$word_buf} = undef;
  429. ##
  430. ## store
  431. ##
  432. print OUTP $word_buf, "\n";
  433. my $hash_buf = md5_hex ($salt_buf . md5_hex ($salt_buf . $word_buf));
  434. print OUTH $hash_buf, ":", $salt_buf, "\n";
  435. $left--;
  436. }
  437. close (OUTH);
  438. close (OUTP);
  439. unlink ($tmp_out);
  440. my $rc = system ($hashcat, "-a", "0", "-m", "4010", "-o", $tmp_out, $tmp_hash, $tmp_word);
  441. comword ($test_num, "rc") if ($rc != 0);
  442. my $lines = get_lines_in_file ($tmp_out);
  443. comword ($test_num, "numlines") if ($lines != $num_words);
  444. }
  445. }
  446. sub test17
  447. {
  448. my $test_num = 17;
  449. for (1..$runs_per_test)
  450. {
  451. my $num_words = get_random_num ($num_words_min, $num_words_max);
  452. open (OUTP, ">", $tmp_word) or die ("$tmp_word: $!\n");
  453. open (OUTH, ">", $tmp_hash) or die ("$tmp_hash: $!\n");
  454. my %dupe;
  455. my $left = $num_words;
  456. while ($left)
  457. {
  458. ##
  459. ## salt
  460. ##
  461. my $salt_len = 10;
  462. my @salt_arr;
  463. for (my $i = 0; $i < $salt_len; $i++)
  464. {
  465. push (@salt_arr, get_random_chr ($word_chr_min, $word_chr_max));
  466. }
  467. my $salt_buf = join ("", @salt_arr);
  468. ##
  469. ## word
  470. ##
  471. my $word_len = 10;
  472. my @word_arr;
  473. for (my $i = 0; $i < $word_len; $i++)
  474. {
  475. push (@word_arr, get_random_chr ($word_chr_min, $word_chr_max));
  476. }
  477. my $word_buf = join ("", @word_arr);
  478. ##
  479. ## dupe
  480. ##
  481. next if exists $dupe{$word_buf};
  482. $dupe{$word_buf} = undef;
  483. ##
  484. ## store
  485. ##
  486. print OUTP $word_buf, "\n";
  487. my $hash_buf = md5_hex ($salt_buf . md5_hex ($word_buf . $salt_buf));
  488. print OUTH $hash_buf, ":", $salt_buf, "\n";
  489. $left--;
  490. }
  491. close (OUTH);
  492. close (OUTP);
  493. unlink ($tmp_out);
  494. my $rc = system ($hashcat, "-a", "0", "-m", "4110", "-o", $tmp_out, $tmp_hash, $tmp_word);
  495. comword ($test_num, "rc") if ($rc != 0);
  496. my $lines = get_lines_in_file ($tmp_out);
  497. comword ($test_num, "numlines") if ($lines != $num_words);
  498. }
  499. }
  500. sub test13
  501. {
  502. my $test_num = 13;
  503. for (1..$runs_per_test)
  504. {
  505. my $num_words = get_random_num ($num_words_min, $num_words_max);
  506. open (OUTP, ">", $tmp_word) or die ("$tmp_word: $!\n");
  507. open (OUTH, ">", $tmp_hash) or die ("$tmp_hash: $!\n");
  508. my %dupe;
  509. my $left = $num_words;
  510. while ($left)
  511. {
  512. my $word_len = get_random_num ($word_len_min, $word_len_max);
  513. my @word_arr;
  514. for (my $i = 0; $i < $word_len; $i++)
  515. {
  516. push (@word_arr, get_random_chr ($word_chr_min, $word_chr_max));
  517. }
  518. my $word_buf = join ("", @word_arr);
  519. next if exists $dupe{$word_buf};
  520. $dupe{$word_buf} = undef;
  521. print OUTP $word_buf, "\n";
  522. my $hash_buf = sha1_hex ($word_buf);
  523. print OUTH $hash_buf, "\n";
  524. $left--;
  525. }
  526. close (OUTH);
  527. close (OUTP);
  528. unlink ($tmp_out);
  529. my $rc = system ($hashcat, "-a", "0", "-m", "100", "-o", $tmp_out, $tmp_hash, $tmp_word);
  530. comword ($test_num, "rc") if ($rc != 0);
  531. my $lines = get_lines_in_file ($tmp_out);
  532. comword ($test_num, "numlines") if ($lines != $num_words);
  533. }
  534. }
  535. sub test14
  536. {
  537. my $test_num = 14;
  538. for (1..$runs_per_test)
  539. {
  540. my $num_words = get_random_num ($num_words_min, $num_words_max);
  541. open (OUTP, ">", $tmp_word) or die ("$tmp_word: $!\n");
  542. open (OUTH, ">", $tmp_hash) or die ("$tmp_hash: $!\n");
  543. my %dupe;
  544. my $left = $num_words;
  545. while ($left)
  546. {
  547. ##
  548. ## salt
  549. ##
  550. my $salt_len = get_random_num ($salt_len_min, $salt_len_max);
  551. my @salt_arr;
  552. for (my $i = 0; $i < $salt_len; $i++)
  553. {
  554. push (@salt_arr, get_random_chr ($word_chr_min, $word_chr_max));
  555. }
  556. my $salt_buf = join ("", @salt_arr);
  557. ##
  558. ## word
  559. ##
  560. my $word_len = get_random_num ($word_len_min, $word_len_max - $salt_len);
  561. my @word_arr;
  562. for (my $i = 0; $i < $word_len; $i++)
  563. {
  564. push (@word_arr, get_random_chr ($word_chr_min, $word_chr_max));
  565. }
  566. my $word_buf = join ("", @word_arr);
  567. ##
  568. ## dupe
  569. ##
  570. next if exists $dupe{$word_buf};
  571. $dupe{$word_buf} = undef;
  572. ##
  573. ## store
  574. ##
  575. print OUTP $word_buf, "\n";
  576. my $hash_buf = sha1_hex ($word_buf . $salt_buf);
  577. print OUTH $hash_buf, ":", $salt_buf, "\n";
  578. $left--;
  579. }
  580. close (OUTH);
  581. close (OUTP);
  582. unlink ($tmp_out);
  583. my $rc = system ($hashcat, "-a", "0", "-m", "101", "-o", $tmp_out, $tmp_hash, $tmp_word);
  584. comword ($test_num, "rc") if ($rc != 0);
  585. my $lines = get_lines_in_file ($tmp_out);
  586. comword ($test_num, "numlines") if ($lines != $num_words);
  587. }
  588. }
  589. sub test15
  590. {
  591. my $test_num = 15;
  592. for (1..$runs_per_test)
  593. {
  594. my $num_words = get_random_num ($num_words_min, $num_words_max);
  595. open (OUTP, ">", $tmp_word) or die ("$tmp_word: $!\n");
  596. open (OUTH, ">", $tmp_hash) or die ("$tmp_hash: $!\n");
  597. my %dupe;
  598. my $left = $num_words;
  599. while ($left)
  600. {
  601. ##
  602. ## salt
  603. ##
  604. my $salt_len = get_random_num ($salt_len_min, $salt_len_max);
  605. my @salt_arr;
  606. for (my $i = 0; $i < $salt_len; $i++)
  607. {
  608. push (@salt_arr, get_random_chr ($word_chr_min, $word_chr_max));
  609. }
  610. my $salt_buf = join ("", @salt_arr);
  611. ##
  612. ## word
  613. ##
  614. my $word_len = get_random_num ($word_len_min, $word_len_max - $salt_len);
  615. my @word_arr;
  616. for (my $i = 0; $i < $word_len; $i++)
  617. {
  618. push (@word_arr, get_random_chr ($word_chr_min, $word_chr_max));
  619. }
  620. my $word_buf = join ("", @word_arr);
  621. ##
  622. ## dupe
  623. ##
  624. next if exists $dupe{$word_buf};
  625. $dupe{$word_buf} = undef;
  626. ##
  627. ## store
  628. ##
  629. print OUTP $word_buf, "\n";
  630. my $hash_buf = sha1_hex ($salt_buf . $word_buf);
  631. print OUTH $hash_buf, ":", $salt_buf, "\n";
  632. $left--;
  633. }
  634. close (OUTH);
  635. close (OUTP);
  636. unlink ($tmp_out);
  637. my $rc = system ($hashcat, "-a", "0", "-m", "102", "-o", $tmp_out, $tmp_hash, $tmp_word);
  638. comword ($test_num, "rc") if ($rc != 0);
  639. my $lines = get_lines_in_file ($tmp_out);
  640. comword ($test_num, "numlines") if ($lines != $num_words);
  641. }
  642. }
  643. ##
  644. ## test1 : random number of passwords, random word length, random chars, 10 times
  645. ## : simple out -a 0 -m 0.
  646. ##
  647. sub test1
  648. {
  649. my $test_num = 1;
  650. for (1..$runs_per_test)
  651. {
  652. my $num_words = get_random_num ($num_words_min, $num_words_max);
  653. open (OUTP, ">", $tmp_word) or die ("$tmp_word: $!\n");
  654. open (OUTH, ">", $tmp_hash) or die ("$tmp_hash: $!\n");
  655. my %dupe;
  656. my $left = $num_words;
  657. while ($left)
  658. {
  659. my $word_len = get_random_num ($word_len_min, $word_len_max);
  660. my @word_arr;
  661. for (my $i = 0; $i < $word_len; $i++)
  662. {
  663. push (@word_arr, get_random_chr ($word_chr_min, $word_chr_max));
  664. }
  665. my $word_buf = join ("", @word_arr);
  666. next if exists $dupe{$word_buf};
  667. $dupe{$word_buf} = undef;
  668. print OUTP $word_buf, "\n";
  669. my $hash_buf = md5_hex ($word_buf);
  670. print OUTH $hash_buf, "\n";
  671. $left--;
  672. }
  673. close (OUTH);
  674. close (OUTP);
  675. unlink ($tmp_out);
  676. my $rc = system ($hashcat, "-a", "0", "-m", "0", "-o", $tmp_out, $tmp_hash, $tmp_word);
  677. comword ($test_num, "rc") if ($rc != 0);
  678. my $lines = get_lines_in_file ($tmp_out);
  679. comword ($test_num, "numlines") if ($lines != $num_words);
  680. }
  681. }
  682. ##
  683. ## test2 : random number of passwords, random word length, random chars, 10 times
  684. ## : simple out -a 0 -m 10.
  685. ##
  686. sub test2
  687. {
  688. my $test_num = 2;
  689. for (1..$runs_per_test)
  690. {
  691. my $num_words = get_random_num ($num_words_min, $num_words_max);
  692. open (OUTP, ">", $tmp_word) or die ("$tmp_word: $!\n");
  693. open (OUTH, ">", $tmp_hash) or die ("$tmp_hash: $!\n");
  694. my %dupe;
  695. my $left = $num_words;
  696. while ($left)
  697. {
  698. ##
  699. ## salt
  700. ##
  701. my $salt_len = get_random_num ($salt_len_min, $salt_len_max);
  702. my @salt_arr;
  703. for (my $i = 0; $i < $salt_len; $i++)
  704. {
  705. push (@salt_arr, get_random_chr ($word_chr_min, $word_chr_max));
  706. }
  707. my $salt_buf = join ("", @salt_arr);
  708. ##
  709. ## word
  710. ##
  711. my $word_len = get_random_num ($word_len_min, $word_len_max - $salt_len);
  712. my @word_arr;
  713. for (my $i = 0; $i < $word_len; $i++)
  714. {
  715. push (@word_arr, get_random_chr ($word_chr_min, $word_chr_max));
  716. }
  717. my $word_buf = join ("", @word_arr);
  718. ##
  719. ## dupe
  720. ##
  721. next if exists $dupe{$word_buf};
  722. $dupe{$word_buf} = undef;
  723. ##
  724. ## store
  725. ##
  726. print OUTP $word_buf, "\n";
  727. my $hash_buf = md5_hex ($word_buf . $salt_buf);
  728. print OUTH $hash_buf, ":", $salt_buf, "\n";
  729. $left--;
  730. }
  731. close (OUTH);
  732. close (OUTP);
  733. unlink ($tmp_out);
  734. my $rc = system ($hashcat, "-a", "0", "-m", "10", "-o", $tmp_out, $tmp_hash, $tmp_word);
  735. comword ($test_num, "rc") if ($rc != 0);
  736. my $lines = get_lines_in_file ($tmp_out);
  737. comword ($test_num, "numlines") if ($lines != $num_words);
  738. }
  739. }
  740. ##
  741. ## test3 : random number of passwords, random word length, random chars, 10 times
  742. ## : simple out -a 0 -m 20.
  743. ##
  744. sub test3
  745. {
  746. my $test_num = 3;
  747. for (1..$runs_per_test)
  748. {
  749. my $num_words = get_random_num ($num_words_min, $num_words_max);
  750. open (OUTP, ">", $tmp_word) or die ("$tmp_word: $!\n");
  751. open (OUTH, ">", $tmp_hash) or die ("$tmp_hash: $!\n");
  752. my %dupe;
  753. my $left = $num_words;
  754. while ($left)
  755. {
  756. ##
  757. ## salt
  758. ##
  759. my $salt_len = get_random_num ($salt_len_min, $salt_len_max);
  760. my @salt_arr;
  761. for (my $i = 0; $i < $salt_len; $i++)
  762. {
  763. push (@salt_arr, get_random_chr ($word_chr_min, $word_chr_max));
  764. }
  765. my $salt_buf = join ("", @salt_arr);
  766. ##
  767. ## word
  768. ##
  769. my $word_len = get_random_num ($word_len_min, $word_len_max - $salt_len);
  770. my @word_arr;
  771. for (my $i = 0; $i < $word_len; $i++)
  772. {
  773. push (@word_arr, get_random_chr ($word_chr_min, $word_chr_max));
  774. }
  775. my $word_buf = join ("", @word_arr);
  776. ##
  777. ## dupe
  778. ##
  779. next if exists $dupe{$word_buf};
  780. $dupe{$word_buf} = undef;
  781. ##
  782. ## store
  783. ##
  784. print OUTP $word_buf, "\n";
  785. my $hash_buf = md5_hex ($salt_buf . $word_buf);
  786. print OUTH $hash_buf, ":", $salt_buf, "\n";
  787. $left--;
  788. }
  789. close (OUTH);
  790. close (OUTP);
  791. unlink ($tmp_out);
  792. my $rc = system ($hashcat, "-a", "0", "-m", "20", "-o", $tmp_out, $tmp_hash, $tmp_word);
  793. comword ($test_num, "rc") if ($rc != 0);
  794. my $lines = get_lines_in_file ($tmp_out);
  795. comword ($test_num, "numlines") if ($lines != $num_words);
  796. }
  797. }
  798. ##
  799. ## test4 : random number of passwords, random word length, random chars, 10 times
  800. ## : simple out -a 0 -m 2600.
  801. ##
  802. sub test4
  803. {
  804. my $test_num = 4;
  805. for (1..$runs_per_test)
  806. {
  807. my $num_words = get_random_num ($num_words_min, $num_words_max);
  808. open (OUTP, ">", $tmp_word) or die ("$tmp_word: $!\n");
  809. open (OUTH, ">", $tmp_hash) or die ("$tmp_hash: $!\n");
  810. my %dupe;
  811. my $left = $num_words;
  812. while ($left)
  813. {
  814. ##
  815. ## word
  816. ##
  817. my $word_len = get_random_num ($word_len_min, $word_len_max);
  818. my @word_arr;
  819. for (my $i = 0; $i < $word_len; $i++)
  820. {
  821. push (@word_arr, get_random_chr ($word_chr_min, $word_chr_max));
  822. }
  823. my $word_buf = join ("", @word_arr);
  824. ##
  825. ## dupe
  826. ##
  827. next if exists $dupe{$word_buf};
  828. $dupe{$word_buf} = undef;
  829. ##
  830. ## store
  831. ##
  832. print OUTP $word_buf, "\n";
  833. my $hash_buf = md5_hex (md5_hex ($word_buf));
  834. print OUTH $hash_buf, "\n";
  835. $left--;
  836. }
  837. close (OUTH);
  838. close (OUTP);
  839. unlink ($tmp_out);
  840. my $rc = system ($hashcat, "-a", "0", "-m", "2600", "-o", $tmp_out, $tmp_hash, $tmp_word);
  841. comword ($test_num, "rc") if ($rc != 0);
  842. my $lines = get_lines_in_file ($tmp_out);
  843. comword ($test_num, "numlines") if ($lines != $num_words);
  844. }
  845. }
  846. ##
  847. ## test5 : random number of passwords, random word length, random chars, 10 times
  848. ## : simple out -a 0 -m 3500.
  849. ##
  850. sub test5
  851. {
  852. my $test_num = 5;
  853. for (1..$runs_per_test)
  854. {
  855. my $num_words = get_random_num ($num_words_min, $num_words_max);
  856. open (OUTP, ">", $tmp_word) or die ("$tmp_word: $!\n");
  857. open (OUTH, ">", $tmp_hash) or die ("$tmp_hash: $!\n");
  858. my %dupe;
  859. my $left = $num_words;
  860. while ($left)
  861. {
  862. ##
  863. ## word
  864. ##
  865. my $word_len = get_random_num ($word_len_min, $word_len_max);
  866. my @word_arr;
  867. for (my $i = 0; $i < $word_len; $i++)
  868. {
  869. push (@word_arr, get_random_chr ($word_chr_min, $word_chr_max));
  870. }
  871. my $word_buf = join ("", @word_arr);
  872. ##
  873. ## dupe
  874. ##
  875. next if exists $dupe{$word_buf};
  876. $dupe{$word_buf} = undef;
  877. ##
  878. ## store
  879. ##
  880. print OUTP $word_buf, "\n";
  881. my $hash_buf = md5_hex (md5_hex (md5_hex ($word_buf)));
  882. print OUTH $hash_buf, "\n";
  883. $left--;
  884. }
  885. close (OUTH);
  886. close (OUTP);
  887. unlink ($tmp_out);
  888. my $rc = system ($hashcat, "-a", "0", "-m", "3500", "-o", $tmp_out, $tmp_hash, $tmp_word);
  889. comword ($test_num, "rc") if ($rc != 0);
  890. my $lines = get_lines_in_file ($tmp_out);
  891. comword ($test_num, "numlines") if ($lines != $num_words);
  892. }
  893. }
  894. ##
  895. ## test6 : random number of passwords, random word length, random chars, 10 times
  896. ## : simple out -a 0 -m 2611.
  897. ##
  898. sub test6
  899. {
  900. my $test_num = 6;
  901. for (1..$runs_per_test)
  902. {
  903. my $num_words = get_random_num ($num_words_min, $num_words_max);
  904. open (OUTP, ">", $tmp_word) or die ("$tmp_word: $!\n");
  905. open (OUTH, ">", $tmp_hash) or die ("$tmp_hash: $!\n");
  906. my %dupe;
  907. my $left = $num_words;
  908. while ($left)
  909. {
  910. ##
  911. ## salt
  912. ##
  913. my $salt_len = get_random_num ($salt_len_min, $salt_len_max - 32);
  914. my @salt_arr;
  915. for (my $i = 0; $i < $salt_len; $i++)
  916. {
  917. push (@salt_arr, get_random_chr ($word_chr_min, $word_chr_max));
  918. }
  919. my $salt_buf = join ("", @salt_arr);
  920. ##
  921. ## word
  922. ##
  923. my $word_len = get_random_num ($word_len_min, $word_len_max - $salt_len);
  924. my @word_arr;
  925. for (my $i = 0; $i < $word_len; $i++)
  926. {
  927. push (@word_arr, get_random_chr ($word_chr_min, $word_chr_max));
  928. }
  929. my $word_buf = join ("", @word_arr);
  930. ##
  931. ## dupe
  932. ##
  933. next if exists $dupe{$word_buf};
  934. $dupe{$word_buf} = undef;
  935. ##
  936. ## store
  937. ##
  938. print OUTP $word_buf, "\n";
  939. my $hash_buf = md5_hex (md5_hex ($word_buf) . $salt_buf);
  940. print OUTH $hash_buf, ":", $salt_buf, "\n";
  941. $left--;
  942. }
  943. close (OUTH);
  944. close (OUTP);
  945. unlink ($tmp_out);
  946. my $rc = system ($hashcat, "-a", "0", "-m", "2611", "-o", $tmp_out, $tmp_hash, $tmp_word);
  947. comword ($test_num, "rc") if ($rc != 0);
  948. my $lines = get_lines_in_file ($tmp_out);
  949. comword ($test_num, "numlines") if ($lines != $num_words);
  950. }
  951. }
  952. ##
  953. ## test7 : random number of passwords, random word length, random chars, 10 times
  954. ## : simple out -a 0 -m 3610.
  955. ##
  956. sub test7
  957. {
  958. my $test_num = 7;
  959. for (1..$runs_per_test)
  960. {
  961. my $num_words = get_random_num ($num_words_min, $num_words_max);
  962. open (OUTP, ">", $tmp_word) or die ("$tmp_word: $!\n");
  963. open (OUTH, ">", $tmp_hash) or die ("$tmp_hash: $!\n");
  964. my %dupe;
  965. my $left = $num_words;
  966. while ($left)
  967. {
  968. ##
  969. ## salt
  970. ##
  971. my $salt_len = 32;
  972. my @salt_arr;
  973. for (my $i = 0; $i < $salt_len; $i++)
  974. {
  975. push (@salt_arr, get_random_chr ($word_chr_min, $word_chr_max));
  976. }
  977. my $salt_buf = join ("", @salt_arr);
  978. ##
  979. ## word
  980. ##
  981. my $word_len = get_random_num ($word_len_min, $word_len_max - 32);
  982. my @word_arr;
  983. for (my $i = 0; $i < $word_len; $i++)
  984. {
  985. push (@word_arr, get_random_chr ($word_chr_min, $word_chr_max));
  986. }
  987. my $word_buf = join ("", @word_arr);
  988. ##
  989. ## dupe
  990. ##
  991. next if exists $dupe{$word_buf};
  992. $dupe{$word_buf} = undef;
  993. ##
  994. ## store
  995. ##
  996. print OUTP $word_buf, "\n";
  997. my $hash_buf = md5_hex (md5_hex ($salt_buf) . $word_buf);
  998. print OUTH $hash_buf, ":", $salt_buf, "\n";
  999. $left--;
  1000. }
  1001. close (OUTH);
  1002. close (OUTP);
  1003. unlink ($tmp_out);
  1004. my $rc = system ($hashcat, "-a", "0", "-m", "3610", "-o", $tmp_out, $tmp_hash, $tmp_word);
  1005. comword ($test_num, "rc") if ($rc != 0);
  1006. my $lines = get_lines_in_file ($tmp_out);
  1007. comword ($test_num, "numlines") if ($lines != $num_words);
  1008. }
  1009. }
  1010. ##
  1011. ## test7 : random number of passwords, random word length, random chars, 10 times
  1012. ## : simple out -a 1.
  1013. ##
  1014. sub test8
  1015. {
  1016. my $test_num = 8;
  1017. for (1..$runs_per_test)
  1018. {
  1019. my $num_words = get_random_num ($num_words_min, $num_words_max);
  1020. open (OUTP, ">", $tmp_word) or die ("$tmp_word: $!\n");
  1021. open (OUTH, ">", $tmp_hash) or die ("$tmp_hash: $!\n");
  1022. my %dupe;
  1023. my $left = $num_words;
  1024. while ($left)
  1025. {
  1026. ##
  1027. ## word
  1028. ##
  1029. my $word_len = get_random_num (6, 14);
  1030. my @word_arr;
  1031. for (my $i = 0; $i < $word_len; $i++)
  1032. {
  1033. push (@word_arr, get_random_chr ($word_chr_min, $word_chr_max));
  1034. }
  1035. my $word_buf = join ("", @word_arr);
  1036. my $word_buf_sep = int ($word_len / 2);
  1037. my $word_buf_left = substr ($word_buf, 0, $word_buf_sep);
  1038. my $word_buf_right = substr ($word_buf, $word_buf_sep);
  1039. ##
  1040. ## dupe
  1041. ##
  1042. next if exists $dupe{$word_buf};
  1043. $dupe{$word_buf} = undef;
  1044. ##
  1045. ## store
  1046. ##
  1047. print OUTP $word_buf_left, "\n";
  1048. print OUTP $word_buf_right, "\n";
  1049. my $hash_buf = md5_hex ($word_buf);
  1050. print OUTH $hash_buf, "\n";
  1051. $left--;
  1052. }
  1053. close (OUTH);
  1054. close (OUTP);
  1055. unlink ($tmp_out);
  1056. my $rc = system ($hashcat, "-a", "1", "-o", $tmp_out, $tmp_hash, $tmp_word);
  1057. comword ($test_num, "rc") if ($rc != 0);
  1058. my $lines = get_lines_in_file ($tmp_out);
  1059. comword ($test_num, "numlines") if ($lines != $num_words);
  1060. }
  1061. }
  1062. ##
  1063. ## test9 : random number of passwords, random word length, random chars, 10 times
  1064. ## : simple out -a 0 -m 3710.
  1065. ##
  1066. sub test9
  1067. {
  1068. my $test_num = 9;
  1069. for (1..$runs_per_test)
  1070. {
  1071. my $num_words = get_random_num ($num_words_min, $num_words_max);
  1072. open (OUTP, ">", $tmp_word) or die ("$tmp_word: $!\n");
  1073. open (OUTH, ">", $tmp_hash) or die ("$tmp_hash: $!\n");
  1074. my %dupe;
  1075. my $left = $num_words;
  1076. while ($left)
  1077. {
  1078. ##
  1079. ## salt
  1080. ##
  1081. my $salt_len = get_random_num ($salt_len_min, $salt_len_max - 32);
  1082. my @salt_arr;
  1083. for (my $i = 0; $i < $salt_len; $i++)
  1084. {
  1085. push (@salt_arr, get_random_chr ($word_chr_min, $word_chr_max));
  1086. }
  1087. my $salt_buf = join ("", @salt_arr);
  1088. ##
  1089. ## word
  1090. ##
  1091. my $word_len = get_random_num ($word_len_min, $word_len_max - $salt_len);
  1092. my @word_arr;
  1093. for (my $i = 0; $i < $word_len; $i++)
  1094. {
  1095. push (@word_arr, get_random_chr ($word_chr_min, $word_chr_max));
  1096. }
  1097. my $word_buf = join ("", @word_arr);
  1098. ##
  1099. ## dupe
  1100. ##
  1101. next if exists $dupe{$word_buf};
  1102. $dupe{$word_buf} = undef;
  1103. ##
  1104. ## store
  1105. ##
  1106. print OUTP $word_buf, "\n";
  1107. my $hash_buf = md5_hex ($salt_buf . md5_hex ($word_buf));
  1108. print OUTH $hash_buf, ":", $salt_buf, "\n";
  1109. $left--;
  1110. }
  1111. close (OUTH);
  1112. close (OUTP);
  1113. unlink ($tmp_out);
  1114. my $rc = system ($hashcat, "-a", "0", "-m", "3710", "-o", $tmp_out, $tmp_hash, $tmp_word);
  1115. comword ($test_num, "rc") if ($rc != 0);
  1116. my $lines = get_lines_in_file ($tmp_out);
  1117. comword ($test_num, "numlines") if ($lines != $num_words);
  1118. }
  1119. }
  1120. ##
  1121. ## test10 : random number of passwords, random word length, random chars, 10 times
  1122. ## : simple out -a 0 -m 3810.
  1123. ##
  1124. sub test10
  1125. {
  1126. my $test_num = 10;
  1127. for (1..$runs_per_test)
  1128. {
  1129. my $num_words = get_random_num ($num_words_min, $num_words_max);
  1130. open (OUTP, ">", $tmp_word) or die ("$tmp_word: $!\n");
  1131. open (OUTH, ">", $tmp_hash) or die ("$tmp_hash: $!\n");
  1132. my %dupe;
  1133. my $left = $num_words;
  1134. while ($left)
  1135. {
  1136. ##
  1137. ## salt
  1138. ##
  1139. my $salt_len = 10;
  1140. my @salt_arr;
  1141. for (my $i = 0; $i < $salt_len; $i++)
  1142. {
  1143. push (@salt_arr, get_random_chr ($word_chr_min, $word_chr_max));
  1144. }
  1145. my $salt_buf = join ("", @salt_arr);
  1146. ##
  1147. ## word
  1148. ##
  1149. my $word_len = get_random_num ($word_len_min, $word_len_max - ($salt_len * 2));
  1150. my @word_arr;
  1151. for (my $i = 0; $i < $word_len; $i++)
  1152. {
  1153. push (@word_arr, get_random_chr ($word_chr_min, $word_chr_max));
  1154. }
  1155. my $word_buf = join ("", @word_arr);
  1156. ##
  1157. ## dupe
  1158. ##
  1159. next if exists $dupe{$word_buf};
  1160. $dupe{$word_buf} = undef;
  1161. ##
  1162. ## store
  1163. ##
  1164. print OUTP $word_buf, "\n";
  1165. my $hash_buf = md5_hex ($salt_buf . $word_buf . $salt_buf);
  1166. print OUTH $hash_buf, ":", $salt_buf, "\n";
  1167. $left--;
  1168. }
  1169. close (OUTH);
  1170. close (OUTP);
  1171. unlink ($tmp_out);
  1172. my $rc = system ($hashcat, "-a", "0", "-m", "3810", "-o", $tmp_out, $tmp_hash, $tmp_word);
  1173. comword ($test_num, "rc") if ($rc != 0);
  1174. my $lines = get_lines_in_file ($tmp_out);
  1175. comword ($test_num, "numlines") if ($lines != $num_words);
  1176. }
  1177. }
  1178. ##
  1179. ## test11 : random number of passwords, random word length, random chars, 10 times
  1180. ## : simple out -a 0 -m 2811.
  1181. ##
  1182. sub test11
  1183. {
  1184. my $test_num = 11;
  1185. for (1..$runs_per_test)
  1186. {
  1187. my $num_words = get_random_num ($num_words_min, $num_words_max);
  1188. open (OUTP, ">", $tmp_word) or die ("$tmp_word: $!\n");
  1189. open (OUTH, ">", $tmp_hash) or die ("$tmp_hash: $!\n");
  1190. my %dupe;
  1191. my $left = $num_words;
  1192. while ($left)
  1193. {
  1194. ##
  1195. ## salt
  1196. ##
  1197. my $salt_len = 10;
  1198. my @salt_arr;
  1199. for (my $i = 0; $i < $salt_len; $i++)
  1200. {
  1201. push (@salt_arr, get_random_chr ($word_chr_min, $word_chr_max));
  1202. }
  1203. my $salt_buf = join ("", @salt_arr);
  1204. ##
  1205. ## word
  1206. ##
  1207. my $word_len = 10;
  1208. my @word_arr;
  1209. for (my $i = 0; $i < $word_len; $i++)
  1210. {
  1211. push (@word_arr, get_random_chr ($word_chr_min, $word_chr_max));
  1212. }
  1213. my $word_buf = join ("", @word_arr);
  1214. ##
  1215. ## dupe
  1216. ##
  1217. next if exists $dupe{$word_buf};
  1218. $dupe{$word_buf} = undef;
  1219. ##
  1220. ## store
  1221. ##
  1222. print OUTP $word_buf, "\n";
  1223. my $hash_buf = md5_hex (md5_hex ($salt_buf) . md5_hex ($word_buf));
  1224. print OUTH $hash_buf, ":", $salt_buf, "\n";
  1225. $left--;
  1226. }
  1227. close (OUTH);
  1228. close (OUTP);
  1229. unlink ($tmp_out);
  1230. my $rc = system ($hashcat, "-a", "0", "-m", "2811", "-o", $tmp_out, $tmp_hash, $tmp_word);
  1231. comword ($test_num, "rc") if ($rc != 0);
  1232. my $lines = get_lines_in_file ($tmp_out);
  1233. comword ($test_num, "numlines") if ($lines != $num_words);
  1234. }
  1235. }
  1236. sub test12
  1237. {
  1238. my $test_num = 12;
  1239. for (1..$runs_per_test)
  1240. {
  1241. my $num_words = get_random_num ($num_words_min, $num_words_max);
  1242. open (OUTP, ">", $tmp_word) or die ("$tmp_word: $!\n");
  1243. open (OUTH, ">", $tmp_hash) or die ("$tmp_hash: $!\n");
  1244. my %dupe;
  1245. my $left = $num_words;
  1246. while ($left)
  1247. {
  1248. ##
  1249. ## salt
  1250. ##
  1251. my $salt_len = 10;
  1252. my @salt_arr;
  1253. for (my $i = 0; $i < $salt_len; $i++)
  1254. {
  1255. push (@salt_arr, get_random_chr ($word_chr_min, $word_chr_max));
  1256. }
  1257. my $salt_buf = join ("", @salt_arr);
  1258. ##
  1259. ## word
  1260. ##
  1261. my $word_len = 10;
  1262. my @word_arr;
  1263. for (my $i = 0; $i < $word_len; $i++)
  1264. {
  1265. push (@word_arr, get_random_chr ($word_chr_min, $word_chr_max));
  1266. }
  1267. my $word_buf = join ("", @word_arr);
  1268. ##
  1269. ## dupe
  1270. ##
  1271. next if exists $dupe{$word_buf};
  1272. $dupe{$word_buf} = undef;
  1273. ##
  1274. ## store
  1275. ##
  1276. print OUTP $word_buf, "\n";
  1277. my $hash_buf = md5_hex (md5_hex ($word_buf) . md5_hex ($salt_buf));
  1278. print OUTH $hash_buf, ":", $salt_buf, "\n";
  1279. $left--;
  1280. }
  1281. close (OUTH);
  1282. close (OUTP);
  1283. unlink ($tmp_out);
  1284. my $rc = system ($hashcat, "-a", "0", "-m", "10", "-o", $tmp_out, $tmp_hash, $tmp_word);
  1285. comword ($test_num, "rc") if ($rc != 0);
  1286. my $lines = get_lines_in_file ($tmp_out);
  1287. comword ($test_num, "numlines") if ($lines != $num_words);
  1288. }
  1289. }
  1290. ##
  1291. ## subs
  1292. ##
  1293. sub comword
  1294. {
  1295. my $test_num = shift;
  1296. my $msg = shift;
  1297. die ("$test_num: $msg\n");
  1298. }
  1299. sub get_lines_in_file
  1300. {
  1301. my $file = shift;
  1302. my $count = 0;
  1303. open (IN, $file) or die ("$file: $!\n");
  1304. while (<IN>) { $count++ }
  1305. close (IN);
  1306. return $count;
  1307. }
  1308. sub get_random_num
  1309. {
  1310. my $min = shift;
  1311. my $max = shift;
  1312. return int ((rand ($max - $min)) + $min);
  1313. }
  1314. sub get_random_chr
  1315. {
  1316. return chr get_random_num (@_);
  1317. }