Hello! I am trying to make an antivirus to remove backdoors!
I know how to get the content of other scripts, get certain words like Require and delete scripts via one script!
But can I also get the value inside of that require void?
Hello! I am trying to make an antivirus to remove backdoors!
I know how to get the content of other scripts, get certain words like Require and delete scripts via one script!
But can I also get the value inside of that require void?
Note that im using a plugin as anti-backdoor!
The script for the plugin:
local PossibleVirus = game.Workspace.Model.NotAVirus
local content = PossibleVirus.Source
local match = string.match(content, "Require")
if match then
--Something to be executed
end
The virus script:
--This aint a virus trust me
Require(someid)
I want to get that
someid
Actually not as difficult as you think it is!
Using string.split
would be able to do exactly what you want it to do.
Also, I’d like to correct you as Require is not capitalized, and another thing: remember people can also use getfenv
to instead send require
in bytecode. getfenv(72657175697265)(module)
I believe is how you do that. The 72 name by the way is the bytecode of the word require.
This pattern: "require%(([%w%p]+)%)"
used with string.match
or string.gmatch
will find the parameters of a require
call.
[Edit]: modified it to check for calls to getfenv
as well. More functions can be added if needed.
local sample = [[
someFunc(1)
local n = require(12345)
someOtherFunc(3)
local m = require(workspace.Script)
local f = getfenv('require')
]]
local functionsToLookFor = {"require", "getfenv"}
local matches = {}
for _, func in ipairs(functionsToLookFor) do
for match in sample:gmatch(func.."%(([%w%p]+)%)") do
table.insert(matches, func..": "..match)
end
end
table.foreach(matches, print)
Sounds good! Can you give an example of how to implement that?
I recommend actually using @blokav’s method if I’m being honest, the only thing I would add is a way to find getfenv
require’s.
Also all the weird stuff in his code are considered string patterns. Kudos to him I didn’t even think of that immediately, but that would find every thing required and not just one.
Can I use this to detect functions using the TeleportService too?
Updated:
local sample = [[
MarketPlaceService:PromptPurchase(player, thing)
someFunc(1)
local n = require(12345)
someOtherFunc(3)
local m = require(workspace.Script)
local f = getfenv('require')
game.TeleportService.Teleport(somegame, someplayer)
]]
local pattern = "%(([%w%p ]+)%)"
local functionsToLookFor = {"require", "getfenv", "Teleport", "PromptPurchase"}
local matches = {}
for _, func in ipairs(functionsToLookFor) do
for match in sample:gmatch(func..pattern) do
table.insert(matches, func..": "..match)
end
end
table.foreach(matches, print)