-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.lua
More file actions
238 lines (187 loc) · 5.14 KB
/
Copy pathmain.lua
File metadata and controls
238 lines (187 loc) · 5.14 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
local getgenv = getgenv or function()
return getfenv(0)
end
local Typeof, Type = typeof, type
local newproxy, getmetatable, assert, next, pcall, tostring, rawget, error = newproxy, getmetatable, assert, next, pcall, tostring, rawget, error
local tinsert, tunpack, tfind, tmove = table.insert, table.unpack, table.find, table.move
local format, split, rep, sub, gsub = string.format, string.split, string.rep, string.sub, string.gsub
local Instance_new = Instance.new
local Sandboxed, SandboxedData = {}, {}
local Signals = {}
local Options = {
Hooks = {}, -- Format it like: DataModel = {{"OpenScreenshotsFolder", function() while true do end end}} ReplicatedStorage = {}
Blocked = {
DataModel = {
"OpenScreenshotsFolder"
},
ScriptProfilerService = {
"SaveScriptProfilingData"
},
ScriptContext = {
"_ALL" -- fuck you script context burn
},
CaptureService = {
"_ALL"
}
}
}
local function Sandbox()end;
local function RBXScriptSignal()end;
local function ReverseGet(Value, Table)
Table = Table or Sandboxed
for Key, Value1 in next, Table do
if Value1 == Value then
return Key
end
end
end
local function Secure(A, ...)
if Typeof(A) == "table" then
local Value2 = {};
for i, v in next, A do
Value2[i] = Secure(v, ...)
end
return Value2
elseif Typeof(A) == "Instance" then
return Sandbox(A)
elseif Typeof(A) == "RBXScriptSignal" then
return Signals[A] or RBXScriptSignal(A)
elseif Typeof(A) == "function" then
local Object, Key, AllowRealValues = tunpack({...})
Object = Object
return function(...)
local Args = {...}
Args[1] = ReverseGet(Args[1])
if not AllowRealValues then
return Secure(
Object[Key](tunpack(Args))
)
else
local Args2 = {}
for a, b in next, Args do
Args2[a] = ReverseGet(b) or b
end
return Secure(Object[Key](tunpack(Args2)))
end
end
else
return A
end
end
RBXScriptSignal = function(Original: RBXScriptSignal)
local function Call(f, ...)
local Args = Secure({...})
f(tunpack(Args))
end
local userdata = newproxy(true);
local self = getmetatable(userdata);
self.__index = function(_, Key) -- self.__index(self, "Once")
local Success, A = pcall(function()
return Original[Key]
end)
assert(Success, A)
return function(_, f)
return Original[Key](Original, function(...)
Call(f, ...)
end)
end
end
self.__metatable = "The metatable is locked"
self.__tostring = function()
return "RBXScriptSignal"
end
Signals[Original] = userdata
return userdata
end
Sandbox = function(Object, Default, OpposeOnMethods)
if Sandboxed[Object] or not Object then
return Sandboxed[Object]
end
Default = Default or {}
OpposeOnMethods = OpposeOnMethods or {}
local userdata = newproxy(true)
local mt = getmetatable(userdata)
local Blocked = Options.Blocked[Object.ClassName] or {}
local Hooks = Options.Hooks[Object.ClassName] or {}
local BLOCK_ALL = tfind(Blocked, "_ALL")
local e = function()error("[SANDBOX] Blocked Function", 2)end
for a, b in next, Default do
mt[a] = b
end
for _, b in next, Blocked do
mt[b] = e
end
local function find(tbl, key, a)
a = a or tbl
for _, Value in next, tbl do
if sub(key, 1, #Value) == Value then
return a[Value]
end
end
end
mt.__index = function(_, key)
local raw = rawget(mt, key);
if raw then return raw end
local Block = find(Blocked, key, mt)
for _, Hook in next, Hooks do -- DUMBASS FUCKING FEATURE TOOK ME AROUND 3 HOURS TO FUCKING FIX RAHHHHHH
local Path, Value = Hook[1], Hook[2] -- "LocalPlayer.Kick", print
local Parts = split(Path, ".") -- {"LocalPlayer", "Kick"}
local First, Last = Parts[1], Parts[#Parts]; -- "LocalPlayer", "Kick"
local function Stupid_Sandbox(Index, REAL_Instance)
local Part = Parts[Index]
return Sandbox(REAL_Instance, {
[Part] = (
Index == #Parts and Value or Stupid_Sandbox(Index + 1, REAL_Instance[Part])
);
})
end
if First ~= Last then -- "LocalPlayer" ~= "Kick"
return Stupid_Sandbox(2, Object[First])
elseif First == Last then -- "LocalPlayer" == "Kick"
return Value
end
end
if Block then
return Block
elseif BLOCK_ALL and Typeof(Object[key]) == "function" then
return e
end
return Secure(Object[key], Object, key, (
not find(OpposeOnMethods, key) -- fxix
))
end
mt.__newindex = function(_, k, v)
Object[k] = ReverseGet(v) or v
end
mt.__metatable = "The metatable is protected"
mt.__tostring = function()
return tostring(Object) -- watafuck tostring(Object) is faster than Object.Name!!
end
Sandboxed[Object] = userdata
return userdata
end
local function HookService(Service, Methods)
Options.Hooks[Service] = Methods
end
local Instance_New = Instance.new
getgenv().Instance = table.freeze({
new = function(Class, Parent)
local Fake = Instance_New(Class);
if Typeof(Parent) == "userdata" then
Fake.Parent = ReverseGet(Parent);
end
return Sandbox(Fake)
end,
fromExisting = function(Fake)
return Sandbox(ReverseGet(Fake) or Fake)
end,
})
getgenv().typeof = function(a)
if ReverseGet(a) then
return "Instance"
elseif ReverseGet(a, Signals) then
return "RBXScriptSignal"
end
return Typeof(a)
end
return Sandbox, ReverseGet