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

  1.  
  2.  
  3. .model  tiny
  4.  
  5. .386
  6.  
  7.         org 100h
  8.  
  9. .data
  10.  
  11. GroupLogo       db 13,10
  12.                 db '                     . a . n . e . w . b . r . e . e . d .',13,10
  13.                 db '                                                                ',13,10
  14.                 db '                                                         ▓',13,10
  15.                 db '                                                    ▄▀ ▀▒█▀ ▀▄▄',13,10
  16.                 db '    ░      ▄▄   ▄▄                                ▄▀▄█▄        █             ░',13,10
  17.                 db '         ▄▀▄ █▀▀▄ █ ▄▄    ▄▄▄▄▄▄     ▄▄    ▄▄▄▄ ▄▄▀▄▀ █ ▄█   ▄█ ▀▄  ▄▄▄▄',13,10
  18.                 db '    ░   █ ██ ▄███ █▀▄ █▄▀▀▄▄▄ ▄▄▀▀▀▀▀▄▄▀█▀▀▄▄▄ █▌ █▀  █ ██▄█████▀ ▀▀ ▄▄▄▀▄   ░',13,10
  19.                 db ' ░▒▒▒▓▓█ █▓███▓██ ▄██ ▀▄██████ ▀█▄▄▄█▀  ▄██████  ██ ▄█▀ ██  ██▌   ▄██████ █▓▒░░',13,10
  20.                 db '      █ █▓█▀ █▒██▀█▓█ ▄██▀ ██    ███   ▄██▀ ██  ███▄▀  ███ ███   ▄██▀ ██  █  ░',13,10
  21.                 db '    ▒ █ █▒█  ██▀ S█▓█ ██▄▄█▀   ▄█████  ██▄▄█▀   ███  ▄ ███ ████  ██▄▄█▀  ▐▌  ▒',13,10
  22.                 db '    ▓ ▀▄ ▀   ▀   a█▒█ ▀██▓▓▒░ ▀█▀  ▀██ ▀███▓▓▒░ ■▀██▀  █▀RV▀██▀▀ ▀███▓▓▒ █   ▓',13,10
  23.                 db '        ▀■--─────C▀██ ──────────────────────────────────────────────---■▀',13,10
  24.                 db '                                 ',13,10,'$'
  25.  
  26.  
  27.  
  28. IntroMsgOne     db 13,10,'   [■]   HexDecChar Editor - Key Generator by Quantico  [■]',13,10
  29.                 db '',13,10
  30.                 db 13,10,'   Enter a name        : ','$'
  31.            
  32.  
  33. ErrorMsg        db 13,10,'                     Need 10-20 digits, try again...',13,10,'$'
  34.  
  35. ShowCodeMsg     db 13,10,'                     Registration number : '
  36.  
  37. CodeBuffer      db 10 dup(0),13,10,'$'
  38.  
  39. NameBuffer      db 18h, 19h dup(0)
  40.  
  41. DataTableOne    db 34h,0A0h,0D5h,00h,0F7h,24h,5Dh,5Ch,0Ah,8Ch,10h,0D6h,9Eh,0B5h,9Ch,66h,00h,24h,6Fh,20h,44h,4Dh,0D4h,63h,4Dh,0A2h,0F0h,10h,27h                       
  42.  
  43. Convert_Digs     db '0123456789ABCDEF'
  44.  
  45. namelength      db 0
  46.  
  47. .code
  48.  
  49. .startup
  50.  
  51. main    proc    near
  52.         mov     ah, 09h                       ;
  53.         lea     edx, GroupLogo                ;
  54.         int     21h                           ; show group logo
  55.  
  56.         mov     ah, 09h                       ;
  57.         lea     edx, IntroMsgOne              ;
  58.         int     21h                           ; show intro and ask for input 
  59.  
  60.         mov     bx, 140Ah                     
  61.         lea     edi, NameBuffer               ;
  62.         call    getstr                        ; read user input
  63.         jc      @error                        ;
  64.         xor     eax, eax                      ; clear eax
  65.         call    keygen                        ; create serial number
  66.  
  67.         mov     ah, 09h                       ;
  68.         lea     dx, ShowCodeMsg               ;
  69.         int     21h                           ; print serial number
  70.         jmp     @exit                         ; finished, quit
  71. @error:
  72.         mov     ah, 09h
  73.         lea     dx, ErrorMsg
  74.         int     21h        
  75. @exit:
  76.         mov     al, 00h                       ;
  77.         mov     ah, 4Ch                       ;
  78.         int     21h                           ; terminate program
  79. main    endp
  80.  
  81. keygen  proc    near
  82.         xor     esi, esi
  83.         mov     ebx, 00000001h
  84.         mov     edx, ebx
  85.         mov     edi, ebx
  86. @more:
  87.         mov     ecx, ebx
  88.         dec     ecx
  89.         and     ecx, 8000000Fh
  90.         jns      @GO
  91.         dec     ecx
  92.         or      ecx, 0FFFFFFF0h
  93.         inc     ecx
  94. @GO:
  95.         lea     eax, dword ptr [ebx+edi]
  96.         push    ecx
  97.         mov     ecx, 00000112h
  98.         cdq
  99.         idiv    ecx
  100.         pop     ecx
  101.         mov     al, byte ptr [edx+DataTableOne]
  102.         lea     edx, namebuffer+2
  103.         mov     dl, byte ptr [edx+ebx-01]
  104.         xor     al, dl
  105.         and     eax, 000000FFh
  106.         shl     eax, cl
  107.         add     esi, eax
  108.         inc     ebx
  109.         dec     [namelength]
  110.         jne     @more
  111.         mov     eax, esi
  112.     
  113.     xor    edx, edx
  114.     mov    ecx, 0000000Ah        
  115.     lea    edi, CodeBuffer
  116.     call    convert_num
  117.     ret
  118. keygen    endp
  119.  
  120.  
  121.  
  122. ; get string from user
  123. ; input :
  124. ;       edi = pointer to buffer
  125. ;       bl  = min length
  126. ;       bh  = max length
  127. ; output :
  128. ;    CF error, cx number of bytes read
  129. getstr  proc    near
  130.         push    dx                            ; save dx
  131.         mov     dx, di                        ;
  132.         mov     ah, 0Ah                       ;
  133.         int     021h                          ; get user input
  134.  
  135.         movsx   ecx, byte ptr [edi + 1]       ; get number of digits
  136.  
  137.         mov     byte ptr [edi + ecx + 2], 00h
  138.  
  139.         cmp     cl, bh                        ; check maximum
  140.         jg      @@0
  141.         cmp     cl, bl                        ; check minimum
  142.         jl      @@0
  143.         mov     [namelength], cl              ; store length
  144.     xor    ch, ch
  145.         clc                                   ; clear CF
  146.         jmp     @@1
  147. @@0:
  148.         stc                                   ; set CF (carry flag)        
  149. @@1:
  150.         pop     dx                            ; restore dx
  151.     ret
  152. getstr  endp
  153.  
  154. Convert_Num proc near
  155.         pushf
  156.     pushAD
  157.  
  158.         sub     esp, 4
  159.         mov     ebp,esp
  160.  
  161.         cld
  162.         mov     esi, edi
  163.         push    esi
  164.  
  165. ;--- loop for each digit
  166.  
  167.         sub     bh, bh
  168.         mov     dword ptr [ebp], eax               ;save low word
  169.         mov     dword ptr [ebp+4], edx             ;save high word
  170.         sub     esi, esi                          ;count digits
  171.  
  172. Connum1:
  173.         inc     esi
  174.         mov     eax, dword ptr [ebp+4]             ;high word of value
  175.         sub     edx, edx                          ;clear for divide
  176.         sub    ebx, ebx
  177.         div     ecx                              ;divide, DX gets remainder
  178.         mov     dword ptr [ebp+4],eax             ;save quotient (new high word)
  179.  
  180.         mov     eax, dword ptr [ebp]               ;low word of value
  181.         div     ecx                              ;divide, DX gets remainder
  182.                                                 ;  (the digit)
  183.         mov     dword ptr [ebp], eax               ;save quotient (new low word)
  184.  
  185.         mov     bl, dl
  186.         mov     al, byte ptr [Convert_Digs+ebx]  ;get the digit
  187.         stosb                                   ;store
  188.  
  189.         cmp     dword ptr [ebp], 0                ;check if low word zero
  190.         jne     Connum1                         ;jump if not
  191.         cmp     dword ptr [ebp+4], 0              ;check if high word zero
  192.         jne     Connum1                         ;jump if not
  193.  
  194.         sub     al, al
  195.         stosb                                   ;store the terminator
  196.  
  197. ;--- reverse digits
  198.  
  199.         pop     ecx                              ;restore start of string
  200.         xchg    ecx, esi
  201.         shr     ecx, 1                           ;number of reverses
  202.         jz      Connum3                         ;jump if none
  203.  
  204.         xchg    edi, esi
  205.         sub     esi, 2                           ;point to last digit
  206.  
  207. Connum2 :
  208.         mov     al, byte ptr [edi]               ;load front character
  209.         xchg    al, byte ptr [esi]               ;swap with end character
  210.         stosb                                   ;store new front character
  211.         dec     esi                              ;back up
  212.         loopd   Connum2                         ;loop back for each digit
  213.  
  214. ;--- finished
  215.  
  216. Connum3  :
  217.         add     esp, 4
  218.  
  219.     popad
  220.         popf
  221.         ret
  222.  endp           ;Convert_Num
  223.  
  224. end    main