home *** CD-ROM | disk | FTP | other *** search
/ Phoenix Rising BBS / phoenixrising.zip / phoenixrising / vir-docs / crptlt19.arj / PW_COM.ASM < prev    next >
Assembly Source File  |  1993-08-05  |  7KB  |  222 lines

  1. ;─────────────────────────────────────────────────────────────────────────────
  2. ;                   Black Wolf's File Protection Utilities 2.1s
  3. ;
  4. ;PW_COM - Password Code for COM file password protection in PassCOM.
  5. ;         If modified, convert to data bytes and re-instate program into
  6. ;         PassCOM.ASM, then recompile PassCOM.
  7. ;      
  8. ;         Basically, this code is attached to a .COM file and, when executed,
  9. ;         waits for a password - if it is legit it continues, otherwise it
  10. ;         stops execution of the file.
  11. ;
  12. ;LISCENSE:
  13. ;    Released As Freeware - These files may be distributed freely.
  14. ;
  15. ;Any modifications made to this program should be listed below the solid line,
  16. ;along with the name of the programmer and the date the file was changed.
  17. ;Also - they should be commented where changed.
  18. ;
  19. ;NOTE THAT MODIFICATION PRIVILEDGES APPLY ONLY TO THIS VERSION (2.1s)!  
  20. ;I'd appreciate notification of any modifications if at all possible, 
  21. ;reach me through the address listed in the documentation file (bwfpu21s.doc).
  22. ;
  23. ;DISCLAIMER:  The author takes ABSOLUTELY NO RESPONSIBILITY for any damages
  24. ;resulting from the use/misuse of this program/file.  The user agrees to hold
  25. ;the author harmless for any consequences that may occur directly or 
  26. ;indirectly from the use of this program by utilizing this program/file
  27. ;in any manner.
  28. ;─────────────────────────────────────────────────────────────────────────────
  29. ;Modifications:
  30. ;       None as of 08/05/93 - Initial Release.
  31.  
  32. .model tiny
  33. .radix 16
  34. .code
  35.         org 100
  36. start:
  37.         call    Get_Offset
  38.  
  39. Displaced:
  40.         mov     byte ptr cs:[tr1+bp],0ea        ;Kill some debuggers
  41. tr1:
  42.         jmp     short tr2
  43.         db      0
  44. skip_it:
  45.         jmp     skip2
  46.         dw      0deadh
  47. tr2:    
  48.         mov     bx,offset tri3
  49.         add     bx,bp
  50.         push    bx
  51.         mov     byte ptr cs:[tr2+bp],0c3   ;This one isn't a prefetch trick,
  52.         jmp     skip_it                    ;but they might think it is....
  53. skip2:
  54.         jmp     tr2
  55. tri3:
  56.         cli
  57.         push    ax ds
  58.         xor     ax,ax
  59.         mov     ds,ax
  60.         lea     ax,[Print_Prompt+bp]
  61.         xchg    ax,word ptr ds:[00]
  62.         push    ax
  63.         mov     ax,cs
  64.         xchg    ax,word ptr ds:[02]
  65.         push    ax
  66.         push    ds
  67.         push    cs
  68.         pop     ds
  69.         mov     word ptr cs:[Change_Div+bp],9090    ;This is an interesting
  70.         xor     cx,cx                               ;trick - it basically
  71. Change_Div:                                         ;calls Print_Prompt...
  72.         div     cx                                  ;try debugging it....
  73.         pop     ds
  74.         pop     ax
  75.         xchg    ax,word ptr ds:[02]
  76.         pop     ax
  77.         xchg    ax,word ptr ds:[00]
  78.         pop     ds ax
  79.         sti
  80.  
  81.         call    GetPass
  82.         add     byte ptr cs:[tri4+1+bp],10   ;mod jump to mess up debuggers
  83. tri4:
  84.         jmp     Do_Encr_Pass    
  85.         db      0ea
  86.         db      9a
  87. Do_Encr_Pass:
  88.         call    Encrypt_Password
  89.         call    Check_Passwords
  90.         jc      BadPass
  91.         
  92.         xor     ax,ax
  93.         mov     cx,0c
  94.         lea     si,[Entered_Pass+bp]
  95.  
  96. GetValue:                               ;Get value to use to decrypt with..
  97.         lodsb
  98.         add     ah,al
  99.         ror     ah,1
  100.         loop    GetValue
  101.                                                 ;I need an improved algorithm
  102.         lea     si,[Goodpass+bp]                ;here.......
  103.         mov     cx,EndGoodPass-GoodPass         
  104.         
  105. Decrypt_Restore:        
  106.         mov     al,[si]
  107.         xor     al,ah
  108.         mov     [si],al
  109.         inc     si
  110.         loop    Decrypt_Restore
  111.         call    RenewPrefetch
  112.         jmp     short GoodPass
  113.         db      0ff
  114. GoodPass:        
  115.         mov     di,100
  116.         push    di
  117.         lea     si,bp+Storage_Bytes      ;Restore control to COM.
  118.         movsw
  119.         movsw
  120.         xor     ax,ax
  121.         mov     si,ax
  122.         mov     di,ax
  123.         ret
  124. EndGoodPass:
  125.         db      0ff
  126.  
  127. BadPass:        
  128.         mov     ah,09
  129.         lea     dx,[BadBad+bp]
  130.         int     21
  131.         mov     ax,4c01
  132.         int     21
  133. BadBad  db      0a,0dh,'Password Incorrect.',07,24
  134.  
  135. RenewPrefetch:
  136.         nop
  137.         jmp     loc1
  138.         db      0ea
  139. loc2:        
  140.         clc
  141.         ret
  142.         db      9a
  143. loc1:
  144.         cld
  145.         jmp     loc2
  146. ;------------------------------------------------------------------------
  147. Check_Passwords:
  148.         lea     si,[bp+Entered_Pass]
  149.         lea     di,[Password+bp]
  150.         mov     cx,0c
  151.         repz    cmpsb
  152.         jcxz    Password_Good   ;This spot needs to be more deeply imbedded
  153.         stc                     ;to avoid simple hacking....
  154.         ret
  155.         db      0e9
  156. Password_Good:
  157.         clc
  158.         ret
  159. ;------------------------------------------------------------------------
  160.         db      0
  161. Encrypt_Password:                       ;Here's another place I could use
  162.         mov     bx,word ptr [Key1+bp]   ;a decent encryption algorithm....
  163.         mov     dx,word ptr [Key2+bp]
  164.         lea     si,[Entered_Pass+bp]
  165.         mov     di,si
  166.         mov     cx,6
  167.   EncryptIt:      
  168.         lodsw
  169.         xor     ax,bx
  170.         add     bx,dx
  171.         stosw
  172.         loop    EncryptIt
  173.         ret
  174. ;------------------------------------------------------------------------
  175.         db      0ea
  176. GetPass:
  177.         mov     cx,0c
  178.         lea     di,[Entered_Pass+bp]
  179.   KeyHit_Loop:
  180.         push    cx
  181.         sub     ax,ax
  182.         int     16
  183.         cmp     al,0dh
  184.         je      HitReturn
  185.         stosb
  186.         pop     cx
  187.         loop    KeyHit_Loop
  188.         ret
  189.   
  190.   HitReturn:
  191.         pop     cx
  192.         xor     al,al
  193.         repnz   stosb
  194.         ret        
  195. ;------------------------------------------------------------------------
  196. Print_Prompt:
  197.         mov     ah,09
  198.         lea     dx,[Info+bp]
  199.         int     21
  200.         iret
  201. Info    db      'Password->',24
  202. ;------------------------------------------------------------------------
  203. Get_Offset:
  204.         pop     bp
  205.         jmp     short confuzzled
  206.         db      0ea                     ;confuse disassemblers....
  207. confuzzled:
  208.         push    bp
  209.         sub     bp,offset Displaced
  210.         ret
  211. ;------------------------------------------------------------------------
  212. Key1            dw      0
  213. Key2            dw      0
  214. ;------------------------------------------------------------------------
  215. Storage_Bytes   db      90,90,0cdh,20
  216. ;------------------------------------------------------------------------
  217. Password        db      'Passwordtest'
  218. Entered_Pass    db      '            '
  219. ;------------------------------------------------------------------------
  220. end_prog:
  221. end start
  222.