home *** CD-ROM | disk | FTP | other *** search
/ Reverse Code Engineering RCE CD +sandman 2000 / ReverseCodeEngineeringRceCdsandman2000.iso / RCE / E_bliss / phox_scrackme5.1.txt < prev    next >
Text File  |  2000-05-25  |  7KB  |  212 lines

  1. Tutorial by Mr. Squash, mrsquash0@hotmail.com
  2. Written by a newbie
  3.  
  4. Purpose:
  5. To show how to calculate a valid s/n for PhoX's crackme 5.1
  6.  
  7. By bpx getwindowtexta you will easily find the protection. After si breaks push F11:
  8. (code ripped with w32dasm)
  9.  
  10. * Reference To: USER32.GetWindowTextA, Ord:0000h
  11. :0040119E E800010000              Call 004012A3
  12. :004011A3 FF3544204000            push dword ptr [00402044]    <- you will end up here
  13. :004011A9 E85D000000              call 0040120B            ;check if the serial is valid
  14. :004011AE 83F801                  cmp eax, 00000001
  15. :004011B1 751E                    jne 004011D1
  16. :004011B3 6A30                    push 00000030
  17.  
  18. * Possible StringData Ref from Data Obj ->"Good For U!"        ;Well, looks like if eax=1 the
  19. :004011B5 6881204000              push 00402081            ;serial is valid
  20. * Possible StringData Ref from Data Obj ->"U Did It!!"
  21. ..
  22.  
  23. ************************
  24.  
  25. Check_If_The_Serial_Is_Valid:
  26. :0040120B C8000000                enter 0000, 00
  27. :0040120F 53                      push ebx
  28. :00401210 52                      push edx
  29. :00401211 33C0                    xor eax, eax
  30. :00401213 B8A6204000              mov eax, 004020A6        ;eax=the serial that you entered
  31. :00401218 803800                  cmp byte ptr [eax], 00    ;any serial entered?
  32. :0040121B 7460                    je 0040127D
  33. :0040121D 33DB                    xor ebx, ebx
  34. :0040121F 33D2                    xor edx, edx
  35.  
  36. Lp:
  37. :00401221 8A18                    mov bl, byte ptr [eax]    ;get letter from string
  38. :00401223 C1C308                  rol ebx, 08            ;<< 8, ex. 00000031 -> 00003100
  39. :00401226 03D3                    add edx, ebx            ;add this value to edx
  40.  
  41. :00401228 40                      inc eax
  42. :00401229 803800                  cmp byte ptr [eax], 00
  43. :0040122C 75F3                    jne Lp
  44.  
  45.  
  46.  
  47. :0040122E 52                      push edx            ;value to convert, ex. 8e910281 -> '8e910281'
  48.  
  49. * Possible StringData Ref from Data Obj ->"%lX"
  50. :0040122F 6854204000              push 00402054
  51. :00401234 68BF204000              push 004020BF            ;buffer to hold the converted value
  52.  
  53. * Reference To: USER32.wsprintfA, Ord:0000h
  54. :00401239 E88F000000              Call 004012CD            ;conv the hex value in edx to ascii
  55.  
  56. :0040123E BBBF204000              mov ebx, 004020BF        ;ebx points to our converted string
  57.  
  58.  
  59. * What the following lines does is to check if our converted string match this string: '8DCAF368' (right s/n)
  60. * - if this is the case, the serial is valid...
  61.  
  62. :00401243 803B38                  cmp byte ptr [ebx], 38    ;8
  63. :00401246 7535                    jne 0040127D
  64. :00401248 807B0144                cmp byte ptr [ebx+01], 44    ;D
  65. :0040124C 752F                    jne 0040127D
  66. :0040124E 807B0243                cmp byte ptr [ebx+02], 43    ;...
  67. :00401252 7529                    jne 0040127D
  68. :00401254 807B0341                cmp byte ptr [ebx+03], 41
  69. :00401258 7523                    jne 0040127D
  70. :0040125A 807B0446                cmp byte ptr [ebx+04], 46
  71. :0040125E 751D                    jne 0040127D
  72. :00401260 807B0533                cmp byte ptr [ebx+05], 33
  73. :00401264 7517                    jne 0040127D
  74. :00401266 807B0636                cmp byte ptr [ebx+06], 36
  75. :0040126A 7511                    jne 0040127D
  76. :0040126C 807B0738                cmp byte ptr [ebx+07], 38    ;8
  77. :00401270 750B                    jne 0040127D
  78. :00401272 B801000000              mov eax, 00000001        ;eax=1, serial is valid
  79. :00401277 5A                      pop edx
  80. :00401278 5B                      pop ebx
  81. :00401279 C9                      leave
  82. :0040127A C20400                  ret 0004
  83.  
  84. ****
  85.  
  86. :0040127D 33C0                    xor eax, eax            ;eax=0, sorry serial is NOT valid
  87. :0040127F 5A                      pop edx
  88. :00401280 5B                      pop ebx
  89. :00401281 C9                      leave
  90. :00401282 C20400                  ret 0004
  91.  
  92.  
  93.  
  94. These 3 lines of code creates the value from the entered input:
  95.  
  96. :00401221 8A18                    mov bl, byte ptr [eax]    ;get letter from string
  97. :00401223 C1C308                  rol ebx, 08            ;<< 8, ex. 00000031 -> 00003100
  98. :00401226 03D3                    add edx, ebx            ;add this value to edx
  99.  
  100.  
  101. We know that we must end up with a value in edx that match 8DCAF368
  102.  
  103.  
  104. Example, if we enter '1234567' as serial, we end up with this value :
  105.  
  106.     edx=00000000
  107.     ebx=00000000
  108.  
  109. Pass 1: Add '1' = 31h
  110.     ebx=00000031    ;mov bl, byte ptr [eax]
  111.     ebx=00003100    ;rol ebx, 08
  112.     edx=00003100    ;add edx, ebx
  113. Pass 2: Add '2' = 32h
  114.     ebx=00003132
  115.     ebx=00313200
  116.     edx=00316300
  117. Pass 3: Add '3' = 33h
  118.     ebx=00313233
  119.     ebx=31323300
  120.     edx=31639600
  121. Pass 4: Add '4' = 34h
  122.     ebx=31323334
  123.     ebx=32333431
  124.     edx=6396CA31
  125. Pass 5: Add '5' = 35h
  126.     ebx=32333435
  127.     ebx=33343532
  128.     edx=96CAFF63
  129. Pass 6: Add '6' = 36h
  130.     ebx=33343536
  131.     ebx=34353633
  132.     edx=CB003596
  133. Pass 7: Add '7' = 37h
  134.     ebx=34353637
  135.     ebx=35363734
  136.     edx=00366CCA <- Final value
  137.  
  138.  
  139. Our problem is now to go from 00366CCA to the original string from which this value was calculated (ie. reversing the protection scheme). With the knowledge that I have gathered so far (remember, I'm a newbie..) I cannot see how this can be done - If I should be wrong here I would like very much to hear from you, I can be reached via my email address: mrsquash0@hotmail.com.
  140.  
  141. Our problems are: When we load a new digit/letter in ebx we erase whatever value that was here before (ie. the lower 8 bits of ebx are changed - with no relation to what it was before). Another problem is that we go beyond the limit of edx, ie. ffffffff, and start over from 0.
  142.  
  143. But there is a solution to our problem, because this type of protection can have more than 1 valid s/n. For this crackme a valid s/n can be computed like this:
  144.  
  145. 8D CA F3 68 <- the value found in the crackme
  146.    |__|_
  147.     __| |
  148.    |    |
  149.    F3 - CA = 29 = ')'
  150.  
  151. ***
  152.  
  153. Then I perform two logical operands on this value:
  154.  
  155. 1) ror 8
  156. 2) and ffffffff00h (-100h)
  157.  
  158. After this I get:
  159.  
  160. 68 8D CA 00
  161.    |__|_
  162.     __| |
  163.    |    |
  164.    CA - 8D = 3D = '='
  165.  
  166. ***
  167.  
  168. 1) ror 8
  169. 2) and ffffffff00h (-100h)
  170.  
  171. 00 68 8D 00
  172.    |__|_
  173.     __| |
  174.    |    |
  175.    8D - 68 = 25 = '%'
  176.  
  177. ***
  178.  
  179. 1) ror 8
  180. 2) and ffffffff00h (-100h)
  181.  
  182. 00 00 68 00
  183.    |__|_
  184.     __| |
  185.    |    |
  186.    68 - 00 = 68 = 'h'
  187.  
  188.  
  189. ***
  190.  
  191. 1) ror 8
  192. 2) and ffffffff00h (-100h)
  193.  
  194. 00 00 00 00
  195.  
  196. DONE
  197.  
  198.  
  199. So from this I get: ')=%h' - reverse this and it is a valid serial. This means that if you enter 'h%=)' (without quotes) as the s/n you'll get the goood messagebox saying that you're a goood cracker :)
  200.  
  201.  
  202. Problem by solving the problem like this:
  203.  
  204. If the program had some disabled functions that would only be available in the registered version and the code within these functions were encrypted with a key from another s/n calculation routine (with the original s/n string as starting point) we would have a serious problem. Because the valid s/n we have calculated would NOT give the same result as the original s/n if it was to put through another algorithm.
  205.  
  206.  
  207.  
  208. I repeat: I am not 100% (only 99%) sure that you cannot (in some way) go from 8DCAF368 to the original string that this value was computed from. If you know of a way, you are MORE than welcome to send me a mail : mrsquash0@hotmail.com , thanks !
  209.  
  210.  
  211.  
  212.