forked from Upbolt/Hydroxide
-
Notifications
You must be signed in to change notification settings - Fork 1
/
ohaux.lua
54 lines (43 loc) · 1.77 KB
/
ohaux.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
local aux = {}
local getGc = getgc
local getInfo = debug.getinfo or getinfo
local getUpvalue = debug.getupvalue or getupvalue or getupval
local getConstants = debug.getconstants or getconstants or getconsts
local isXClosure = is_synapse_function or issentinelclosure or is_protosmasher_closure or is_sirhurt_closure or istempleclosure or checkclosure
local isLClosure = islclosure or is_l_closure or (iscclosure and function(f) return not iscclosure(f) end)
assert(getGc and getInfo and getConstants and isXClosure, "Your exploit is not supported")
local placeholderUserdataConstant = newproxy(false)
local function matchConstants(closure, list)
if not list then
return true
end
local constants = getConstants(closure)
for index, value in pairs(list) do
if constants[index] ~= value and value ~= placeholderUserdataConstant then
return false
end
end
return true
end
local function searchClosure(script, name, upvalueIndex, constants)
for _i, v in pairs(getGc()) do
local parentScript = rawget(getfenv(v), "script")
if type(v) == "function" and
isLClosure(v) and
not isXClosure(v) and
(
(script == nil and parentScript.Parent == nil) or script == parentScript
)
and pcall(getUpvalue, v, upvalueIndex)
then
if ((name and name ~= "Unnamed function") and getInfo(v).name == name) and matchConstants(v, constants) then
return v
elseif (not name or name == "Unnamed function") and matchConstants(v, constants) then
return v
end
end
end
end
aux.placeholderUserdataConstant = placeholderUserdataConstant
aux.searchClosure = searchClosure
return aux