home *** CD-ROM | disk | FTP | other *** search
/ Cracking 2 / Cracking II..iso / Texty / crackme / HOTDOG.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1997-01-15  |  5.0 KB  |  164 lines

  1. /*
  2. Solution / Keygen source to Hotdog's Crackme #1
  3. -----------------------------------------------
  4.  
  5. Written by Prophecy [tNO] (27th July 1998)
  6. ------------------------------------------
  7.  
  8. BTW , if you have any questions you'd like to ask, or any errors to point out, feel
  9. free to email me : prophecy_@usa.net OR catch me in #cracking4newbies in EFNET.
  10.  
  11. Well I promised my friend i'd crack this by 10pm tonight otherwise he'd be asleep,
  12. so if you see any mistakes it was coz i'm in a rush to finish it (it's 8:54pm
  13. already!)
  14.  
  15. Cracking techniques
  16. -------------------
  17.  
  18. I used bpx multibytetowidechar to break into the target, type dd esp to examine
  19. the stack and hence work out where my padded name / regcode would be stored - read
  20. your api reference!
  21.  
  22. As this is a visual basic not much can be said -- you need a fair bit of
  23. experience so that you can separate the VB shit from the actual code
  24. generating algo - newbies would get too scared so much VB code and the fact
  25. that VB copies your name/code to about 1000000 locations in memory before
  26. it finally does anything about it.
  27.  
  28. Anyway : here are a couple of addresses that bring you bang in the middle of the
  29. code algorithm (you have to type ADDR codeman before you enter it, and to enter
  30. it type bpx <address>)
  31.  
  32. Note : read next session : the protection scheme itself before reading my commments in ()
  33.  
  34. 417235 ( you should see your mapped character , and you should see the _vbaadd something
  35.          command.  Note if you trace long enough you will see your name being looked
  36.          up in the table using the REPZ CMSB command to check if it's found your letter
  37.          in the table yet )
  38.  
  39. 417296 ( the final comparison )
  40.  
  41. the protection scheme itself
  42. ----------------------------
  43.  
  44. as i already said the main prob is finding the shit in Sofitce -- for some reason,
  45. i dunno why as Hotdog told me he had no anti smartcheck tricks, this crackme
  46. crashed smartcheck -- nice one hotdog :) , which forced me to use Softice, but being
  47. a man i can handle it.
  48.  
  49. 1) first, your name is converted to uppercase.
  50.  
  51. then it manipulates your name in the following fashion:
  52.  
  53. if you entered a A (0x41) (gets mapped to) -> e (0x65)
  54.                  B (0x42)                  -> f (0x66)
  55.                  C (0x43)                  -> g (0x67)
  56.                  .
  57.                  .
  58.                  Z (0x5a)                  -> ~ (0x7e)
  59.  
  60. so basically all that happens is that 0x24 is added to the chars of your name.
  61.  
  62. if the char you enter is not found in the table, then the value 0x7f is used.
  63.  
  64. btw, i tried to find the table the crackme was using for the mapping, and to
  65. my amusement i saw this:
  66.  
  67. test ax,ax
  68. mov [ebp-7c], 00000065
  69. .
  70. test ax,ax
  71. mov [ebp-7c], 00000066
  72. .
  73. test ax,ax
  74. mov [ebp-7c], 00000067
  75. .
  76. .
  77. .
  78. test ax,ax
  79. mov [ebp-7c], 0000007e
  80. .
  81. test ax,ax
  82. mov [ebp-7c], 0000007f
  83.  
  84. talk about bad programming style! i would done something like add xx,0x24
  85. where xx is the mapped char. with an if statement to check if it's a letter.
  86.  
  87. anyway, back to the algo : i entered Prophecy, which gets converted to
  88. upper case -> PROPHECY.  Then the chars get mapped to give me tvstlig}.
  89.  
  90. the individual letters of the new code "tvstlig}" are added together, ie
  91.  
  92. 0x74+0x76+0x73+0x74+0x6c+0x69+0x67+0x7d = 0x38a.
  93.  
  94. then the code adds the value 0x989680, which is exactly 10 000 000, hence explaining
  95. the 8 digit nature of the valid code.
  96.  
  97. this gives : 10 000 906  (0x38a = 906d)
  98.  
  99. as a final touch, the length of your name is added to this figure to give:
  100.  
  101. 10 000 906 + 8 = 10 000 914 <--- valid code for "PROPHECY" !!
  102.  
  103. So writing a keygen should be a trivial exercise (it's 9:20, which gives me 40 mins
  104. ... so let's rock!)
  105.  
  106. */
  107.  
  108. #include <stdio.h>
  109. #include <string.h>
  110. #include <conio.h>
  111. #include <ctype.h>
  112.  
  113. int main(){
  114.  
  115. unsigned char name[500]={0};
  116. unsigned long code=0;
  117. unsigned int i,len;
  118.  
  119. for(;;){
  120.    clrscr();
  121.    printf("┌─────── ░ ─── ▄ ─────── ░ ────────────┐\n");
  122.    printf("■▀██▓▀███▓▀██▓▀██▓▄   ▄▓█▓ ▀▓██▓▀███▓▀ │\n");
  123.    printf("│  ▀░ ███▓ █░  ███▀▓▄ ███▓  ███▓ ███▓  │\n");
  124.    printf("│    ░███▓    ░███  █████▓ ░███▓ ███▓  │\n");
  125.    printf("│   ▄▓███▓▄  ▄▓███▓▄ ▀▓██▓▄▓███▓▄▓██▓▄ │\n");
  126.    printf("└───────────────────── ▀▀▓ ────────────┘\n");
  127.    printf("\nKey Generator for Hotdog's Crackme #1");
  128.    printf("\nWritten by Prophecy (27th July 1998)\n\n");
  129.    printf("Please enter your name ...: ");
  130.    gets(name);
  131.  
  132.    /* calculate length of name */
  133.    len=strlen(name);
  134.  
  135.    if(len<5 || len>29){ /* name must be >= or <= 29 chars -- this is given to you when you try and enter a name of invalid length by the prog */
  136.        printf("\nYour name contains an invalid amount of characters... try again.");
  137.       getch();
  138.    }
  139.    else break;
  140. }
  141.  
  142. for(i=0;i<len;i++){
  143.    name[i]=toupper(name[i]);
  144. }
  145.  
  146. for(i=0;i<len;i++){
  147.    if(name[i] < 'A' || name[i] > 'Z'){
  148.       name[i]=0x7f;
  149.    }
  150.    else name[i]+=0x24;
  151. }
  152.  
  153. for(i=0;i<len;i++){
  154.    code+=name[i];
  155. }
  156.  
  157. code+=10000000LU;
  158. code+=len;
  159.  
  160. printf("Your code is: ............: %lu",code);
  161. /* ok 9:42pm , plenty of time :) */
  162. }
  163.  
  164.