home *** CD-ROM | disk | FTP | other *** search
/ Reverse Code Engineering RCE CD +sandman 2000 / ReverseCodeEngineeringRceCdsandman2000.iso / RCE / Quantico / km / microch7.asm.txt < prev    next >
Encoding:
Text File  |  2000-05-25  |  9.7 KB  |  268 lines

  1. .model  tiny
  2. .386
  3. org 100h
  4. .data
  5.  
  6. GroupLogo       db 13,10
  7.                 db '            ▄▄▄▄▄ ',13,10
  8.                 db '            █ ▄ █  ',13,10
  9.                 db '    █▀▀▀▀▀▀▀▀ ▄ ▀▀▀▀▀ ▀ ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀█  █▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀ ▀ ▀▀▀▀█ ',13,10
  10.                 db '    █ │░███████  │▓███████▀ │░███▀█▀▀▀▀▀▀▀ ▀ ▀▀▀▀ │░███▀█▀▀▀▀▀▓████▓▄  █ ',13,10
  11.                 db '    █ │▒███████  │▓███████  │▒███████  │▓███████▀ │▒███████  │▓███████ █ ',13,10
  12.                 db '    █ │▓███████  │▓███████  │▓███████  │▓███████  │▓███████  │▓███████ █ ',13,10
  13.                 db '    ▀ │▓███████  │▓███████  │▓███████  │▓███████  │▓███████  │▓███████ █▄▄▄ ',13,10
  14.                 db '    ▀ │▓███████  │▓███████  │▓███████  │▓███████  │▓███████  │▓███████▄ ▄ █ ',13,10
  15.                 db '    █ │▓███████  │▓███████  │▓███████  │▓███████  │▓███████               █ ',13,10
  16.                 db '    █ │▓███████▄▄▄▄▄█▄█▓▀   │▓███████▄▄▄▄▄█▄████  │▓███████▀▀ ▀    ▀      █ ',13,10
  17.                 db '    █▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ ▄ ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ ▀ █▀▀▀▀▀▀▀▀▀ ▀ ▀▀ ',13,10
  18.                 db '    .::[ u n i t e d · c r æ c k i n g · f o r c e ]::. █ ▀ █ Antibody<SAC> ',13,10
  19.                 db '    █▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ ▄ ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ ▀ █▀▀▀▀▀▀▀▀▀ ▀ ▀▀ ',13,10
  20.                 db '                                -----=====-----                             ',13,10
  21.                 db '        [■]   MicroChart/32 v7.04 - Key Generator by Quantico   [■]         ',13,10
  22.                 db '                                -----=====-----                             ',13,10
  23.                 db '                                 ',13,10,'$'
  24.  
  25.  
  26.  
  27. IntroMsgOne     db 13,10,'Enter a name please    : ','$'
  28.            
  29. ErrorMsg        db 13,10,'Need 5-20 digits, try again...',13,10,'$'
  30.  
  31. ShowCodeMsg     db 13,10,'Registration number    : '
  32.  
  33. CodeBuffer      db 20 dup(0),13,10
  34.                 db 13,10,'You can use any company name. ',13,10,'$'
  35.  
  36. NameBuffer      db 18h, 19h dup(0)
  37.  
  38. Convert_Digs    db '0123456789ABCDEF'
  39.  
  40. namelength      db 0
  41.  
  42. datatable       db 1100h dup(00h)
  43.  
  44.  
  45.  
  46. .code
  47.  
  48. .startup
  49.  
  50. main    proc    near
  51.         mov     ah, 09h                       ;
  52.         lea     edx, GroupLogo                ;
  53.         int     21h                           ; show group logo
  54.  
  55.         mov     ah, 09h                       ;
  56.         lea     edx, IntroMsgOne              ;
  57.         int     21h                           ; show intro and ask for input 
  58.  
  59.         mov     bx, 1405h                     ; limits for string input
  60.         lea     edi, NameBuffer               ;
  61.         call    getstr                        ; read user input
  62.         jc      @error                        ;
  63.  
  64.         call    keygen                        ; create serial number
  65.  
  66.         mov     ah, 09h                       ;
  67.         lea     dx, ShowCodeMsg               ;
  68.         int     21h                           ; print serial number
  69.         jmp     @exit                         ; finished, quit
  70. @error:
  71.         mov     ah, 09h
  72.         lea     dx, ErrorMsg
  73.         int     21h        
  74. @exit:
  75.         mov     al, 00h                       ;
  76.         mov     ah, 4Ch                       ;
  77.         int     21h                           ; terminate program
  78. main    endp
  79.  
  80.  
  81. keygen  proc    near
  82.  
  83.         int     3                    ; for debugging
  84.  
  85.         xor     eax, eax             ; eax = 0
  86.  
  87. bigloop:
  88.  
  89.         mov     ecx, eax             ; ecx = eax
  90.         mov     edx, 08              ; edx = 8
  91.  
  92. smallerloop:
  93.  
  94.         test    cl, 01               ; decide whether to xor or not
  95.         je      overthexor
  96.         shr     ecx, 1
  97.         xor     ecx, 0EDB88320h      ; xor ecx with EDB88320h
  98.         jmp     overtheshr           ; jump
  99.  
  100. overthexor:
  101.  
  102.         shr     ecx, 1               ; shift right ecx by 1
  103.  
  104. overtheshr:
  105.  
  106.         dec     edx                  ; edx -1 (7,6,5,4,3,2,1,0)
  107.         jne     smallerloop          ; if not 0 then jump back
  108.         mov     dword ptr [datatable+4*eax], ecx  ; store magic value from previous loop
  109.         inc     eax                  ; eax+1     
  110.         cmp     eax, 100h            ; is eax = 100h
  111.         jl      bigloop              ; if not, jump to make another magic value
  112.  
  113.  
  114. ; end of datatable creation
  115.  
  116.  
  117.  ; The above code creates a data lookup table using an inner and an outer
  118.  ; loop.  The inner loop repeats 8 times and builds up a single value for
  119.  ; the datatable.  When the innerloop exits, the magic value is stored in
  120.  ; the table and the outerloop count increases by one.  The whole thing
  121.  ; repeats until the datatable contains 256 values which are used when the
  122.  ; code is being made. This requires 256*8 repititions of the inner loop.
  123.  
  124.  
  125.  
  126.         xor     ecx, ecx                        ; ecx = 0
  127.         movzx   esi, byte ptr [namelength]      ; esi = length of name
  128.         mov     edi, offset [NameBuffer+2]      ; edi = pointer to name
  129.         mov     eax, 0AFBECDDCh                 ; eax = starting value
  130.  
  131.        
  132. createcode:
  133.  
  134.         xor     edx, edx                        ; clear edx
  135.         mov     ebx, eax                        ; ebx = eax
  136.         mov     dl, byte ptr [ecx+edi]          ; dl = byte of name
  137.         and     ebx, 0FFh                       ; keep bl, clear rest of ebx
  138.         xor     edx, ebx                        ; xor 
  139.         shr     eax, 08                         ; shift right eax by 8
  140.         mov     edx, dword ptr [datatable+4*edx]; magic number from datatable
  141.         xor     eax, edx                        ; xor eax with magic num from table
  142.         inc     ecx                             ; ecx+1
  143.         cmp     ecx, esi                        ; is loopcount = namelength
  144.         jl      createcode                      ; if not, then go again
  145.  
  146.  
  147.  ; this section repeats for each letter of the username, performing some maths
  148.  ; with each letter, the starting value and the 'magic numbers' which were built in
  149.  ; the previous loop.
  150.         
  151.  
  152.         xor     edx, edx           ; clear edx
  153.         mov     ecx, 0000000Ah     ; ecx = 10 (base 10 for convert_num proc)
  154.         lea     edi, CodeBuffer    ; place to store converted string
  155.         call    convert_num        ; convert decimal number to printable string
  156.                                    ; thanks Stone [UCF]
  157.         ret                        ; end of procedure, return to caller
  158.  
  159. keygen    endp
  160.  
  161.  
  162.  
  163.  
  164. ; get string from user
  165. ; input :
  166. ;       edi = pointer to buffer
  167. ;       bl  = min length
  168. ;       bh  = max length
  169. ; output :
  170. ;    CF error, cx number of bytes read
  171.  
  172. getstr  proc    near
  173.         push    dx                            ; save dx
  174.         mov     dx, di                        ;
  175.         mov     ah, 0Ah                       ;
  176.         int     21h                           ; get user input
  177.  
  178.         movsx   ecx, byte ptr [edi + 1]       ; get number of digits
  179.  
  180.         mov     byte ptr [edi + ecx + 2], 00h
  181.  
  182.         cmp     cl, bh                        ; check maximum
  183.         jg      @@0
  184.         cmp     cl, bl                        ; check minimum
  185.         jl      @@0
  186.         mov     [namelength], cl              ; store length
  187.         xor     ch, ch
  188.         clc                                   ; clear CF
  189.         jmp     @@1
  190. @@0:
  191.         stc                                   ; set CF (carry flag)        
  192. @@1:
  193.         pop     dx                            ; restore dx
  194.         ret
  195. getstr  endp
  196.  
  197.  
  198.  
  199. Convert_Num proc near
  200.         pushf
  201.         pushAD
  202.  
  203.         sub     esp, 4
  204.         mov     ebp,esp
  205.  
  206.         cld
  207.         mov     esi, edi
  208.         push    esi
  209.  
  210. ;--- loop for each digit
  211.  
  212.         sub    bh, bh
  213.         mov    dword ptr [ebp], eax            ;save low word
  214.         mov    dword ptr [ebp+4], edx          ;save high word
  215.         sub    esi, esi                        ;count digits
  216.  
  217. Connum1:
  218.         inc    esi
  219.         mov    eax, dword ptr [ebp+4]          ;high word of value
  220.         sub    edx, edx                        ;clear for divide
  221.         div    ecx                             ;divide, DX gets remainder
  222.         mov    dword ptr [ebp+4],eax           ;save quotient (new high word)
  223.  
  224.         mov     eax, dword ptr [ebp]           ;low word of value
  225.         div     ecx                            ;divide, DX gets remainder
  226.                                                ;  (the digit)
  227.         mov     dword ptr [ebp], eax           ;save quotient (new low word)
  228.  
  229.         mov     bl, dl
  230.         mov     al, byte ptr [Convert_Digs+ebx]  ;get the digit
  231.         stosb                                    ;store
  232.  
  233.         cmp     dword ptr [ebp], 0             ;check if low word zero
  234.         jne     Connum1                        ;jump if not
  235.         cmp     dword ptr [ebp+4], 0           ;check if high word zero
  236.         jne     Connum1                        ;jump if not
  237.  
  238.         sub     al, al
  239.         stosb                                  ;store the terminator
  240.  
  241. ;--- reverse digits
  242.  
  243.         pop     ecx                            ;restore start of string
  244.         xchg    ecx, esi
  245.         shr     ecx, 1                         ;number of reverses
  246.         jz      Connum3                        ;jump if none
  247.         xchg    edi, esi
  248.         sub     esi, 2                         ;point to last digit
  249.  
  250. Connum2 :
  251.         mov     al, byte ptr [edi]             ;load front character
  252.         xchg    al, byte ptr [esi]             ;swap with end character
  253.         stosb                                  ;store new front character
  254.         dec     esi                            ;back up
  255.         loopd   Connum2                        ;loop back for each digit
  256.  
  257. ;--- finished
  258.  
  259. Connum3  :
  260.         add     esp, 4
  261.  
  262.         popad
  263.         popf
  264.         ret
  265.  endp           ;Convert_Num
  266.  
  267. end    main
  268.