home *** CD-ROM | disk | FTP | other *** search
/ Cracking 2 / Cracking II..iso / Texty / crackme / boo.asm < prev    next >
Encoding:
Assembly Source File  |  1999-05-31  |  6.1 KB  |  172 lines

  1. ; R!SC 191198
  2. ; asm stylee!!!
  3.  
  4. ; <_risc> well, your a good bloke.. thx for the second opinion (can i have it in writing please..)
  5. ; <josephCo> haha
  6. ; <_risc> got it..
  7. ; <_risc> <josephCo> the total combinations are 2^18
  8. ; <_risc> <josephCo> which is 262144
  9. ; * josephCo writes "it's 2^18 possible combinations"
  10. ; * josephCo writes "which is 262144"
  11. ; <josephCo> :)
  12. ; <josephCo> there you go
  13.  
  14. ; theory behind R!SC's Matrix Brute Forcer (r)
  15.  
  16. ; we have 18 check boxes, can be either 'checked' or 'unchecked' (1 or 0) 
  17. ; (apparantly, the amount of diff combo's is square of 18, 324??? so where i come up with 262,144 :)
  18.  
  19. ; we also have a way of testing single 'bits' in a value, by using 'TEST dest, src'
  20. ; i use a 18bit binary value (well, 32bit binary value, but only use the TEST on the first
  21. ; 18 bits of it...) (i'll refer to this as my MAGIC NUMBER)
  22.  
  23. ; i start the MAGIC NUMBER with the first bit set, (01h) then do the maths, check the result,
  24. ; if it doesnt find the correct answer, we increase the MAGIC NUMBER by 1, and check again....
  25.  
  26. ; examples of the MAGIC NUMBER, and how it represents the matrix of check boxes....
  27.  
  28. ; 000000000000000001 = 01h = box 1 checked, 2-18 unckecked, simulate the maths, check the results
  29. ; 000000000000000010 = 02h = box 2 checked, 1,3-18 unchecked
  30. ; 000000000000000011 = 03h = box 1,2 checked, 3-18 unckecked
  31. ; 000000000000000100 = 04h = box 3 checked, 1,2,4-18 unchecked
  32. ; 000000000000000101
  33. ; 000000000000000110
  34. ; 000000000000000111 = 07h = box 1-3 checked, 4-18 unchecked...
  35. ; 000000000000001000
  36. ; 000000000000001001
  37.  
  38. ; 101000110101000110 = 028d46h = box 2,3,7,9,11,12,16,18 checked
  39. ;                                 box 1,4,5,6,8,10,13,14,15,17 unchecked
  40. ; 111111111111111111 = 03ffffh = box 1-18 checked...
  41.  
  42.  
  43. ; to find out if a bit is set or not, i use another 18bit (32bit :) value, with only one bit
  44. ; set in it (i'll call this X)
  45.  
  46. ; TEST MAGIC NUMBER, X    ; see if bit 'X' is set in the magic number
  47. ; JNZ CHECKED            ; if bit 'X' is not '0' jump to calculation routine
  48.  
  49. ; which will check bit X in the MAGIC NUMBER, and alter the ZERO flag accordingly
  50. ; i.e, bit X is 0, zero flag is set, bit X is 1, zero flag is cleared...
  51.  
  52. ; X gets shifted to the left by 1 bit, the counter increased, check the counter, if its equal
  53. ; to 18, we have checked every bit in the MAGIC NUMBER, and have to loop back to check our result
  54. ; erm... still with me??
  55.  
  56. ; examples of X
  57.  
  58. ; 000000000000000001 = bit 1 set = 01h, counter = 0
  59. ; 000000000000000010 = bit 2 set = 02h, counter = 1
  60. ; 000000000000000100 = bit 3 set = 04h, counter = 2
  61. ; 000000000000001000 = bit 4 set = 08h, counter = 3
  62. ; 000000000000010000 = bit 5 set = 10h, counter = 4
  63. ; 000000000000100000 = bit 6 set = 20h, counter = 5
  64. ; 000000000001000000 = bit 7 set = 40h, counter = 6
  65. ; ..................
  66. ; 001000000000000000 = bit 16 set = 08000h, counter = 15
  67. ; 010000000000000000 = bit 17 set = 10000h, counter = 16
  68. ; 100000000000000000 = bit 18 set = 20000h, counter = 17
  69. ; bit gets shifted one more time, counter increased to 18,
  70. ; counter gets checked, weve done, so loop back and check the answer...
  71.  
  72.  
  73. ; R!SC's Matrix Brute Forcer for duelist's cm#3
  74.  
  75. ; compile to a com file, tasm boo, tlink /t boo
  76. ; bpint 03 in sice.
  77. ; run the com..
  78. ; it breaks when it has found the pattern (about 1 second :)
  79. ; eax==duelist's magic number, ebx==my magic number...
  80.  
  81. ; magic number it created is : 647E -- 110010001111110 in binary
  82. ; which means bit pattern : 0111111000100110000000 (yeah, reversed...)
  83. ; which means each bit thats a 1 is a checked box.. or something
  84.    ;    0  1   1   1   1   1   1   0   0   0   1   0   0   1   1   0   0   0
  85.    ;db 16h,49h,5Eh,15h,27h,26h,21h,25h,1Dh,59h,53h,37h,31h,48h,5Dh,0Ch,61h,52h,4Dh
  86.  
  87. ; boxes 2,3,6,7,9,10,13,14,17 checked...
  88.  
  89. ;       buttons on screen
  90. ;     id  61 49 5e 16 25 26 21 59 53
  91. ;bit was   0  1  1  0  0  1  1  0  1
  92. ;     id  15 37 31 48 5d 0c 52 27 1d
  93. ;          1  0  0  1  1  0  0  1  0
  94.  
  95.  
  96. .MODEL TINY
  97. .CODE
  98. .386
  99.  
  100. ORG 100h
  101.  
  102.  
  103. start:
  104.     lea        si, data
  105.     xor        ecx,ecx
  106.     xor        edx,edx
  107.     xor        eax,eax
  108.     xor        ebx,ebx
  109.  
  110.     mov        ebx, 01        ; we gonna inc ebx, which will add 1 bit to it each time
  111.                         ; 040000h=all 18 bits set, cant go no futher
  112.     jmp        tryme@        ; try bit 1, before entering the loop which goes through all the other 
  113.                         ; possible combinations
  114. nextbits:
  115.     lea        si, data    ; data is the button iD array, in the mixed up order...
  116.     mov        eax, dword ptr [temp]    ; get our calculated number
  117.     cmp        eax, 328feh                ; and check it..
  118.     je        gotit@@
  119.     xor        eax,eax
  120.     mov        dword ptr [temp], eax    ; it wasnt right, so we reset it to 0 :)
  121.     inc        ebx                ; our 18bit value, inc ebx will make it go through every possible combination
  122.     cmp        ebx, 040000h    ; check if we have reached our limit.
  123.     je        shit_fuck_damn    ; shit fuck damn.. means that we have checked all possible 
  124.                             ; combinations and not found our answer, we never want to jump here
  125.  
  126. tryme@:
  127.     mov        eax, 01        ; gonna be our single bit , for checking which bit is set in EBX
  128.     xor        edx,edx        ; our iD counter
  129.     inc        edx
  130. loopy@:
  131.     test    ebx, eax    ; TEST MAGIC NUMBER, X
  132.     jnz        callit        ; JNZ CHECKED
  133. still:
  134.     shl        eax, 1        ; shift our bit to the left :)
  135.     inc        edx            ; increase the iD counter
  136.     inc        si            ; point data to next iD
  137.     cmp        edx, 19        ; see if we have checked all 18 bits
  138.     je        nextbits    ; je next bit pattern, i.e. inc EBX
  139.     jmp        loopy@        ; loop until finished
  140.     
  141. callit:                ; bit X in EBX==1
  142.     pushad
  143.     call    @1        ; do maths
  144.     popad
  145.     jmp        still
  146. @1:
  147.     
  148.     mov    al, byte ptr [si]            ; current iD
  149.     mov    cl, byte ptr [si+1]            ; next iD
  150.     movsx    eax, al                    ; clear rest of register
  151.     movsx    ecx, cl                    ;  "                 "
  152.     imul    eax, ecx                ; EAX==Current box iD * Next box iD
  153.     imul    eax, edx                ; EAX*=Button counter
  154.     add        dword ptr [temp],eax    ; MAGIC NUMBER = MAGIC NUMBER + EAX
  155.     ret
  156. shit_fuck_damn:
  157.     mov        eax, dword ptr [temp]    ; bad news, either my code is wrong, or???
  158.     int    03
  159. gotit@@:
  160.     mov        eax, dword ptr [temp]    ; temp==duelist's magic number
  161.     int 03                            ; so EBX==our bit pattern
  162.     mov     ax, 4C00h
  163.     int     21h
  164.  
  165. ;_______________________________________________________________
  166.  
  167.  
  168. temp    dd    0
  169.  
  170. data    db 16h,49h,5Eh,15h,27h,26h,21h,25h,1Dh,59h,53h,37h,31h,48h,5Dh,0Ch,61h,52h,4Dh
  171.  
  172. end start;