Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Function to read the content of a file
- local function readFile(filePath)
- if fs.exists(filePath) then
- local file = fs.open(filePath, "r")
- local content = file.readAll()
- file.close()
- return content
- end
- return nil
- end
- -- Function to check for malicious code
- local function containsMaliciousCode(content)
- local maliciousPatterns = {
- "/disk/os",
- "/disk/boot",
- "/disk/bootloader",
- "/disk/security"
- }
- for _, pattern in ipairs(maliciousPatterns) do
- if string.find(content, pattern) then
- return true
- end
- end
- return false
- end
- -- Function to get disk information
- local function getDiskInfo()
- for _, side in ipairs({"left", "right", "top", "bottom", "front", "back"}) do
- if disk.isPresent(side) then
- return disk.getID(side), side
- end
- end
- return nil, nil
- end
- -- Main function to check and manage startup scripts
- local function checkStartupScripts()
- local diskID, diskSide = getDiskInfo()
- if not diskID then
- print("No disk drive detected.")
- return
- end
- local startupPaths = {"/disk2/startup", "/disk2/startup.lua"}
- for _, path in ipairs(startupPaths) do
- if fs.exists(path) then
- local content = readFile(path)
- if content then
- if containsMaliciousCode(content) then
- print("Doggy OS Boot Manager has blocked a startup script from loading")
- print("Disk ID: " .. diskID)
- print("Disk Side: " .. diskSide)
- print("The script contains malicious code.")
- return
- else
- print("Launching /disk/boot/BIOS")
- shell.run("/disk/boot/BIOS")
- return
- end
- end
- end
- end
- print("No startup script found. Launching /disk/boot/BIOS")
- shell.run("/disk/boot/BIOS")
- end
- -- Run the check
- checkStartupScripts()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement