Created
December 5, 2020 12:33
-
-
Save Cheatoid/df7bfc607dee65b14b7d58ec77964a70 to your computer and use it in GitHub Desktop.
Alternative to hot-patch the backdoor in the E2Power addon; https://github.com/VelaEurope/E2Power/pull/7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Hot-patch the backdoor in the E2Power addon. | |
-- Place this in your server's autorun Lua. | |
if not (SERVER and file.Exists('entities/gmod_wire_expression2/core/custom/E2Power.lua', 'LUA')) then return end | |
-- Only run this if E2Power is installed. | |
local rawset, pairs, getinfo, getupvalue = rawset, pairs, debug.getinfo, debug.getupvalue | |
local function get_upvalues(func) | |
local info = getinfo(func, 'u') | |
if info then | |
local variables = {} | |
for i = 1, info.nups do rawset(variables, getupvalue(func, i)) end | |
return variables | |
end | |
end | |
local hook_GetTable, hook_Remove, timer_Simple, remove_backdoor = hook.GetTable, hook.Remove, timer.Simple | |
function remove_backdoor() | |
if E2Power then -- Wait for E2Power to load. | |
local hooks = hook_GetTable() | |
hooks = hooks['PlayerInitialSpawn'] | |
if hooks then | |
local first, second = hooks['E2P_runlua'], hooks['E2Power_CheckPlayer'] | |
if first and second then -- Wait for both hooks to be found. | |
-- Remove the backdoor. | |
for name, value in pairs(get_upvalues(first)) do | |
if name == 'WhiteList' then -- Clear the whitelist table. | |
for k in pairs(value) do rawset(value, k, nil) end | |
break | |
end | |
end | |
for name, value in pairs(get_upvalues(second)) do | |
if name == 'WhiteList' then -- Clear the whitelist table. | |
for k in pairs(value) do rawset(value, k, nil) end | |
break | |
end | |
end | |
hook_Remove('PlayerInitialSpawn', 'E2P_runlua') -- Finally, remove the useless hook. | |
--hook_Remove('PlayerInitialSpawn', 'E2Power_CheckPlayer') | |
return -- Done. Exit the loop. | |
end | |
end | |
end | |
timer_Simple(1, remove_backdoor) -- Keep looping until removed. | |
end | |
timer_Simple(10, remove_backdoor) -- Start the loop. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment