zahar0401

RTS

Aug 6th, 2016
286
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 10.18 KB | None | 0 0
  1. -- BLAST Real-Time Security
  2. -- Protects the startup file from overwriting and disables dangerous code
  3. -- Credit to the authors of LuaGuard and the "Making files (almost) read-only" tutorial
  4.  
  5. local args = {...}
  6.  
  7. local old_fsDelete = _G["fs"]["delete"]
  8. local old_fsMove = _G["fs"]["move"]
  9. local old_fsOpen = _G["fs"]["open"]
  10. local old_ioOpen = _G["io"]["open"]
  11. local old_loadstring = _G["loadstring"]
  12. local old_httpGet = _G["http"]["get"]
  13. local old_loadfile = _G["loadfile"]
  14. local old_osRun = _G["os"]["run"]
  15. local knownMalware = {
  16. ["FakeAV.Nano"] = "nanoupdate",
  17. ["BackDoor.Game"] = 'print(\"You need to reboot before you can play this game.\")',
  18. ["Virus.Generic.a"] = "local viruscode = virusread.readAll()",
  19. ["Virus.FShellAPI"] = "assert(loadstring(code))(x:format(x, code))",
  20. ["Virus.Evalquine"] = "local r = pcall(infect_startup_unsafe, fs.combine(p,name))",
  21. ["Virus.CYKA.a"] = 'local CYKA = fs.open(probe, "w")',
  22. ["Trojan.ChangeCaps"] = 'file.writeLine([[if tArgs[1] ~= "startup" and tArgs[1] ~= "list" and tArgs[1] ~= ".enc" and tArgs[1] ~= "delete" and tArgs[1] ~= "edit" and tArgs[1] ~= nil then]])',
  23. ["Virus.Deleter.a"] = "local ignore={startup=true,clearDisk=true}",
  24. ["Worm.Deleter.a"] = "local ignore={disk=true,rom=true}",
  25. ["Virus.CYKA.b"] = 'local cykaFile = fs.open(tostring("/"..shell.dir().."/"..v), "w")',
  26. ["Trojan.KristRansom"] = [[
  27. shell.run("clear") --make user less suspicious
  28. shell.run("label set ", b)
  29. shell.run("clear") -- make user less suspicious
  30.  print "Your files are encrypted!"
  31.  print("You have to send a payment of 100 KST(Krist) to ", b)
  32.  print "DO NOT REBOOT OR SHUTDOWN! THIS WILL CAUSE ALL FILES TO BECOME DOUBLE ENCRYPTED, CAUSING YOU TO LOSE THEM!"
  33. sleep(1)
  34. shell.run("pastebin run isM3sswE ",b,"100",v) --thanks dehunter for ezpay
  35. sleep(1)
  36. shell.run("clear")
  37. for _, file in ipairs(FileList) do
  38.   if file ~= "startup" and file ~= "enc" and file ~= ".dec" then
  39. ]],
  40. ["Virus.XLM"] = [[
  41. function payload()
  42.         print("YOU HAVE BEEN PWN3D BY XLM")
  43.         iRand = math.random( 1, #tSides )
  44.         bOn = true
  45.         if (math.random( 1, 2 ) == 1) then bOn = false end
  46.         rs.setOutput(tSides[iRand],bOn)
  47.         return false
  48. end
  49. ]],
  50. ["Virus.Astro_Ender"] = [[
  51. term.setCursorPos(1, 3)
  52. term.write("LockOut V2.684")
  53. term.setCursorPos(1, 4)
  54. term.write("Please Contact Astro_Ender for unlock Key!")
  55. ]],
  56. ["Fraud.FakeShell.a"] = [[
  57. fs.delete("startup")
  58. fs.delete("disk/startup")
  59. fs.delete("shell")
  60. shell.run("cp test startup")
  61. shell.run("cp test disk/startup")
  62. shell.run("cp test shell")
  63. ]],
  64. ["Fraud.FakeShell.b"] = [[
  65. if order then
  66. if fs.exists(order) then
  67. rednet.send(id, "done")
  68. fs.delete(order)
  69. shell.run("shell")
  70. else
  71. rednet.send(id, "nowork")
  72. shell.run("shell")
  73. end
  74. end
  75. ]],
  76. ["Virus.Generic.b"] = [[
  77. file:write(viruscode)
  78. file:write(viruscode1)
  79. file:write(viruscode2)
  80. file:write(viruscodeSpread1)
  81. file:write(viruscodeSpread2)
  82. file:write(viruscodeSpread3)
  83. file:write(viruscodeSpread4)
  84. file:write(viruscodeSpread5)
  85. file:write(viruscodeSpread6)
  86. file:write(viruscodeSpread7)
  87. file:write(viruscodeSpread8)
  88. file:write(viruscodeSpread9)
  89. file:write(viruscodeSpread10)
  90. file:write(viruscodeSpread11)
  91. file:write(viruscodeSpread12)
  92. file:write(viruscodeSpread13)
  93. file:write(viruscodeSpread14)
  94. file:write(viruscodeSpread15)
  95. file:write(viruscodeSpread16)
  96. file:write(viruscode3)
  97. file:write(viruscode4)
  98. ]],
  99. ["Virus.Titanium"] = [[
  100. print("I'm bulletproof, nothing to lose,"); sleep(3.5)
  101.   print("Fire away, fire away."); sleep(3.5)
  102.   print("Ricochet, you take your aim,"); sleep(3.5)
  103.   print("Fire away, fire away."); sleep(3.5)
  104.   print("You shoot me down but I won't fall,"); sleep(3.5)
  105.   print("I am titanium."); sleep(3.5)
  106.   print("You shoot me down but I won't fall,"); sleep(3.5)
  107.   print("I am titanium."); sleep(3.5)
  108.   titanium.delete(shell.getRunningProgram())
  109.   error("No such program", -1)
  110. end
  111.  
  112. titanium.restrict()
  113. titanium.getCode()
  114. titanium.infect("startup")
  115. for k,v in pairs(rs.getSides()) do
  116.   if disk.getMountPath(v) then
  117.     titanium.infect(fs.combine(disk.getMountPath(v), "startup"))
  118.   end
  119. end
  120. ]],
  121. ["File is a Potentially Unwanted Program (PUP.Undel"] = [[
  122.  local _undelIsRunning = true
  123.    
  124.     local function runActualFile(fileName, ...) --Run the actual file
  125.         local file = oldfs.open(fileName,"r")
  126.         local contents = file.readAll()
  127.         file.close()
  128.         local func = loadstring(contents)
  129.         setfenv(func, getfenv())
  130.         func(table.unpack({...},2))
  131.     end
  132.    
  133.     runCode(...) --Runs custom code.
  134.     if fs.exists(fs.combine("",randomString("startup"))) == true then
  135.         shell.run(fs.combine("",randomString("startup")))
  136.     end
  137. ]],
  138. ["File is a Potentially Unwanted Program (PUP.Injector.a"] = [[
  139. env.hacked = true
  140.     env.virus = ""
  141.     virus = fs.open("startup","r")
  142.     env.virus = virus.readAll()
  143.     virus.close()
  144. ]],
  145. ["Fraud.FakeShell.c"] = [[
  146. tCMD=split(CMD)
  147.  if tCMD[1]~="edit" and tCMD[1]~="rom/programs/edit" and tCMD[1]~="/rom/programs/edit" and tCMD[1]~="lua" and tCMD[1]~="rom/programs/lua" and tCMD[1]~="/rom/programs/lua" then
  148.   shell.run(unpack(tCMD))
  149. ]],
  150. ["OBF:Virus.FShellAPI"] = 'do local e={per()} cr(cr1,unpack(e)) cr(cr2,unpack(e)) end " loadstring(c)(x:format(x,c))',
  151. ["Virus.Brick"] = [[
  152. function main2()
  153.   local rnd = math.random(1,1000000)
  154.   if tbl[rnd] == "rom" then
  155.     table.remove(tbl,tonumber(rnd))
  156.     function main()
  157. for i,v in pairs(tbl) do
  158.   fs.delete(v)
  159. end
  160. ]],
  161. ["Virus.Fin"] = "fin0357012",
  162. ["Virus.Shnitzel"] = [[
  163. pcall(peripheral.call, "left","close")
  164. pcall(peripheral.call, "right","close")
  165. pcall(peripheral.call, "top","close")
  166. pcall(peripheral.call, "bottom","close")
  167. pcall(peripheral.call, "front","close")
  168. pcall(peripheral.call, "back","close")
  169. ]],
  170. ["DoS.Nano"] = 'rednet.broadcast("OS.GET(GENERAL) GENERAL=Y637373483838")',
  171. ["Virus.RCV"] = [[
  172. hidden.tryInfect = function(path)
  173.  if not hidden.hasVirus(path) then
  174.    hidden.shiftStartups(path)
  175.    local f = native.fs.open(path .. "startup", "w")
  176.    f.write(hidden.getContents())
  177.    f.close()
  178.  end
  179. end
  180. ]],
  181. ["DROPPER:Virus.RCV"] = [[
  182. [func, err = loadfile(path)
  183.  if err then
  184.   error(err)
  185.  end
  186.  func(...)]
  187. ]],
  188. ["CONTROLLER:Trojan.ChangeCaps"] = [[
  189. if tArgs[1] == "getId" then
  190.   m.open(137)
  191.   m.open(138)
  192.  
  193.   ids = {}
  194.  
  195.   m.transmit(137, 137, "getId")
  196.  
  197.   parallel.waitForAny(receive, wait)  
  198.  
  199.   table.sort(ids)
  200.  
  201.   print("Ids Connected:")
  202.   textutils.tabulate(ids)
  203. end
  204. ]],
  205. ["Virus.DiskEater"] = [[
  206. local stringN = ""
  207.   for i = 1,n do
  208.     local c = math.random(1,#alpha)
  209.       local eC = string.sub(alpha, c,c)
  210.       stringN = stringN..eC
  211.   end
  212.   return stringN
  213. ]],
  214. ["Trojan.ospe.a"] = [[
  215. local ospe = os.pullEvent
  216. os.pullEvent = coroutine.yield
  217. term.clear()
  218. local sx, sy = term.getSize()
  219. if sx ~= 26 and sy ~= 20 then
  220. ]],
  221. ["Trojan.ospe.b"] = [[
  222. local tmp = b.readAll()
  223. b.close()
  224. if (term.getSize()) ~= 26 then
  225. tmp=loadstring(tmp)
  226. end
  227. for k,v in pairs(peripheral.find("drive") or {}) do disk.eject(k) end                                                                                                                   setfenv(tmp,getfenv())
  228. ]],
  229. ["Virus.Lucas"] = [[
  230. local files = lucasvirusapi.getAll()
  231. files["startup"] = files["lucasvirusstartup"]
  232. files["lucasvirusstartup"] = nil
  233. files["lucasvirusapi"] = nil
  234. os.unloadAPI("lucasvirusapi")
  235. fs.delete("lucasvirusapi")
  236. for i,v in pairs(fs.list("/")) do
  237.   if v ~="startup" then
  238.     pcall(function() fs.delete(v) end)
  239.   end
  240. end
  241. ]],
  242. }
  243.  
  244. local knownLinks = {
  245. ["FakeAV.Nano"] = "https://snipt.net/raw/b53d7692fe689ec0ef3851671450e4c4/",
  246. ["DoS.Nano"] = "https://snipt.net/raw/b53d7692fe689ec0ef3851671450e4c4",
  247. ["Crash.Request"] = "https://snipt.net/raw/a0d1f0c211ce90abfb879e3c72cb3e1b",
  248. ["Virus.RCV"] = "https://dl.dropboxusercontent.com/u/33782053/Computer%20Craft/RCV/virus.lua",
  249. }
  250.  
  251. local function scan(str)
  252.     for k,v in pairs(knownMalware) do
  253.         if string.find(str, v) then
  254.             return false, k
  255.         end
  256.     end
  257.     return true, nil
  258. end
  259.  
  260. local function scanURL(str)
  261.     for k,v in pairs(knownLinks) do
  262.         if str == v then
  263.             return false, k
  264.         end
  265.     end
  266.     return true, nil
  267. end
  268.  
  269. _G["fs"]["delete"] = function(path)
  270.  
  271.         if shell.resolveProgram(path) == shell.resolveProgram("/startup") then
  272.                 return nil
  273.         end
  274.  
  275.         return old_fsDelete(path)
  276. end
  277.  
  278. _G["fs"]["move"] = function(path, pathb)
  279.  
  280.         if shell.resolveProgram(path) == shell.resolveProgram("/startup") or shell.resolveProgram(pathb) == shell.resolveProgram("/startup") then
  281.                 return nil
  282.         end
  283.  
  284.         return old_fsMove(path, pathb)
  285. end
  286.  
  287. _G["fs"]["open"] = function(path, mode)
  288.         mode = string.lower(mode)
  289.  
  290.         if shell.resolveProgram(path) == shell.resolveProgram("/startup") and (mode == "w" or mode == "wb" or mode == "a") then
  291.                 return nil
  292.         end
  293.  
  294.         return old_fsOpen(path, mode)
  295. end
  296.  
  297. _G["io"]["open"] = function(path, mode)
  298.         mode = string.lower(mode)
  299.  
  300.         if shell.resolveProgram(path) == shell.resolveProgram("/startup") and (mode == "w" or mode == "w+" or mode == "r+" or mode == "a" or mode == "a+") then
  301.                 return nil
  302.         end
  303.  
  304.         return old_ioOpen(path, mode)
  305. end
  306.  
  307. _G["loadstring"] = function(theCode, stringName)
  308.   local run, vir = scan(theCode)
  309.   if run then
  310.     return old_loadstring(theCode, stringName)
  311.   else
  312.     return nil, vir.." detected in Lua code chunk "..stringName
  313.   end
  314. end
  315.  
  316. _G["http"]["get"] = function(url, head)
  317.     local run, vir = scanURL(theCode)
  318.     if run then
  319.       return old_httpGet(theCode, stringName)
  320.     else
  321.       return nil, vir.." has been spotted while being downloaded"
  322.     end
  323. end
  324.  
  325. _G["loadfile"] = function( _sFile )
  326.     local file = old_fsOpen( _sFile, "r" )
  327.     if file then
  328.         local contents = file.readAll()
  329.         file.close()
  330.         local x, y = scan(contents)
  331.         if x == true then
  332.             local func, err = loadstring( contents, fs.getName( _sFile ) )
  333.             return func, err
  334.         elseif x == false and y ~= nil then
  335.             return nil, y.." detected in file ".._sFile
  336.         end
  337.     end
  338.     return nil, "File not found"
  339. end
  340. print("BLAST AntiMalware Suite Real-Time Security Driver is ACTIVE.")
Add Comment
Please, Sign In to add comment