home *** CD-ROM | disk | FTP | other *** search
/ KeyGen Studio 2002 / KeyGen_Studio_2002.iso / Tutorials / Dos CrackMes / com / SMART5.TXT < prev    next >
Encoding:
Text File  |  1999-08-27  |  8.9 KB  |  247 lines

  1.         . ..:  Smart 5 by ajax - A tutorial by DEATH of Execution  :.. .
  2.             `------------------------------------------------------'
  3.  
  4. Introduction
  5. -------------
  6. I made this tutor because I didn't see any other tutorial considering this
  7. crackme in Eternal Bliss's site (crackmes.cjb.net or surf.to/crackmes) .
  8. I have cracked this crackme long time ago, so I'll just recrack it.. :)
  9.  
  10.  
  11. Greetings
  12. ----------
  13. I'd like to greet Eternal for having such a wonderful crackme site ;)
  14.  
  15.  
  16. Tools
  17. ------
  18. - Notice I will use Turbo Debugger, that's because I am hearing MP3's right now
  19.   and I don't want Soft-ICE to stop'em ;)
  20. - Ajax Smart 5 ;)
  21.  
  22.  
  23. Start
  24. ------
  25. Ok.. Load up the crackme in TD. First you see a jump.. Not interesting :)
  26. The jump brings us to an INT 3h which is the debugger's breakpoint interrupt..
  27. We'll just ignore it..
  28. Now the crackme prints the 'Enter password' string:
  29.     mov dx, 103h                        ; that's the string to print
  30.     mov ah, 9h                          ; PRINT STRING service
  31.     int 21h                             ; do'em
  32.  
  33. Now the crackme will ask for the password:
  34.     mov dx, 131h                        ; Entered Password buffer
  35.     mov ah, 0Ah                         ; GET STRING FROM KEYBOARD service
  36.     int 21h                             ; get'em
  37.  
  38. So.. in the memory view window, we GoTo ds:133h .. Why?
  39.     String buffer structure is like this:
  40.         Name                Type                        Position
  41.         --------------------------------------------------------
  42.         Maximum_Characters  db                          0
  43.         Character_Count     db                          1
  44.         Buffer              db Maximum_Characters       2
  45.  
  46. Check out what's the Maximum_Characters.. It's 5 (+1 for Carriege Return).
  47. By the way, we see the buffer overwrites the code before the GET STRING code..
  48. Now the crackme will move the buffer position to bx:
  49.     mov bx, 131h
  50.  
  51. Now.. A call.. We trace into it, what do we see? 32-bit Registers! No panic..
  52. Just go to the Registers window, right mouse click on it, and choose 32-Bit
  53. Registers option (if it's not already turned on).
  54.  
  55. Here's the procedure:
  56.     mov eax, 0D12345h                   ; eax = 0D12345h (hardcoded)
  57.     mov cx, 10h                         ; ecx = 64 times for loop
  58. loop1:
  59.     xor ax, 2h                          ; eax gets xored by 2
  60.     inc ax                              ; eax++
  61.     cwde                                ; convert word to double word with eax
  62.     loop loop1                          ; till ecx = 0
  63.     dec eax                             ; eax--
  64.     ret                                 ; return from call
  65.  
  66. This just calculates another value for eax.. Seems that ajax wanted to confuse
  67. us thinking it's an important code instead of just putting a 'mov eax, 2354h'.
  68.  
  69. Another call.. here's the procedure:
  70.     mov cx, 0Ah                         ; ecx = 10 times for loop
  71. loop1:
  72.     xor eax, ebx                        ; this xors eax (2354h) by ebx (131h)
  73.     loop loop1                          ; loop tha loop
  74.     ret                                 ; return from call
  75.  
  76. Ok.. First, let me say that if you XOR a value twice by the same number, the
  77. value will be the same.. :)
  78. Since 10 is an even number, eax will stay 2354h.. Another routine to confuse
  79. us..
  80.  
  81. Another call, this time it's an important call, that calculates the checksum
  82. for the password:
  83.     mov cx, 0Ah                         ; ecx = 10 times for loop
  84. loop1:
  85.     xor eax, ebx                        ; xors eax by ebx (131h)
  86.     shr eax, 1                          ; eax gets divided by 2
  87.     loop loop1                          ; loopah
  88.     and eax, 2Ah                        ; eax (0E7h) ANDed with 2Ah
  89.     sub eax, [bx]                       ; eax (22h) gets subtracted by double
  90.                                         ; word of the first four bytes of
  91.                                         ; the entered password buffer
  92.                                         ; (which are the character_max,
  93.                                         ; character count, and two
  94.                                         ; first characters of password)
  95.     sub eax, [bx + 1]                   ; eax gets subtracted by double
  96.                                         ; word of the entered password buffer
  97.                                         ; (which are the character count, and
  98.                                         ; three first characters of password)
  99.     sub eax, [bx + 2]                   ; eax gets subtracted by double
  100.                                         ; word of the entered password buffer
  101.                                         ; (which are the first four characters
  102.                                         ; of the entered password)
  103.     sub eax, [bx + 3]                   ; eax gets subtracted by double
  104.                                         ; word of the entered password buffer
  105.                                         ; (which are four characters of the
  106.                                         ; entered password starting from the
  107.                                         ; second character)
  108.     sub eax, [bx + 4]                   ; eax gets subtracted by double
  109.                                         ; word of the entered password buffer
  110.                                         ; (which are three last characters of
  111.                                         ; the entered password + carriege
  112.                                         ; return byte (0Ah))
  113.     sub eax, [bx + 5]                   ; eax gets subtracted by double
  114.                                         ; word of the entered password buffer
  115.                                         ; (which are last two characters of the
  116.                                         ; entered password + carriege return
  117.                                         ; byte (0Ah) + hardcoded byte '!')
  118.     rol eax, 1                          ; eax gets rotated left by 1
  119.     inc eax                             ; eax++
  120.     ret                                 ; return from call
  121.  
  122. Phew.. Read it until you get it..
  123.  
  124. After the call, ax (lower word of eax) gets compared with an hardcoded value
  125. of 0B4E3h and if it's equal, then we have succeeded to crack it :)
  126.  
  127. So how do we get a valid password?  We have two options:
  128.     1> Reverse the checksum (might take a little brain-effort)
  129.     2> Brute (easier.. 5 characters + 16-bit checksum.. fast too)
  130.  
  131. This time I have chosen the second option since I am having a little
  132. headache..
  133.  
  134. Brute forcer code
  135. ------------------
  136. Ok.. here's my source of the bruteforcer, of course you could make it better
  137. and use it on other crackmes, but it's good for Smart 5.. It's good for us :)
  138.  
  139. --cut here--
  140. ; Solve to ajax's Smart 5 crackme
  141. ; (c)1999 by DEATH of Execution
  142. ;
  143. ; Brute force attack
  144. ; -------------------
  145. ; This crackme needed only 5 printable characters and had a 16bit checksum
  146. ; value, so I realized it wouldn't take much long before I could crack it..
  147. ; Phun, eh?
  148. ;
  149. ; This will crack for printable chars.
  150. ;
  151. .model tiny
  152. .386p
  153. .code
  154.     org 100h
  155. start:
  156.     lea ebx, passbuf
  157.  
  158.     mov byte ptr ch1, ' ' - 1
  159.  
  160. ch1loop:
  161.     mov byte ptr ch2, ' ' - 1
  162.     mov byte ptr ch3, ' ' - 1
  163.     mov byte ptr ch4, ' ' - 1
  164.     mov byte ptr ch5, ' ' - 1
  165.  
  166.     inc byte ptr ch1
  167.     cmp byte ptr ch1, '~' + 1
  168.     jae nofound
  169.  
  170. ch2loop:
  171.     mov al, '.'
  172.     int 29h
  173.  
  174.     mov byte ptr ch3, ' ' - 1
  175.     mov byte ptr ch4, ' ' - 1
  176.     mov byte ptr ch5, ' ' - 1
  177.  
  178.     inc byte ptr ch2
  179.     cmp byte ptr ch2, '~' + 1
  180.     jae ch1loop
  181.  
  182. ch3loop:
  183.     mov byte ptr ch4, ' ' - 1
  184.     mov byte ptr ch5, ' ' - 1
  185.  
  186.     inc byte ptr ch3
  187.     cmp byte ptr ch3, '~' + 1
  188.     jae ch2loop
  189.  
  190. ch4loop:
  191.     mov byte ptr ch5, ' ' - 1
  192.  
  193.     inc byte ptr ch4
  194.     cmp byte ptr ch4, '~' + 1
  195.     jae ch3loop
  196.  
  197. ch5loop:
  198.     inc byte ptr ch5
  199.     cmp byte ptr ch5, '~' + 1
  200.     jae ch4loop
  201.  
  202.     mov eax, 22h                        ; magic value
  203.     sub eax, [ebx]
  204.     sub eax, [ebx + 1]
  205.     sub eax, [ebx + 2]
  206.     sub eax, [ebx + 3]
  207.     sub eax, [ebx + 4]
  208.     sub eax, [ebx + 5]
  209.     rol eax, 1
  210.     inc eax
  211.  
  212.     cmp ax, 0B4E3h                      ; checksum value
  213.     jne ch5loop
  214.  
  215.     mov byte ptr endtext, 0Ah
  216.     mov ah, 9
  217.     lea dx, ch1
  218.     int 21h
  219.     mov byte ptr endtext, '!'
  220.     jmp ch5loop
  221.  
  222. nofound:
  223.     int 20h
  224.  
  225.  
  226. passbuf db 06h                          ; Maximum chars
  227.         db 05h                          ; entered chars
  228. ch1     db ?
  229. ch2     db ?
  230. ch3     db ?
  231. ch4     db ?
  232. ch5     db ?
  233. endtext db '!'                          ; hardcoded
  234.         db 0Dh
  235.         db '$'
  236. end start
  237. --stop cutting here--
  238.  
  239. I threw the output to file, and tried to 'fish' readable words of passwords..
  240. I have found a good password: 'Sorry' .. Tried it, it worked..
  241.  
  242. Now go ahead and crack Smart 6.. Hope this tut was good :)
  243.  
  244.                                                 - DEATH of Execution in 1999
  245.                                                      <ab4ds@hotmail.com>
  246.  
  247.