home *** CD-ROM | disk | FTP | other *** search
/ Reverse Code Engineering RCE CD +sandman 2000 / ReverseCodeEngineeringRceCdsandman2000.iso / RCE / +Sandman / lsoth2.asm < prev    next >
Assembly Source File  |  2000-05-25  |  6KB  |  256 lines

  1. ; Serial Number generator by Lord Soth. Version 1.0
  2. ; for ID crackme number 3.
  3. ; Any comments are welcome, but will be ignored :)
  4. ;-----------------------------------------------------------------
  5. model compact
  6. .data
  7.  
  8.  
  9. querystr db 'Enter your soon to be registered name: $'
  10. headline db 'Immortal Descendants CrackMe 3 serial number generator!$'
  11. sernumstr db 'Your serial number is: $'
  12. creditstr db 'Cracked and brought to you by Lord Soth!!$'
  13. zerostr db 'ERROR: Zero length string.$'
  14. username db 256 DUP (0)        ; max length of string that can be brought by a dialog box
  15.  
  16. str_out db 12 DUP (0)        ; length of final serial
  17. ser_len dw 0000
  18.  
  19. .code
  20. .startup
  21. .386C
  22.  
  23. MOV AH,0
  24. MOV AL,3
  25. INT 10h                    ; set normal text video mode.
  26. MOV AX,0625h            ; set 25 lines to scroll up
  27. MOV BH,1Fh                ; set color attribute for blank chars
  28. MOV CX,0000                ; set upper-left corner of window
  29. MOV DX,184Fh            ; set lower-right corner of window
  30. INT 10h                    ; fill screen with blue death :)
  31.  
  32. push ds
  33. pop es
  34. mov ah,13h
  35. mov al,1
  36. mov bh,0
  37. mov bl,0eh
  38. mov cx,37h
  39. mov dx,0
  40. mov ebp,offset es:headline        ; this will print the headline string..
  41. int 10h
  42.  
  43. MOV Ah,3
  44. MOV BH,0
  45. INT 10h                            ; get cursor position
  46.  
  47. ADD DH,2                        ; go down 2 lines
  48. MOV AH,2
  49. MOV DL,0
  50. PUSH DX
  51. MOV BH,0
  52. INT 10h                            ; set cursor on new position
  53.  
  54. POP DX
  55. MOV AH,13h
  56. MOV AL,1
  57. MOV BX,1Fh
  58. MOV CX,27h                        ; 39 chars to print
  59. MOV EBP,offset ES:querystr        ; load offset of string
  60. INT 10h                            ; print the damn string :)
  61.  
  62. ; get the user name from the user, of course.. who did u think? :)
  63.  
  64. MOV CX,0FFh                        ; counter from 255 to 0 (bytes read)
  65. mov bx,0                        ; pointer for memory
  66. LEA DI,username
  67.  
  68. KBread:    MOV AH,0
  69.     INT 16h                        ; get char from keyboard
  70.     MOV BX,CX
  71.     OR BX,0FF00h
  72.     NOT BX                        ; BX will be used to point to the memory where char is stored
  73.     CMP AH,1Ch                    ; check for Enter pressed
  74.     JZ  CreateUserName             ; Bug outa here
  75.     CMP AH,0Eh                    ; check for backspace
  76.     JNZ store
  77.     CALL delchar
  78.     JMP Kbread
  79.  
  80. store:    MOV [DI+BX],AL             ; store ASCII byte in username buffer
  81.         MOV AH,0Ah
  82.         MOV BX,0
  83.         PUSH CX                    ; store counter on stack
  84.         MOV CX,1
  85.         INT 10h                    ; print the char on screen
  86.         MOV AH,3
  87.         INT 10h                    ; get cursor position
  88.         INC DL                     ; increase X pos by 1
  89.         MOV AH,2
  90.         MOV BH,0
  91.         INT 10h                    ; set on new pos
  92.         POP CX    
  93.         LOOP KBread                ; get another char (CX decreases)
  94.  
  95. ; Create the REAL username the program has to calculate the serial from
  96.  
  97. CreateUserName : 
  98.  
  99. NOT CL                            ; reversing CX makes it the string length
  100. CMP CL,0                        ; if no chars, get outa here :)
  101. JNZ contuser                    ; 
  102. JMP out_of_prog                    ; this is a fixed JMP, if your calculation routine is long
  103.                                 ; this might be needed
  104.  
  105. contuser:
  106.  
  107. MOV AX,0                        ; initailize to 0
  108. LEA SI,username                    ; pointer to the username we entered
  109. MOV CX,5                        ; 5 chars to process
  110. MOV BX,0                        ; set BX to 0
  111. LEA DI,str_out                  ; load target string offset into EDI :)
  112.  
  113. ;Calculation of the serial number , those 4 little lines :)
  114. calc:
  115.  
  116. MOV AL,[SI+BX]            ; get char
  117. CALL num2str            ; turn it into an ASCII digit
  118. INC BX                    ; next char
  119. LOOP calc                ; all over again..
  120.  
  121. ;Get string length and check against 10, which is max
  122. LEA SI,str_out
  123. MOV DI,SI
  124. not_end:
  125. INC SI
  126. CMP BYTE PTR [SI],0                ; check for end of string
  127. JNZ not_end
  128. SUB SI,DI                        ; substract will give the length
  129. CMP SI,0Ah                        ; compare to 10
  130. JLE good_num                    ; if 10 or less, continue, this is a good number
  131. MOV SI,0Ah                        ; if more than 10, set to 10, coz 10 is the max the prog uses..
  132. good_num:
  133. MOV WORD PTR [ser_len],SI            ; store length of serial number
  134.  
  135.         
  136.     MOV AH,3
  137.     MOV BX,0
  138.     INT 10h                ; get cursor position
  139.     ADD DH,2
  140.     MOV DL,0
  141.     MOV AX,1301h
  142.     MOV BX,1Fh
  143.     MOV CX,17h            ; 23 chars to print - "Your serial number...."
  144.     MOV EBP,offset sernumstr
  145.     INT 10h
  146.     MOV AH,3
  147.     MOV BX,0
  148.     INT 10h                ; get cursor position
  149.     MOV CX,WORD PTR [ser_len] ; get serial length
  150.     MOV AX,1301h
  151.     MOV BX,1Fh
  152.     MOV EBP,offset str_out
  153.     INC EBP
  154.     INT 10h                ; print serial number
  155.     MOV AH,3
  156.     MOV BX,0
  157.     INT 10h                ; get cursor position
  158.     ADD DH,3            ; increase Y pos by 3
  159.     MOV DL,0            ; X pos = 0, start of line
  160.     MOV AX,1301h
  161.     MOV BX,1Fh
  162.     MOV CX,29h
  163.     MOV EBP,offset creditstr
  164.     INT 10h                ; print my name
  165.     POP BP
  166.     MOV AX,4C00h
  167.     INT 21h                ; get da fuck outa here :)
  168.  
  169. out_of_prog : 
  170.     MOV AH,3
  171.     MOV BX,0
  172.     INT 10h                ; get cursor position
  173.     MOV AX,1301h
  174.     MOV DL,0
  175.     ADD DH,3
  176.     MOV BX,1Fh
  177.     MOV CX,1Ah            ; 26 chars to print, "ERROR: Zero length..."
  178.     MOV EBP,offset ES:zerostr
  179.     INT 10h
  180.     POP BP
  181.     MOV AX,4C00h
  182.     INT 21h                ; get outa here, no chars in username
  183.  
  184. delchar PROC near
  185.     PUSH CX
  186.     PUSH AX
  187.     CMP BX,0
  188.     JZ nochars
  189.     MOV BYTE PTR [DI+BX],0        ; store null char on the buffer
  190.     DEC BX                        ; reduce memory pointer by 1
  191.     PUSH BX
  192.     MOV BH,0
  193.     MOV AH,3
  194.     INT 10h                ; get cursor position
  195.     DEC DL
  196.     MOV AH,2
  197.     MOV BH,0
  198.     INT 10h                ; set it on X-1 pos
  199.     MOV AX,0A20h        ; store "space" on screen pos
  200.     MOV BX,0
  201.     MOV CX,1
  202.     INT 10H                ; write space on screen
  203.     POP BX            
  204.     POP AX
  205.     POP CX
  206.     INC CX                ; increase CX, coz it normally decreases
  207.                         ; and we want to go back 1 char
  208.     RET                    ; return to caller
  209.  
  210. nochars:MOV BX,0        ; zero out BX, no chars to del
  211.         POP AX
  212.         POP CX            ; free stack
  213.         MOV CX,0FFh        ; zero out counter, intial value is FFh
  214.         RET
  215. delchar    ENDP
  216.  
  217. num2str PROC near
  218.         ; AX assumed to hold the 3 digit number
  219.         ; BX used in indirection to put the ASCII in memory
  220.         ; CX used to divide by 100, 10 etc.....
  221.  
  222.         PUSH CX
  223.         MOV CX,64h            ; to divide by 100, find hundreds-digit
  224.         CWD
  225.         IDIV CX
  226.         CMP AX,0
  227.         JZ  zero_dig
  228.         ADD AX,30h            ; add 30h to make it ASCII
  229.         MOV [EDI],AL
  230.         SUB AX,30h            ; return me to normal numbers
  231.         INC EDI
  232. zero_dig:MOV CX,0Ah
  233.         MOV AX,DX
  234.         CWD
  235.         IDIV CX
  236.          ADD AX,30h
  237.         ADD DX,30h
  238.         MOV [EDI],AL
  239.         INC EDI
  240.         MOV [EDI],DL
  241.         INC EDI        
  242.         POP CX
  243.         RET
  244. num2str    ENDP
  245.  
  246. .exit
  247. END
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.         
  256.