Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Detection only version of rescue disk
- -- This is a comment
- -- to help deter certain viruses
- -- which hide their code in the header of programs
- local function helpInstructions()
- if term.isColor() then
- term.setTextColor(colors.yellow)
- end
- print("Reinstallation instructions:")
- print("Find an uninfected computer, turn on the computer, " ..
- "insert this disk, and run:")
- print("\"pastebin run qhvYyj6N\".")
- print("")
- if term.isColor() then
- term.setTextColor(colors.white)
- end
- print("Press any key to attempt shutdown...")
- os.pullEvent("key")
- os.shutdown()
- end
- local function labelInfected(unknown)
- local side = nil
- for _, v in pairs(peripheral.getNames()) do
- if peripheral.getType(v) == "drive" and
- peripheral.call(v, "hasData") then
- if peripheral.call(v, "getMountPath") == "disk" or unknown then
- side = v
- break
- end
- end
- end
- if side then
- peripheral.call(side, "setDiskLabel", "[INFECTED] Rescue Boot Disk")
- end
- end
- if term.isColor() then
- term.setTextColor(colors.lightBlue)
- end
- term.clear()
- term.setCursorPos(1, 1)
- print("Running 1lann's Rescue Boot Disk v1.0")
- print("")
- if os.clock() > 1 then
- if term.isColor() then
- term.setTextColor(colors.red)
- end
- print("This boot disk did not run on boot!")
- print("It may now be infected.")
- print("")
- helpInstructions()
- end
- if not shell or shell.getRunningProgram() ~= "disk/startup" then
- if #(shell.getRunningProgram()) > 4 then
- if (shell.getRunningProgram()):sub(1, 4) == "disk" then
- if fs.exists("/disk") then
- pcall(fs.delete, "/disk")
- else
- if term.isColor() then
- term.setTextColor(colors.yellow)
- end
- pcall(fs.delete, shell.getRunningProgram())
- print("The boot disk is infected!")
- print("")
- print("Reason: Program is running on /diskN rather " ..
- "than /disk, and /disk does not exist.")
- print("")
- pcall(labelInfected, true)
- helpInstructions()
- end
- if term.isColor() then
- term.setTextColor(colors.yellow)
- end
- print("The boot disk is potentially infected. Try rebooting " ..
- "this computer, and if you see this message again, the boot " ..
- "disk is (probably) infected.")
- print("")
- print("Reason: Program is running on /diskN rather than /disk.")
- print("")
- helpInstructions()
- end
- end
- if term.isColor() then
- term.setTextColor(colors.red)
- end
- pcall(fs.delete, shell.getRunningProgram())
- print("This boot disk is (probably) infected!")
- print("")
- print("Reason: This program is not running on /disk/startup.")
- print("As a result, this program will self-destruct.")
- print("")
- helpInstructions()
- end
- -- local contents = http.get("http://pastebin.com/raw.php?i=BvvkvEp4")
- -- if not contents then
- -- if term.isColor() then
- -- term.setTextColor(colors.red)
- -- end
- -- print("Could not connect to pastebin! If pastebin works on an " ..
- -- "uninfected computer, this disk may be infected.")
- -- print("")
- -- pcall(labelInfected)
- -- helpInstructions()
- -- end
- -- local f = io.open(shell.getRunningProgram(), "r")
- -- local thisFile = f:read("*a")
- -- f:close()
- -- if contents.readAll() ~= thisFile then
- -- if term.isColor() then
- -- term.setTextColor(colors.red)
- -- end
- -- print("This boot disk is infected!")
- -- print("")
- -- print("Reason: Program contents does not match pastebin version.")
- -- print("")
- -- pcall(labelInfected)
- -- helpInstructions()
- -- end
- local _, err = pcall(error, "", 16)
- if not err or #err < 14 or err:sub(1, 14) ~= "multishell:60:" then
- if term.isColor() then
- term.setTextColor(colors.red)
- end
- print("This boot disk is infected!")
- print("")
- print("Reason: Stack trace signature does not match expected signature.")
- print("")
- pcall(labelInfected)
- helpInstructions()
- end
- if term.isColor() then
- term.setTextColor(colors.lime)
- end
- print("Boot verification successful!")
- if term.isColor() then
- term.setTextColor(colors.yellow)
- end
- print("Scanning and cleaning...")
- print("")
- local systemNames = fs.list("/rom/programs")
- local names = {"cp", "dir", "ls", "mv", "rm", "gps", "help", "adventure", "hello", "worm", "pastebin", "dance", "excavate", "go", "tunnel", "turn", "list"}
- for i = 1, #names do table.insert(systemNames, names[i]) end
- local function isSystemName(name)
- for _, v in pairs(systemNames) do
- if v == name and v ~= "startup" then
- return true
- end
- end
- return false
- end
- -- if fs.exists("/infected") and not fs.isDir("/infected") then
- -- fs.delete("/infected")
- -- end
- -- if not fs.exists("/infected") then
- -- fs.makeDir("/infected")
- -- end
- local hidden = {}
- local traps = {}
- for k,v in pairs(fs.list("/")) do
- if isSystemName(v) then
- table.insert(traps, v)
- -- if fs.exists("/infected/infected_" .. v) then
- -- pcall(fs.delete, "/infected/infected_" .. v)
- -- end
- -- pcall(fs.move, "/" .. v, "/infected/infected_" .. v)
- end
- if v:sub(1, 1) == "." then
- table.insert(hidden, v)
- end
- end
- local problems = false
- if #traps > 0 then
- problems = true
- if term.isColor() then
- term.setTextColor(colors.yellow)
- end
- print("The following traps were found:")
- for _, v in pairs(traps) do
- write(v .. ", ")
- end
- print("")
- print("These traps have been moved to /infected")
- print("")
- end
- if #hidden > 0 then
- if term.isColor() then
- term.setTextColor(colors.yellow)
- end
- print("The following hidden files were found:")
- for _, v in pairs(hidden) do
- write(v .. ", ")
- end
- print("")
- print("")
- end
- -- if fs.exists("/startup") then
- -- problems = true
- -- if fs.exists("/infected/infected_startup") then
- -- pcall(fs.delete, "/infected/infected_startup")
- -- end
- -- pcall(fs.move, "/startup", "/infected/infected_startup")
- -- if term.isColor() then
- -- term.setTextColor(colors.yellow)
- -- end
- -- print("The computer's startup file has been moved to /infected")
- -- print("")
- -- end
- if term.isColor() then
- term.setTextColor(colors.lime)
- end
- if problems then
- print("Scan and clean complete! This computer should now be disinfected.")
- if term.isColor() then
- term.setTextColor(colors.red)
- end
- print("Non-critical files left on the computer may be infected! Please " ..
- "check them before running them.")
- else
- print("Scan completed! No significant problems found.")
- end
- -- This is a comment
- -- to help deter certain viruses
- -- which hide their code in the footer of programs
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement