Advertisement
Guest User

zodiac.pl

a guest
Jun 22nd, 2011
6,635
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 4.63 KB | None | 0 0
  1. #!/usr/bin/perl
  2. ## z340crack written by BJP
  3. ##
  4. ## This script attempts to brute-force crack Quadrant 3 of the Zodiac killer's "Z340" cipher.
  5. ##
  6. $|=1;
  7. ## 1 = Backward B
  8. ## 2 = Left half filled circle
  9. ## 3 = Filled P
  10. ## 4 = Filled circle
  11. ## 5 = Backward C
  12. ## 6 = Circle with vertical line
  13. ## 7 = Butt, left dimple
  14. ## 8 = Filled triangle
  15. ## 9 = Backward P
  16. ## = = Upside-down T
  17. ## # = Backward F
  18. ## % = Backward Q
  19. ## & = Top half filled circle
  20. ## : = Backward L
  21. ## ; = Circle with horizontal line
  22. ## ' = / Forward slash
  23. ## { = Square
  24. ## } = Southwest filled square
  25. ## _ = Caret
  26. ## X = Plus sign
  27. ## ] = Dot
  28. ##
  29. ##
  30. ## Ciphertext block:    YB91TMKO
  31. ##                      T2M]X3BF
  32. ##                      4FB5678R
  33. ##                      1]5V2=XX
  34. ##                      E>VUZ4-X
  35. ##                      9_]#M%G&
  36. ##                      XF:WBI;L
  37. ##                      OSHT'6;9
  38. ##                      {YOB}-C5
  39. ##                      ZO8AIK7X
  40. ##
  41. ##                      
  42.  
  43. ##
  44. ## One liner:  YB91TMKOT2M]X3BF4FB5678R1]5V2=XXE>VUZ4-X9_]#M%G&XF:WBI;LOSHT'6;9{YOB}-C5ZO8AIK7X
  45. ##
  46.  
  47.  
  48.  
  49. $z=0;
  50.  
  51. while ($z>=0)
  52. {
  53.         $#table=-1;
  54.  
  55.         $normalAlphabet="abcdefghijklmnopqrstuvwxyz";
  56.         $zodiacAlphabet="=>_-;:']{}&#%123456789ABCEFGHIKLMORSTUVWXYZ";
  57.         $cipherText="YB91TMKOT2M]X3BF4FB5678R1]5V2=XXE>VUZ4-X9_]#M%G&XF:WBI;LOSHT'6;9{YOB}-C5ZO8AIK7X";
  58.  
  59.         $oldZ=$zodiacAlphabet;
  60.  
  61.         $x=0;
  62.  
  63.         while($x<100)  ### Scramble the alphabet so that symbol selection is random. 100 iterations should do.
  64.         {
  65.  
  66.                 $offset=int(rand(length($zodiacAlphabet))); ## Pick a symbol somewhere in the string..
  67.                 $offset--;
  68.                 $splitter=substr($zodiacAlphabet,$offset,1);
  69.                 $zodiacAlphabet=~/$splitter/;
  70.                 $zodiacAlphabet=$'."$splitter".$`; # Swap the right half and the left half of the match..
  71.                 $x++;
  72.         }
  73.  
  74.         $x=0;
  75.  
  76.         while ($x<length($zodiacAlphabet))
  77.         {
  78.                 $l=length($zodiacAlphabet);
  79.                 $thisSymbol=substr($zodiacAlphabet,$x,1);
  80.                 $letter=int(rand(length($normalAlphabet)));
  81.                 $table[$letter].="$thisSymbol";
  82.                 $x++;
  83.         }
  84.  
  85.         ## The table has now been built. All letters in the normal alphabet now have a random number of zodiac symbols assigned to them.
  86.  
  87.         $x=0;
  88.         $x=0;
  89.         $y=0;
  90.  
  91.  
  92.         while ($x<length($normalAlphabet)) ## For every letter of the normal alphabet, replace the symbols assigned to it in the cipher.
  93.         {
  94.                 $thisLetter=substr($normalAlphabet,$x,1);
  95.  
  96.                 $y=0;
  97.  
  98.                 while($y<length($table[$x]))
  99.                 {
  100.                         $thisSymbol=substr($table[$x],$y,1);
  101.                         $cipherText=~s/$thisSymbol/$thisLetter/g;
  102.                         $y++;
  103.                 }
  104.  
  105.                 $x++;
  106.         }
  107.  
  108.         $z++;
  109.  
  110.         ## Look for pay dirt..
  111.  
  112.         @signalWords=("children","others","around","shall","about","people","would","missed","police","because","thing","there","could","rather","light","school","vallejo","useing","triger","howers","cerous","meannie","killed","victom","speaking","lyeing","slaves","afterlife","zodiac","intersting","idenity","woeman","untill");
  113.  
  114.  
  115.         foreach $signal (@signalWords)
  116.         {
  117.                 if ($cipherText=~/$signal/)
  118.                 {
  119.                         $signalValue++;
  120.                         $signalsFound.=" $signal";
  121.                 }
  122.  
  123.  
  124.         }
  125.  
  126.         if ($z%9==0)
  127.         {
  128.                 print "Processing: Pass #$z [$cipherText]\r";
  129.         }
  130.  
  131.         if ($signalValue>=3)
  132.         {
  133.                 print "\n\n\nMATCH FOUND: $cipherText (Count: $signalValue, $signalsFound ), cycle $z\n\n";
  134.  
  135.                 open (FILE,">>/tmp/zodiac.txt");
  136.                 print FILE "\n\n\nMATCH FOUND: $cipherText (Count: $signalValue, $signalsFound ), pass $z\n\n";
  137.  
  138.  
  139.                 $x=0;
  140.  
  141.                 while ($x<length($normalAlphabet))
  142.                 {
  143.                         $thisLetter=substr($normalAlphabet,$x,1);
  144.                         print "\t$thisLetter equals ($table[$x])";
  145.                         print FILE "\t$thisLetter equals ($table[$x])";
  146.                         if ($x%4==0 && $x>0)
  147.                         {
  148.                                 print "\n";
  149.                                 print FILE "\n";
  150.                         }
  151.                         $x++;
  152.                 }
  153.  
  154.         close (FILE);
  155.  
  156.         print "\n\n";
  157.  
  158.         }
  159.  
  160.         $signalValue=0;
  161.         $signalsFound="";
  162.         $signal="";
  163.  
  164. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement