home *** CD-ROM | disk | FTP | other *** search
/ KeyGen Studio 2002 / KeyGen_Studio_2002.iso / Tutorials / CrackMesCbjNet / death_magic.txt < prev    next >
Encoding:
Text File  |  2001-09-21  |  3.6 KB  |  137 lines

  1. (extracted from DEATH's email:)
  2. -----------------
  3.  
  4. Well it's pretty hard to have a programme like that, that will also work with
  5. this specific cryptogram,
  6. since there are too few characters to do a statistical analysis (refer to LANAKI
  7. cryptogram lessons :) and single character statistical analysis was out of the
  8. question (transposition cipher).
  9.  
  10. --------------------
  11.  
  12. I already tried some rules so I thought, hey an english sentence can start with a
  13. parenthesis :)
  14.  
  15. PPS: Hehe.. Serial: 5706498132
  16.  
  17. ---------------------------------
  18.  
  19. #include <stdio.h>
  20. #include <stdlib.h>
  21. #include <string.h>
  22.  
  23. char *permute( char *strng, int length);
  24.  
  25. void crypt(char *src, char *passphrase, char *dst)
  26. {
  27.     short count;
  28.     short count2;
  29.     short index;
  30.  
  31.     for (count = 0; count < 10; count++) {
  32.         index = (passphrase[count] - '0') * 0x0E;
  33.         for (count2 = 0; count2 < 0x0E; count2++) {
  34.             dst[count2 * 10 + count] = src[index + count2];
  35.         }
  36.     }
  37. }
  38.  
  39. void main(void)
  40. {
  41.     char cryptogram[] = "r  whlyeo l r.r nih\"h Lan ,idthy iru Dedforaeio
  42. renShLhe t k ttliy i he osiso\"saauet. ei  ualsy lna ,i.rb foylhewmsolzosdaa
  43. eusIeHwd.aywaeuC\0xD\0xA\0xD$";
  44.     char dest[512];
  45.     char *passphrase = "0123456789";
  46.     char dest2[512];
  47.  
  48.     memset(dest, 0, sizeof(dest));
  49.     memset(dest2, 0, sizeof(dest));
  50.  
  51.     passphrase = permute(passphrase, 10);
  52.  
  53.     do {
  54.         crypt(cryptogram, passphrase, dest);
  55.         crypt(dest, passphrase, dest2);
  56.         if (dest2[0] == '"' && dest2[139] == '.' && strstr(dest2, ", ") &&
  57. (strstr(dest2, " \"") == NULL)) {
  58.             if (isupper(dest2[1])) {
  59.                 printf("%s\n", dest2);
  60.                 printf("%s\n\n", passphrase);
  61.             }
  62.         }
  63.     } while (passphrase = permute(NULL, 10));
  64. }
  65.  
  66. /*  permute ( char *strng, int length) returns a pointer to a permuted */
  67. /*  string, first call, call with string and origonal string is returned */
  68. /*  each subsiquent call, call with NULL, returns one permutation */
  69. /*  calls after all permuataions have been returned return NULL */
  70. /*  ( always call with strlen(string) as length )  */
  71. /*  will return NULL for errors  */
  72. /*  not very defensive ( ie WILL BREAK  ) */
  73.  
  74. /*  dave chapman july '91  released to public domain  */
  75.  
  76. char *permute( char *strng, int length);
  77.  
  78. char *permute( char *strng, int length)
  79. {
  80. char c;
  81. static int level;
  82. static char *str;
  83. static char *curr;
  84. static int  *counts;
  85.  
  86. if ( 0 >= length ) return NULL;
  87. if ( NULL != strng )
  88.    {
  89.    str = malloc( length+1 );         /* first call, copy string for use */
  90.    counts = calloc( length, sizeof(int) );  /* where are we? */
  91.  
  92.    /* str = calloc( length+1, sizeof(int) + 1 );  and some manipulation
  93.    lets the caller free this memory  */
  94.  
  95.    strcpy( str, strng );
  96.    curr = str;
  97.    level = 0;
  98.    return str;
  99.    }
  100. if ( 2 == length )
  101.    {
  102.    c = *curr;             /* rotate last 2 chars */
  103.    *curr = *(curr+1);
  104.    *(curr+1) = c;
  105.    (*(counts+level))++;  /* <- I thought *(counts+level)++ would inc */
  106.           /*  the counter, it didn't  comment? */
  107.    }
  108.    else
  109.    {                     /* go down one level */
  110.    curr++;
  111.    level++;
  112.    if ( NULL == permute( NULL, length-1 ))
  113.       {
  114.       c = *(--curr);         /* done lower levels, rotate this one  */
  115.       memmove( curr, curr+1, length-1 );
  116.       *(curr + length-1) = c;
  117.       (*(counts + --level))++;
  118.       }
  119.       else
  120.       {
  121.       --curr;
  122.       --level;
  123.       }
  124.    }
  125. if ( *(counts+level) >= length )
  126.    {
  127.    *(counts+level) = 0;             /* reset it */
  128.    return NULL;                     /* done here */
  129.    }
  130. return str;              /* still some left */
  131. }
  132.  
  133.  
  134. ------------------
  135. Cya.. DEATH
  136.  
  137.