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

  1. ; 1) not sure why the prog keeps a 'clean' copy of the name (included anyway)
  2. ; 2) only added enough datatable for the 16 digit code.  Can add more if needed (table replicates)
  3. ; 3) spent ages debugging faults, all cleared now.  Needed to clear eax and edx before the idiv
  4. ;    otherwise a divide overflow occurs
  5. ; 4) code is not optimized
  6. ; 5) keygen calculates both valid codes but the one calculated by the idiv's is presented 1st
  7. ;    because it is easier to read.  The other is only to give the user another option.
  8.  
  9. .model  tiny
  10.  
  11. .386
  12.  
  13.         org 100h
  14.  
  15. .data
  16.  
  17. GroupLogo       db 13,10
  18.                 db '                     . a . n . e . w . b . r . e . e . d .',13,10
  19.                 db '                                                                ',13,10
  20.                 db '                                                         ▓',13,10
  21.                 db '                                                    ▄▀ ▀▒█▀ ▀▄▄',13,10
  22.                 db '    ░      ▄▄   ▄▄                                ▄▀▄█▄        █             ░ ',13,10
  23.                 db '         ▄▀▄ █▀▀▄ █ ▄▄    ▄▄▄▄▄▄     ▄▄    ▄▄▄▄ ▄▄▀▄▀ █ ▄█   ▄█ ▀▄  ▄▄▄▄       ',13,10
  24.                 db '    ░   █ ██ ▄███ █▀▄ █▄▀▀▄▄▄ ▄▄▀▀▀▀▀▄▄▀█▀▀▄▄▄ █▌ █▀  █ ██▄█████▀ ▀▀ ▄▄▄▀▄   ░ ',13,10
  25.                 db ' ░▒▒▒▓▓█ █▓███▓██ ▄██ ▀▄██████ ▀█▄▄▄█▀  ▄██████  ██ ▄█▀ ██  ██▌   ▄██████ █▓▒░░',13,10
  26.                 db '      █ █▓█▀ █▒██▀█▓█ ▄██▀ ██    ███   ▄██▀ ██  ███▄▀  ███ ███   ▄██▀ ██  █  ░ ',13,10
  27.                 db '    ▒ █ █▒█  ██▀ S█▓█ ██▄▄█▀   ▄█████  ██▄▄█▀   ███  ▄ ███ ████  ██▄▄█▀  ▐▌  ▒ ',13,10
  28.                 db '    ▓ ▀▄ ▀   ▀   a█▒█ ▀██▓▓▒░ ▀█▀  ▀██ ▀███▓▓▒░ ■▀██▀  █▀RV▀██▀▀ ▀███▓▓▒ █   ▓ ',13,10
  29.                 db '        ▀■--─────C▀██ ──────────────────────────────────────────────---■▀      ',13,10
  30.                 db '                                                                               ',13,10
  31.                 db '                                -----=====-----                                ',13,10
  32.                 db '            [■]   UltraEdit  v5.20 - Key Generator by Quantico  [■]           ',13,10
  33.                 db '                                -----=====-----                                ',13,10
  34.                 db '                                 ',13,10,'$'
  35.  
  36.  
  37.  
  38. IntroMsgOne     db 13,10,'Enter a name        : ','$'
  39.            
  40.  
  41. ErrorMsg        db 13,10,'                     Need 6-21 digits, please try again...',13,10,'$'
  42.  
  43.  
  44. Namealtered     db 18h, 19h dup(0)
  45. Nameclean       db 18h, 19h dup(0)
  46.  
  47. fullcode1       db 3Ch dup(2Eh)
  48. fullcode2       db 3Ch dup(2Eh)
  49.  
  50. notresult       db 0
  51.  
  52. datatable       db 6Eh,35h,0F7h,74h,0DEh,6Fh,32h,85h,0FFh,36h,0A8h,59h,0DEh,0DEh,79h,88h
  53.  
  54. namelength      db 0
  55.  
  56. ShowCodeMsg     db 13,10,13,10,'--=[Valid registration numbers]=-- ',13,10
  57.                 db 13,10,'[CODE 1] : '
  58. Code2Buffer     db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,13,10
  59.                 db 13,10,'[CODE 2] : '
  60. Code1Buffer     db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,13,10,'$'
  61.  
  62. .code
  63.  
  64. .startup
  65.  
  66. main    proc    near
  67.         mov     ah, 09h                       ;
  68.         lea     edx, GroupLogo                ;
  69.         int     21h                           ; show group logo
  70.  
  71.         mov     ah, 09h                       ;
  72.         lea     edx, IntroMsgOne              ;
  73.         int     21h                           ; show intro and ask for input 
  74.  
  75.         mov     bx, 1506h                     ; limits for string input
  76.         lea     edi, Namealtered              ;
  77.         call    getstr                        ; read user input
  78.         jc      @error                        ;
  79.         xor     eax, eax                      ; clear eax
  80.         call    keygen                        ; create serial number
  81.  
  82.         mov     ah, 09h                       ;
  83.         lea     dx, ShowCodeMsg               ;
  84.         int     21h                           ; print serial number
  85.         jmp     @exit                         ; finished, quit
  86. @error:
  87.         mov     ah, 09h
  88.         lea     dx, ErrorMsg                  ; wrong input
  89.         int     21h        
  90. @exit:
  91.         mov     al, 00h                       ;
  92.         mov     ah, 4Ch                       ;
  93.         int     21h                           ; terminate program
  94. main    endp
  95.  
  96. keygen  proc    near
  97.  
  98.         mov     eax, offset Namealtered+2
  99.         mov     esi, offset Nameclean
  100.         mov     ebx, offset namelength
  101.         movsx   ebx, byte ptr [ebx]
  102. notendofname:
  103.         mov     cl, byte ptr [eax]
  104.         mov     byte ptr [esi], cl
  105.         inc     eax
  106.         inc     esi
  107.         dec     ebx
  108.         jnz     notendofname
  109.  
  110.         mov     eax, offset namealtered+2
  111.         mov     byte ptr [eax+2], 09
  112.         mov     bl, byte ptr [eax+5]
  113.         or      bl, 55h
  114.         mov     byte ptr [eax+5], bl
  115.  
  116.         mov     esi, offset fullcode1
  117.         mov     ebx, offset namelength
  118.         movsx   ebx, byte ptr [ebx]
  119. notallcopied:
  120.         mov     cl, byte ptr [eax]
  121.         mov     byte ptr [esi], cl
  122.         inc     eax
  123.         inc     esi
  124.         dec     ebx
  125.         jnz     notallcopied
  126.         mov     byte ptr [esi], 00
  127.  
  128.         mov     esi, offset namelength
  129.         movsx   esi, byte ptr [esi]
  130.         xor     ecx, ecx
  131.         xor     eax, eax
  132. notalladded:
  133.         add     al, byte ptr [fullcode1+ecx]
  134.         inc     ecx
  135.         cmp     ecx, esi
  136.         jnz     notalladded
  137.         not     al
  138.         mov     byte ptr [notresult], al
  139.  
  140.         xor     esi, esi
  141. esinot60:
  142.         mov     ecx, offset fullcode1
  143.         mov     edx, offset notresult
  144.         mov     dl, byte ptr [edx]
  145.         mov     al, byte ptr [datatable+esi]
  146.         xor     al, dl
  147.         inc     al
  148.         xor     byte ptr [ecx+esi], al
  149.  
  150.         xor     eax, eax
  151.         xor     edx, edx
  152.         mov     al, byte ptr [ecx+esi]
  153.         cmp     esi, 08                        
  154.         jge     @0040BF99                 ; my brain was too tired to think of
  155.                                           ; a more interesting name to jump to
  156. ;        push    1Ah         ; replaced
  157. ;        pop     ecx
  158.  
  159.         xor     ecx, ecx
  160.         mov     cl, 1Ah
  161.         idiv    cx
  162.         add     dl, 41h
  163.         jmp     @0040BFA1
  164. @0040BF99:
  165. ;        push    0Ah         ; replaced
  166. ;        pop     ecx
  167.  
  168.         xor     ecx, ecx
  169.         mov     cl, 0Ah
  170.         idiv    cx
  171.         add     dl, 30h
  172. @0040BFA1:
  173.         mov     byte ptr [fullcode2+esi], dl
  174.         inc     esi
  175.         cmp     esi, 3Ch
  176.         jl      esinot60
  177.  
  178.         xor     edx, edx
  179.         xor     ebx, ebx
  180. edxnot3c:
  181.         mov     cl, byte ptr [fullcode1+edx]
  182.         lea     eax, dword ptr [fullcode1+edx]
  183.         cmp     cl, 80h
  184.         jb      lessthan80
  185.         add     cl, 80h
  186.         mov     byte ptr [eax], cl
  187. lessthan80:
  188.         mov     cl, byte ptr [eax]
  189.         cmp     cl, 7Fh
  190.         jl      lessthan7f
  191.         sub     cl, 7Fh
  192.         mov     byte ptr [eax], cl
  193. lessthan7f:
  194.         mov     cl, byte ptr [eax]
  195.         cmp     cl, 21h
  196.         jg      morethan21
  197.         add     cl, 21h
  198.         mov     byte ptr [eax], cl
  199. morethan21:
  200.         cmp     byte ptr [eax], 22h
  201.         jne     not22
  202.         mov     byte ptr [eax], 23h
  203. not22:
  204.         cmp     byte ptr [eax], 27h
  205.         jne     not27
  206.         mov     byte ptr [eax], 28h
  207. not27:
  208.         cmp     byte ptr [eax], 2Eh
  209.         jne     not2e
  210.         mov     byte ptr [eax], 2Fh
  211. not2e:
  212.         cmp     byte ptr [eax], 60h
  213.         jne     not60
  214.         mov     byte ptr [eax], 61h
  215. not60:
  216.         cmp     byte ptr [eax], 7Ch
  217.         jne     not7c
  218.         mov     byte ptr [eax], 6Ch
  219. not7c:
  220.         inc     edx
  221.         cmp     edx, 3Ch
  222.         jl      edxnot3c
  223.  
  224.         mov     eax, offset fullcode1
  225.         mov     esi, offset Code1Buffer
  226.         mov     ecx, 10h
  227. fillmore:
  228.         mov     dl, byte ptr [eax]
  229.         mov     byte ptr [esi], dl
  230.         inc     eax
  231.         inc     esi
  232.         dec     ecx
  233.         jnz     fillmore
  234.  
  235.         mov     ecx, 10h
  236.         mov     eax, offset fullcode2
  237.         mov     esi, offset Code2Buffer
  238. fillmore2:
  239.         mov     dl, byte ptr [eax]
  240.         mov     byte ptr [esi], dl
  241.         inc     eax
  242.         inc     esi
  243.         dec     ecx
  244.         jnz     fillmore2
  245.  
  246. ; THATS IT!
  247.  
  248.     ret
  249. keygen    endp
  250.  
  251.  
  252.  
  253. ; get string from user
  254. ; input :
  255. ;       edi = pointer to buffer
  256. ;       bl  = min length
  257. ;       bh  = max length
  258. ; output :
  259. ;    CF error, cx number of bytes read
  260. getstr  proc    near
  261.         push    dx                            ; save dx
  262.         mov     dx, di                        ;
  263.         mov     ah, 0Ah                       ;
  264.         int     021h                          ; get user input
  265.  
  266.         movsx   ecx, byte ptr [edi+1]       ; get number of digits
  267.  
  268.         mov     byte ptr [edi+ecx+2], 00h
  269.  
  270.         cmp     cl, bh                        ; check maximum
  271.         jg      @@0
  272.         cmp     cl, bl                        ; check minimum
  273.         jl      @@0
  274.         mov     [namelength], cl              ; store length
  275.     xor    ch, ch
  276.         clc                                   ; clear CF
  277.         jmp     @@1
  278. @@0:
  279.         stc                                   ; set CF (carry flag)        
  280. @@1:
  281.         pop     dx                            ; restore dx
  282.     ret
  283. getstr  endp
  284.  
  285. end    main