Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- (c) COPYRIGHT 2012 --
- -- A program made by 1lann --
- -- Thanks to: This_is_1984 --
- -- and GravityScore --
- function move(dir, option1, option2)
- term.setCursorPos(3, 14)
- write(" ")
- if dir == "left" then
- b1 = (math.floor(13-(string.len(option1)/2)))-1
- b2 = math.floor(37-(string.len(option2)/2))
- term.setCursorPos(b1, 14)
- term.write(">" .. option1 .. "<")
- term.setCursorPos(b2, 14)
- term.write(option2)
- coroutine.yield()
- event, key = os.pullEvent("key")
- if key == 205 then
- r = move("right", option1, option2)
- return r
- elseif key == 28 then
- return option1
- else
- r = move("left", option1, option2)
- return r
- end
- elseif dir == "right" then
- b1 = math.floor(13-(string.len(option1)/2))
- b2 = (math.floor(37-(string.len(option2)/2)))-1
- term.setCursorPos(b1, 14)
- term.write(option1)
- term.setCursorPos(b2, 14)
- term.write(">" .. option2 .. "<")
- coroutine.yield()
- event, key = os.pullEvent("key")
- if key == 203 then
- r = move("left", option1, option2)
- return r
- elseif key == 28 then
- return option2
- else
- r = move("right", option1, option2)
- return r
- end
- elseif dir == "centre" then
- b1 = math.floor(25-(string.len(option1)/2))
- term.setCursorPos(b1, 14)
- write(">" .. option1 .. "<")
- coroutine.yield()
- event, key = os.pullEvent("key")
- if key == 28 then
- return option2
- else
- r = move("centre", option1, option2)
- return r
- end
- else
- error("Not a valid direction")
- end
- end
- function prompt(line1, line2, line3, line4, line5, option1, option2)
- show(true)
- term.clear()
- term.setCursorPos(2,2)
- write("+----------------------------------------------+")
- term.setCursorPos(2,3)
- write("|1lann's Rescue Disk (v0.5) |")
- term.setCursorPos(2,4)
- write("+----------------------------------------------+")
- for i = 1, 12 do
- b = i+4
- term.setCursorPos(2, b)
- write("|")
- term.setCursorPos(49, b)
- write("|")
- end
- term.setCursorPos(2, 17)
- write("+----------------------------------------------+")
- a1 = math.floor(25-(string.len(line1)/2))
- a2 = math.floor(25-(string.len(line2)/2))
- a3 = math.floor(25-(string.len(line3)/2))
- a4 = math.floor(25-(string.len(line4)/2))
- a5 = math.floor(25-(string.len(line5)/2))
- term.setCursorPos(a1, 7)
- write(line1)
- term.setCursorPos(a2, 8)
- write(line2)
- term.setCursorPos(a3, 9)
- write(line3)
- term.setCursorPos(a4, 10)
- write(line4)
- term.setCursorPos(a5, 11)
- write(line5)
- dir = "left"
- if option2 == nil then
- dir = "centre"
- end
- x = move(dir, option1, option2)
- term.clear()
- term.setCursorPos(1, 1)
- show(false)
- return x
- end
- function log(log)
- f = io.open("/disk/avlog.log", "a")
- f:write(log .. "\n")
- f:close()
- end
- function scandir(ldir)
- local currentdir = ldir
- local cont = {}
- cont = fs.list(currentdir)
- if cont[1] == nil then
- return
- end
- local b = 0
- for i = 1, #cont do
- sleep(0.000001)
- b = b+1
- i = b
- if cont[i] == "disk" and currentdir == "/" then
- skip = "true"
- elseif cont[i] == "rom" and currentdir == "/" then
- skip = "true"
- else
- skip = "false"
- end
- if not fs.isDir(currentdir .. cont[i]) then
- files = files+1
- f = io.open(currentdir .. cont[i], "r")
- local data = f:read("*a")
- f:close()
- for xvirus = 1, #virusdatabase do
- local find = string.find(data, virusdatabase[xvirus], 1, false)
- if find ~= nil then
- fs.delete( "/disk/bad" .. cont[i])
- fs.move(currentdir .. cont[i], "/disk/bad" .. cont[i])
- viruses = viruses+1
- print("Virus \"" .. namedatabase[xvirus] .. "\" found in " .. currentdir .. cont[i])
- log("Virus \"" .. namedatabase[xvirus] .. "\" found in " .. currentdir .. cont[i])
- break
- end
- end
- elseif skip == "false" then
- folders = folders+1
- scandir(currentdir .. cont[i] .. "/")
- else
- end
- end
- end
- function namecheck()
- filelist = fs.list("/")
- names = {"cp", "dir", "ls", "mv", "rm", "computer", "http", "secret", "turtle", "bit", "colors", "colours", "gps", "help", "io", "parallel", "rednet", "term", "textutils", "vector", "os", "math", "fs", "coroutine", "parallel", "peripheral", "rs", "redstone", "shell", "string", "table", "term", "adventure", "hello", "worm", "pastebin", "alongtimeago", "dance", "excavate", "go", "tunnel", "turn"}
- for b = 1, #filelist do
- for i = 1, #names do
- if filelist[b] == names[i] then
- viruses = viruses+1
- files = files+1
- print("Virus \"General.Malware\" found in /" .. filelist[b])
- log("Virus \"General.Malware\" found in /" .. filelist[b])
- fs.delete("/disk/bad" .. filelist[b])
- fs.move("/" .. filelist[b], "/disk/bad" .. filelist[b])
- else
- end
- end
- end
- end
- function syscheck()
- filelist = fs.list("/")
- system = fs.list("/rom/programs")
- for b = 1, #filelist do
- for i = 1, #system do
- if filelist[b] == system[i] then
- viruses = viruses+1
- files = files+1
- print("Virus \"General.Malware\" found in /" .. filelist[b])
- log("Virus \"General.Malware\" found in /" .. filelist[b])
- fs.delete("/disk/bad" .. filelist[b])
- fs.move("/" .. filelist[b], "/disk/bad" .. filelist[b])
- else
- end
- end
- end
- end
- function maskscan()
- option = prompt(" ", "Right! Now we\'re going to do a", "full virus scan and delete", "all the viruses", " ", "Ok", "Exit")
- if option == "Exit" then
- prompt(" ", "Alright! Just be careful!", "Please eject the disk", "Press enter to shutdown the computer", " ", "Shutdown")
- os.shutdown()
- end
- log("Start virus scan")
- viruses = 0
- files = 0
- folders = 0
- syscheck()
- namecheck()
- scandir("/")
- log("Scanned through " .. files .. " files")
- log("Scanned through " .. folders .. " folders")
- log("End virus scan")
- log(" ")
- print("Press any key to continue...")
- os.pullEvent("key")
- prompt("Scanned through " .. files .. " files and " .. folders .. " folders!", "A total of " .. viruses .. " viruses were found and moved!", "The files were moved on the disk,", "prefixed with \"bad\"", " ", "Ok")
- prompt("Horrah! You finished the entire antivirus", "process! \(It\'s that easy!\)", "Please eject the disk", "Press enter to shutdown the computer", " ", "Shutdown")
- os.shutdown()
- end
- function restore()
- option = prompt(" ", "Uh oh!, You\'re computer is infected!", "Don\'t worry! we can fix this in a sinch", "Do you want to ignore it or restore it", "from the disk?", "Restore", "Ignore")
- if option == "Restore" then
- f = io.open("/disk/startbackup", "r")
- startbackup = f:read("*a")
- f:close()
- f = io.open("/startup", "r")
- startupfile = f:read("*a")
- f:close()
- f = io.open("/disk/badstartup", "w")
- f:write(startupfile)
- f:close()
- f = io.open("/startup", "w")
- f:write(startbackup)
- f:close()
- prompt("Restored!", "Also, I made a copy of the bad startup", "on the disk called badstartup", "The next step is to perform a", "full antivirus scan", "Continue")
- maskscan()
- end
- maskscan()
- end
- function manual()
- prompt("Alright, then I can\'t check your startup", "You\'re going to have to check it yourself", "Hit exit once you\'re done checking", "BTW, editting and hitting save won\'t", "do anything to the actual startup", "Open startup")
- f = io.open("/startup", "r")
- file = f:read("*a")
- f:close()
- f = io.open("/disk/tempstartup", "w")
- f:write(file)
- f:close()
- shell.run("/rom/programs/edit", "/disk/tempstartup")
- fs.delete("/disk/tempstartup")
- option = prompt(" ", " ", "Was that startup file correct?", " ", " ", "Yes", "No")
- if option == "Yes" then
- f = io.open("/disk/startbackup", "w")
- f:write(file)
- f:close()
- prompt(" ", "Backed up on the disk as \"startbackup\"", "The next step is to perform a", "full antivirus scan", " ", "Continue")
- maskscan()
- else
- restore()
- end
- end
- function main()
- clock = 0.1
- term.clear()
- term.setCursorPos(1, 1)
- if not fs.exists("/startup") then
- f = io.open("/startup", "w")
- f:write("\n")
- f:close()
- end
- if clock > 1 then
- prompt(" ", " ", "This program wasn\'t run on startup!", "Please reboot your computer and try again", " ", "Ok")
- elseif not fs.exists("/disk/startup") then
- prompt(" ", "This program is not ran from a disk", "Please put it on a disk as startup", "and try again"," ", "Ok")
- elseif not fs.isDir("/disk") then
- input = prompt(" ", "A file is obstructing the name \"disk\"", "Would you like to rename it or", "exit the rescue disk?", " ", "Rename", "Exit")
- if input == "Rename" then
- f = io.open("/disk", "r")
- disk = f:read("*a")
- f:close()
- f = io.open("/otherdisk", "w")
- f:write(disk)
- f:close()
- prompt(" ", " ", "Alright, renamed to \"otherdisk\"", "Now we have to reboot the computer", " ", "Reboot")
- os.reboot()
- else
- os.shutdown()
- end
- else
- if fs.exists("/disk/tempstartup") then fs.delete("/disk/tempstartup") end
- shell.run("/rom/programs/http/pastebin", "get", "hLnnpXtZ", "/disk/tempstartup")
- f = io.open("/disk/tempstartup", "r")
- tempstartup = f:read("*a")
- f:close()
- f = io.open("/disk/startup", "r")
- avstartup = f:read("*a")
- f:close()
- fs.delete("/disk/tempstartup")
- if fs.exists("/disk/database") then fs.delete("/disk/database") end
- shell.run("/rom/programs/http/pastebin", "get", "xJhGLZeV", "/disk/database")
- f = io.open("/disk/database", "r")
- namedatabase = {}
- bdatabase = f:read("*l")
- while bdatabase ~= nil do
- table.insert(namedatabase, bdatabase)
- bdatabase = f:read("*l")
- bdatabase = f:read("*l")
- end
- f:close()
- f = io.open("/disk/database", "r")
- virusdatabase = {}
- bdatabase = f:read("*l")
- bdatabase = f:read("*l")
- while bdatabase ~= nil do
- table.insert(virusdatabase, bdatabase)
- bdatabase = f:read("*l")
- bdatabase = f:read("*l")
- end
- f:close()
- fs.delete("/disk/database")
- option = prompt(" ", "Welcome to 1lann\'s Rescue Disk! \(v0.5\)", "Would you like to continue", "Or go to the terminal?", " ", "Continue", "Terminal")
- if option == "Terminal" then
- term.clear()
- term.setCursorPos(1, 1)
- end
- else
- prompt("Uh oh! The rescue disk is infected!", "Please re-install the rescue disk", "and make sure that computer is", "off when you insert the rescue disk", "Press enter to shutdown", "Shutdown")
- os.shutdown()
- end
- end
- terminate = true
- end
- end
- local stime = false
- function show(bool)
- stime = bool
- end
- local running = true
- function run(bool)
- running = bool
- end
- terminate = false
- local function clockFunc()
- while running == true do
- while stime == true do
- x, y = term.getCursorPos()
- time = textutils.formatTime(os.time())
- term.setCursorPos(41,3)
- write(" ")
- term.setCursorPos(41,3)
- write(time)
- term.setCursorPos(x, y)
- sleep(0.03)
- end
- sleep(0.03)
- end
- end
- while terminate == false do
- parallel.waitForAny(clockFunc, main)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement