Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local tArgs = {...}
- local virusDB = {'fs.open((%p.)startup(%p.))', 'os.pullEvent = os.pullEventRaw', 'fs.delete((%p.)scan(%p.))'}
- -- Add virus code to virusDB (line above)
- percent = 0
- if #tArgs < 1 then
- print("Usage:")
- print("scan <program>")
- print("")
- error()
- end
- path = shell.resolve(tArgs[1])
- if fs.exists(path) == false then
- print("File does not exist.")
- error()
- end
- function status(lines)
- add = (100/lines)/#virusDB
- write(math.floor(percent))
- print("%")
- percent = percent + add
- end
- function scan(file, string)
- for w in string.gmatch(file, string) do
- return true
- end
- return false
- end
- function ready(tempFile)
- lines = #tempFile
- if #tempFile > 65 then
- quick = true
- else
- quick = false
- end
- for virNum = 1, #virusDB do
- for fileNum = 1, #tempFile do
- term.clear()
- term.setCursorPos(1,1)
- print("Searching for virus #"..virNum.." in "..tArgs[1])
- write("Results: ")
- val = scan(tempFile[fileNum], virusDB[virNum])
- print(val)
- write("Status: ")
- status(lines)
- if val == true then
- print("")
- print("************************")
- print(" Virus Info ")
- print("")
- print("Virus code: "..virusDB[virNum])
- print("Line number: "..fileNum)
- print("************************")
- print("")
- print("Would you like to delete this program? (Y/N)")
- act, key = os.pullEvent("key")
- if key == 21 then
- path = shell.resolve(tArgs[1])
- fs.delete(path)
- term.clear()
- term.setCursorPos(1,1)
- print("File removed.")
- error()
- end
- end
- if quick == false then
- sleep(.1)
- end
- end
- end
- end
- function read(file)
- f = fs.open(file, "r")
- fileData = {}
- nilLine = 0
- repeat
- table.insert(fileData, line)
- line = f.readLine()
- if line == nil then
- nilLine = nilLine + 1
- else
- nilLine = 0
- end
- until nilLine > 1
- f.close()
- ready(fileData)
- end
- read(tArgs[1])
- term.clear()
- term.setCursorPos(1,1)
- print("File scan complete. Scanned "..lines.." lines total.")
- if quick == true then
- print("File was scanned in hyper mode to save time.")
- end
- sleep(2)
- os.reboot()
Add Comment
Please, Sign In to add comment