Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- N-Virus by PaymentOption and theobjop --
- term.clear()
- term.setCursorPos(1,1)
- local selection = 1
- local sSide = ""
- local line = 0
- VERSION = 1.0
- function cPrint(height, string)
- local w,h = term.getSize()
- xPos = w/2 - string.len(string)/2
- term.setCursorPos(xPos, height)
- term.write(string)
- end
- function contains(str,find) --Returns true if @str contains @find by Vandie
- if not str then return nil end
- str = tostring(str)
- for n=1, #str-#find+1 do
- if str:sub(n,n+#find-1) == find then return true end
- end
- return false
- end
- function checkLocalDisk()
- local localFiles = fs.list("")
- local lines = 0
- for i=1, #localFiles do
- if fs.isDir(localFiles[i]) then break
- else
- line = line+1
- file = fs.open(localFiles[i], "r")
- fileContents = file.readLine()
- file.close()
- if contains(fileContents, "os.shutdown()") then
- fs.delete(localFiles[i])
- file = fs.open("startup", "w")
- file.write('print("N-Virus Detection in '.. localFiles[i] ..':")\nprint(string.rep("-", 50))\nprint("os.shutdown() virus:'..line..'")\n')
- file.write('sleep(2)\n')
- file.close()
- os.reboot()
- elseif contains(fileContents, "os.reboot()") then
- fs.delete(localFiles[i])
- file = fs.open("startup", "w")
- file.write('print("N-Virus Detection in '.. localFiles[i] ..':")\nprint(string.rep("-", 50))\nprint("os.reboot() virus:'..line..'")\n')
- file.write('sleep(2)\n')
- file.close()
- os.reboot()
- elseif contains(fileContents, ".delete()") then
- fs.delete(localFiles[i])
- file = fs.open("startup", "w")
- file.write('print("N-Virus Detection in '.. localFiles[i] ..':")\nprint(string.rep("-", 50))\nprint("fs.delete() virus:'..line..'")\n')
- file.write('sleep(2)\n')
- file.close()
- os.reboot()
- elseif contains(fileContents, "shell.run(") then
- if not contains(fileContents, ") -- N-Virus Protected") then
- fs.delete(localFiles[i])
- file = fs.open("startup", "w")
- file.write('print("N-Virus Detection in '.. localFiles[i] ..':")\nprint(string.rep("-", 50))\nprint("shell.run() virus:'..line..'")\n')
- file.write('sleep(2)\n')
- file.close()
- os.reboot()
- end
- else term.clear(); term.setCursorPos(1,1); cPrint(7, "All Clean! - N-Detect for NeXoS by PaymentOption"); sleep(2) end
- end
- end
- end
- function cPrint(height, string)
- local w,h = term.getSize()
- xPos = w/2 - string.len(string)/2
- term.setCursorPos(xPos, height)
- term.write(string)
- end
- function printMenu()
- term.setCursorPos(3,2)
- print("Version: "..VERSION)
- if selection == 1 then cPrint(6, "[ N-Check: Local Disk ]")
- else cPrint(6, " N-Check: Local Disk ") end
- if selection == 2 then cPrint(7, "[ N-Check: External Disk ]")
- else cPrint(7, " N-Check: External Disk ") end
- if selection == 3 then cPrint(8, "[ Exit ]")
- else cPrint(8, " Exit ") end
- end
- function printBorder()
- term.clear()
- term.setCursorPos(1,1)
- local borderSize = 48
- print(" ".. string.rep("#", borderSize))
- print(" ".."#" ..string.rep(" ", borderSize-2).. "#")
- print(" ".."#" ..string.rep(" ", borderSize-2).. "#")
- print(" ".."#" ..string.rep(" ", borderSize-2).. "#")
- print(" ".."#" ..string.rep(" ", borderSize-2).. "#")
- print(" ".."#" ..string.rep(" ", borderSize-2).. "#")
- print(" ".."#" ..string.rep(" ", borderSize-2).. "#")
- print(" ".."#" ..string.rep(" ", borderSize-2).. "#")
- print(" ".."#" ..string.rep(" ", borderSize-2).. "#")
- print(" ".."#" ..string.rep(" ", borderSize-2).. "#")
- print(" ".."#" ..string.rep(" ", borderSize-2).. "#")
- print(" ".."#" ..string.rep(" ", borderSize-2).. "#")
- print(" ".."#" ..string.rep(" ", borderSize-2).. "#")
- print(" ".."#" ..string.rep(" ", borderSize-2).. "#")
- print(" ".."#" ..string.rep(" ", borderSize-2).. "#")
- print(" ".. string.rep("#", borderSize))
- end
- function checkExternalDisk(side)
- term.clear()
- term.setCursorPos(1,1)
- if fs.exists("disk") and fs.isDir("disk") then
- local diskFiles = fs.list("disk/")
- for i=1, #diskFiles do
- file = fs.open("disk/" ..diskFiles[i], "r")
- if fs.isDir(diskFiles[i]) == false then
- repeat
- line = line+1
- fileContents = file.readLine()
- if contains(fileContents, "os.shutdown()") then
- file.close()
- fs.delete("disk/startup")
- file = fs.open("disk/startup", "w")
- file.write('print("N-Virus Detection on Disk/'.. diskFiles[i] ..':")\nprint(string.rep("-", 50))\nprint("os.shutdown() virus:'..line..'")\n')
- file.write('fs.delete("disk/' .. diskFiles[i].. '")')
- file.close()
- os.reboot()
- elseif contains(fileContents, "os.reboot()") then
- file.close()
- fs.delete("disk/startup")
- file = fs.open("disk/startup", "w")
- file.write('print("N-Virus Detection on Disk/'.. diskFiles[i] ..':")\nprint(string.rep("-", 50))\nprint("os.reboot() virus:'..line..'")\n')
- file.write('fs.delete("disk/' .. diskFiles[i].. '")')
- file.close()
- os.reboot()
- elseif contains(fileContents, ".delete()") then
- file.close()
- fs.delete("disk/startup")
- file = fs.open("disk/startup", "w")
- file.write('print("N-Virus Detection on Disk/'.. diskFiles[i] ..':")\nprint(string.rep("-", 50))\nprint("fs.delete() virus:'..line..'")\n')
- file.write('fs.delete("disk/' .. diskFiles[i].. '")')
- file.close()
- os.reboot()
- elseif contains(fileContents, "shell.run()") then
- file.close()
- if not contains(fileContens, "-- N-Virus Protected") then
- fs.delete("disk/startup")
- file = fs.open("disk/startup", "w")
- file.write('print("N-Virus Detection on Disk/'.. diskFiles[i] ..':")\nprint(string.rep("-", 50))\nprint("shell.run() virus:'..line..'")\n')
- file.write('fs.delete("disk/' .. diskFiles[i].. '")')
- file.close()
- os.reboot()
- end
- else term.clear(); cPrint(7, "All clean! - N-Detect for NeXoS by PaymentOption"); sleep(2); end
- until fileContents == nil
- line = 0
- else file.close() end
- end
- else term.clear(); cPrint(7, "No disk!") end
- end
- while true do
- printBorder()
- printMenu()
- event, key = os.pullEvent("key")
- if key == 200 and selection > 1 then selection = selection-1
- elseif key == 208 and selection < 3 then selection = selection+1
- end
- if selection == 1 and key == 28 then
- checkLocalDisk()
- term.clear()
- term.setCursorPos(1,1)
- elseif selection == 2 and key == 28 then
- term.clear()
- term.setCursorPos(1,1)
- cPrint(7, "Enter disk drive side: ")
- sSide = read()
- checkExternalDisk(sSide)
- term.clear()
- term.setCursorPos(1,1)
- elseif selection == 3 and key == 28 then term.clear(); term.setCursorPos(1,1); break end
- end
- --]]
Advertisement
Add Comment
Please, Sign In to add comment