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

  1. .-------------------------------------------------------------------------------------------------.
  2. |Date   : June 26, 2001                                                                          
  3. |
  4. |Target : Praetorian's CrackMe #1 
  5. (http://www.mesa-sys.com/~eternal/m-p/praetoriancm.zip)        |
  6. |Author : Praetorian               (praetorian@nameplanet.com)                                   
  7. |
  8. |Cracker: Bl00dBaTH [pGC/2001]     (Bl00dBaTH@pgc-force.com)                                     
  9. |
  10. |Tools  : IDA + SoftICE                                                                          
  11. |
  12. |Viewer : Notepad/Fullscreen/Wordwrap                                                            
  13. |
  14. ;_________________________________________________________________________________________________;  
  15.  
  16. INTRODUCTION
  17. xxxxxxxxxxxxxx If you read the readme file which comes with this crackme, you'll find
  18. out that there are 3 checks. Since its a keyfile protection, its pretty
  19. safe to assume that the 3 things we need to do are: 1. Find out the name of the keyfile.
  20. 2. Find out the size of the keyfile.
  21. 3. Find out what the keyfile checks. Ok, well thats pretty straight forward. But before we do anything, lets
  22. run our target and see what happens. Boom, the program throws an error
  23. right in our face. Ok, no problem. We could bpx MessageBoxA and check
  24. out what caused this, or we could load it up in a deadlister to get a
  25. good view of whats going on. I chose the deadlisting since we're only
  26. going to analyze the target right now and its a good way to get a clear
  27. look at the code. Alright, lets get down to business.  ANALYSIS OF THE TARGET
  28. xxxxxxxxxxxxxxxxxxxxxxxx A good place to start examining our target, as usual, is to check out
  29. the String References. If you look here, you'll see the following
  30. strings. 1. Xnt.L`cd.Hs-..
  31. 2. Fqd`s.Vnqj-..Mns.sg`s.g`qc.h.ftdrr-.
  32. 3. DQQNQ
  33. 4. Dqqnq.hm.sdrs.$kt
  34. 5. sdrs-sws What the hell is this?? Don't worry, we'll get to that in the next
  35. section...  CRACKING THE TARGET: STEP 1/3
  36. xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx The following is the first snippet of code we should look at in order
  37. to find out whats going on. Its the main code of the program and I'll
  38. reference it several times throughout this essay... Main Code:
  39. ---------------------------------------------------------------------------------------------------
  40.   00401002                 call    j_GetModuleHandleA
  41.   00401007                 mov     dword_40309C, eax
  42.   0040100C                 add     byte_403050, 1
  43.   00401013                 call    sub_40109D           ;Lets see whats
  44. in this call...
  45.   00401018                 jz      short loc_40104C       
  46. --------------------------------------------------------------------------------------------------- 
  47. Inside Call 40109D:
  48. ---------------------------------------------------------------------------------------------------
  49.   0040109D                 lea     edi, ds:40303Bh      ;edi points to
  50. "sdrs-sws".
  51.   004010A3                 call    sub_40113D           ;Another call
  52. here. Lets check it first.
  53. --------------------------------------------------------------------------------------------------- 
  54. Inside Call 40113D:
  55. ---------------------------------------------------------------------------------------------------
  56.   0040113D                 mov     al, [edi]            ;Copy a byte
  57. from edi into al.
  58.   0040113F                 cmp     al, 0                ;All done?
  59.   00401141                 jz      short loc_401150     ;If so then
  60. jump to 401150.
  61.   00401143                 cmp     al, 2Eh              ;al equal to
  62. "."?
  63.   00401145                 jnz     short loc_401149     ;If not jump to
  64. 401149.
  65.   00401147                 mov     al, 1Fh              ;Otherwise put
  66. 1F into al.
  67.  
  68.   00401149                 add     al, 1                ;Add 1 to al.
  69.   0040114B                 mov     [edi], al            ;Put al back
  70. into edi.
  71.   0040114D                 inc     edi                  ;Increase edi
  72. to get the next byte.
  73.   0040114E                 jmp     short sub_40113D     ;Jump to 40113D   00401150                 mov     [edi], al            ;0 Terminate
  74. the string edi points to. (al                                                        
  75. ;will equal 0 when it gets here).
  76.   00401152                 retn                         ;Return To Call
  77. 40109D.
  78. --------------------------------------------------------------------------------------------------- 
  79. Ok, so what the above call does, is add 1 to each character pointed to
  80. by edi, and then 0 terminate it. (Strings must be 0 terminated, that
  81. is, end with a 0). Now that we know this little bit of info, lets go back
  82. to what we were looking at before. Back To Call 40109D:
  83. ---------------------------------------------------------------------------------------------------
  84.   0040109D                 lea     edi, ds:40303Bh      ;edi points to
  85. "sdrs-sws".
  86.   004010A3                 call    sub_40113D           ;The above
  87. routine that decodes the string
  88.                                                         ;pointed to by
  89. edi.
  90.   004010A8                 push    0                   
  91.   004010AA                 push    80h
  92.   004010AF                 push    3
  93.   004010B1                 push    0                   
  94.   004010B3                 push    1                   
  95.   004010B5                 push    80000000h            ;Read access.
  96.   004010BA                 push    40303Bh              ;Keyfile:
  97. test.txt (sdrs-sws = test.txt)
  98.   004010BF                 call    j_CreateFileA        ;Open the file.
  99.   004010C4                 cmp     eax, 0FFFFFFFFh      ;Was the open
  100. successful?
  101.   004010C7                 retn                         ;Return to Main
  102. Code.
  103.  
  104. --------------------------------------------------------------------------------------------------- 
  105. Alright now that we're done having a look at the first check, we know
  106. that the name of our keyfile is test.txt. Lets go back to our main piece
  107. of code and apply our new knowledge. Main Code:
  108. ---------------------------------------------------------------------------------------------------
  109.   00401002                 call    j_GetModuleHandleA
  110.   00401007                 mov     dword_40309C, eax
  111.   0040100C                 add     byte_403050, 1
  112.   00401013                 call    sub_40109D           ;Try to open
  113. test.txt
  114.   00401018                 jz      short loc_40104C     ;If it couldn't
  115. be opened, jump to badguy.
  116. ---------------------------------------------------------------------------------------------------
  117.  We now know how to get past the first check, we must have a keyfile
  118. names test.txt. Now lets move on to the second check...  CRACKING THE TARGET: STEP 2/3
  119. xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Now we'll continue on from where we left off and move on to the second
  120. check. Main Code:
  121. ---------------------------------------------------------------------------------------------------
  122.   00401002                 call    j_GetModuleHandleA
  123.   00401007                 mov     dword_40309C, eax
  124.   0040100C                 add     byte_403050, 1
  125.   00401013                 call    sub_40109D           ;Try to open
  126. test.txt
  127.   00401018                 jz      short loc_40104C     ;If it couldn't
  128. be opened, jump to badguy.
  129.   0040101A                 mov     dword_403044, eax
  130.   0040101F                 add     byte_403050, 1
  131.   00401026                 call    sub_4010C8           ;Lets see whats
  132. in this call...
  133.   0040102B                 jnz     short loc_40104C    
  134. --------------------------------------------------------------------------------------------------- 
  135. Inside Call 4010C8:
  136. ---------------------------------------------------------------------------------------------------
  137.   004010C8                 push    0                   
  138.   004010CA                 push    dword_403044         ;Handle of
  139. test.txt.
  140.   004010D0                 call    j_GetFileSize        ;Get size of
  141. test.txt.
  142.   004010D5                 cmp     eax, 0Ah             ;Is test.txt
  143. equal to 10 bytes?
  144.   004010D8                 retn                         ;Return to Main
  145. Code.
  146. --------------------------------------------------------------------------------------------------- 
  147. Oh yeah, that call was short and sweet. No jumping around. =] Well, we
  148. know now that our keyfiles name is test.txt and that it should be 10
  149. bytes long. We'll reference our main code once more to fill in the blanks
  150. and then move right on to the third and final check. Main Code:
  151. ---------------------------------------------------------------------------------------------------
  152.   00401002                 call    j_GetModuleHandleA
  153.   00401007                 mov     dword_40309C, eax
  154.   0040100C                 add     byte_403050, 1
  155.   00401013                 call    sub_40109D           ;Try to open
  156. test.txt
  157.   00401018                 jz      short loc_40104C     ;If it couldn't
  158. be opened, jump to badguy.
  159.   0040101A                 mov     dword_403044, eax
  160.   0040101F                 add     byte_403050, 1
  161.   00401026                 call    sub_4010C8           ;Get size of
  162. test.txt.
  163.   0040102B                 jnz     short loc_40104C     ;If its not 10
  164. bytes, jump to badguy.
  165. --------------------------------------------------------------------------------------------------- 
  166. We're almost done. Now to finish this up...  CRACKING THE TARGET: STEP 3/3
  167. xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx This is the last check we need to pass and we'll have this crackme
  168. defeated. Lets get to it... Main Code:
  169. ---------------------------------------------------------------------------------------------------
  170.   00401002                 call    j_GetModuleHandleA
  171.   00401007                 mov     dword_40309C, eax
  172.   0040100C                 add     byte_403050, 1
  173.   00401013                 call    sub_40109D           ;Try to open
  174. test.txt
  175.   00401018                 jz      short loc_40104C     ;If it couldn't
  176. be opened, jump to badguy.
  177.   0040101A                 mov     dword_403044, eax
  178.   0040101F                 add     byte_403050, 1
  179.   00401026                 call    sub_4010C8           ;Get size of
  180. test.txt.
  181.   0040102B                 jnz     short loc_40104C     ;If its not 10
  182. bytes, jump to badguy.
  183.   0040102D                 mov     dword_403072, eax
  184.   00401032                 call    sub_4010D9           ;Lets see whats
  185. in this call...
  186.   00401037                 cmp     eax, 1         
  187.   0040103A                 jz      short loc_401045
  188.   0040103C                 add     byte_403050, 1
  189.   00401043                 jmp     short loc_40104C
  190. --------------------------------------------------------------------------------------------------- 
  191. Inside Call 4010D9:
  192. ---------------------------------------------------------------------------------------------------
  193.   004010D9                 push    0
  194.   004010DB                 push    offset unk_403088
  195.   004010E0                 push    4                    ;Read 4 bytes.
  196.   004010E2                 push    offset byte_40307E   ;Buffer to hold
  197. read data.
  198.   004010E7                 push    dword_403044         ;Handle of
  199. test.txt.
  200.   004010ED                 call    j_ReadFile           ;Read test.txt.
  201.   004010F2                 cmp     byte_40307E, 2Dh     ;Is the first
  202. byte equal to "-"?
  203.   004010F9                 jz      short loc_4010FF     ;If so jump to
  204. 4010FF.
  205.   004010FB                 xor     eax, eax             ;Clear eax.
  206.   004010FD                 jmp     short locret_401112  ;Otherwise jump
  207. to badguy.   004010FF                 cmp     byte_40307F, 30h     ;Is the second
  208. byte equal to "0"?
  209.   00401106                 jz      short loc_40110C     ;If so jump to
  210. 40110C.
  211.   00401108                 xor     eax, eax             ;Clear eax.
  212.   0040110A                 jmp     short locret_401112  ;Otherwise jump
  213. to badguy.   0040110C                 mov     eax, 1               ;Set the good
  214. flag.
  215.   00401111                 retn                         ;Return To Main
  216. Code.
  217. --------------------------------------------------------------------------------------------------- 
  218. Now we have all the information we need about the format of the
  219. keyfile: 1. It must be named test.txt.
  220. 2. It must be 10 bytes long.
  221. 3. The first 2 bytes must be -0. An example key would be: -0123456. Lets have a look at our main code now... Main Code:
  222. ---------------------------------------------------------------------------------------------------
  223.   00401002                 call    j_GetModuleHandleA
  224.   00401007                 mov     dword_40309C, eax
  225.   0040100C                 add     byte_403050, 1
  226.   00401013                 call    sub_40109D           ;Try to open
  227. test.txt
  228.   00401018                 jz      short loc_40104C     ;If it couldn't
  229. be opened, jump to badguy.
  230.   0040101A                 mov     dword_403044, eax
  231.   0040101F                 add     byte_403050, 1
  232.   00401026                 call    sub_4010C8           ;Get size of
  233. test.txt.
  234.   0040102B                 jnz     short loc_40104C     ;If its not 10
  235. bytes, jump to badguy.
  236.   0040102D                 mov     dword_403072, eax
  237.   00401032                 call    sub_4010D9           ;Check to see
  238. if the first 2 bytes are -0.
  239.   00401037                 cmp     eax, 1               ;eax equal to
  240. 1?
  241.   0040103A                 jz      short loc_401045     ;If so, jump to
  242. 401045.
  243.   0040103C                 add     byte_403050, 1
  244.   00401043                 jmp     short loc_40104C     ;Otherwise jump
  245. to the badguy message.   00401045                 call    sub_401113           ;Lets see whats
  246. in this call...
  247.   0040104A                 jmp     short loc_401096
  248. --------------------------------------------------------------------------------------------------- 
  249. Inside Call 401113:
  250. ---------------------------------------------------------------------------------------------------
  251.   00401113                 lea     edi, ds:403000h      ;edi points to
  252. "Xnt.L`cd.Hs-.."
  253.   00401119                 call    sub_40113D           ;Call to decode
  254. the above string.
  255.   0040111E                 lea     edi, ds:40300Fh      ;edi points to                                                                                    
  256. ;"Fqd`s.Vnqj-..Mns.sg`s.g`qc.h.ftdrr-."
  257.   00401124                 call    sub_40113D           ;Call to decode
  258. the above string.
  259.   00401129                 push    0
  260.   0040112B                 push    403000h              ;"You Made It."
  261.   00401130                 push    40300Fh              ;"Great Work. 
  262. Not That Hard I Guess."
  263.   00401135                 push    0
  264.   00401137                 call    j_MessageBoxA        ;Goodguy
  265. Message.
  266.   0040113C                 retn                         ;Return To Main
  267. Code.
  268. --------------------------------------------------------------------------------------------------- 
  269. Thats all there is to it, crackme solved. The program uses the same
  270. kind of routine to show the badguy message as well. It decodes the 2
  271. strings and then displays them in a messagebox. Our strings are: 1. Xnt.L`cd.Hs-..                                  -- 
  272. "You Made It."
  273. 2. Fqd`s.Vnqj-..Mns.sg`s.g`qc.h.ftdrr-.            -- "Great Work.  Not
  274. That Hard I Guess."
  275. 3. DQQNQ                                           -- "ERROR"
  276. 4. Dqqnq.hm.sdrs.$kt                               -- "Error in test x"
  277. (Where x is 1, 2 or 3)
  278. 5. sdrs-sws                                        -- "test,txt"  FINAL WORDS
  279. xxxxxxxxxxxxx Well I hope this essay wasn't too hard to follow, and hopefully you got
  280. something out of it. Its a pretty long essay for such a simple crackme,
  281. but I wanted to try to explain as much as possible. =]
  282. Any comments/flames/etc can be sent to me at Bl00dBaTH@pgc-force.com. Greets go out to all my friends, Muad'dib and The+Q for the awesome
  283. crackme site, and of course, Praetorian for the crackme. Thats it for now.
  284. Peace. Bl00dBaTH [pGC/2001]