-
Notifications
You must be signed in to change notification settings - Fork 50
/
Copy pathScriptDumper.lua
362 lines (283 loc) · 10.8 KB
/
ScriptDumper.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
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
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
--[[
Report any bugs, issues and detections to me if you don't mind (NoTwistedHere#6703)
V3 SaveInstance isn't the best so I had to make some adjustments in order for this to work with v3 :) (doesn't work though)
]]
local getname = function(Object) if Object:IsA("Script") and getscriptname then return getscriptname(Object) end return Object.Name end
local gethash = function(Object) local Success, Response = pcall(function() return getscripthash(Object) end) if Success and type(Response) == "string" then return Response end return; end
local Threading = loadstring(game:HttpGet("https://raw.githubusercontent.com/NoTwistedHere/Roblox/" .. (Branch or "main") .. "/Threading.lua"))()
local CoreGui, CorePackages, Players, RunService, RunService = game:GetService("CoreGui"), game:GetService("CorePackages"), game:GetService("Players"), game:GetService("RunService"), game:GetService("RunService")
local Result = "<roblox xmlns:xmime=\"http://www.w3.org/2005/05/xmlmime\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"http://www.roblox.com/roblox.xsd\" version=\"4\">"
local Decompiled, Scripts = 0, {}
local DecompiledScripts = {}
local IgnoreEmpty = IgnoreEmpty or true
local Threads = Threads or 10
local Instances = {
"LocalScript";
"ModuleScript";
"RemoteEvent";
"RemoteFunction";
}
local Services = {
"StarterPlayerScripts";
"StarterCharacterScripts";
}
local SpecialCharacters = {
["<"] = "<";
[">"] = ">";
["&"] = "&";
["\""] = """;
["'"] = "'";
}
local Timeout = Timeout or 60 --// Decompiler timeout (in seconds)
if not RunService:IsRunning() then --// So you can dump scripts in games that do a bit of funny business (I'm mainly trying to patch the things I come up with)
local function IsNetworkOwner(Object)
if Object:IsA("BasePart") and isnetworkowner(Object) then
return true
elseif not Object.Parent then
return false
end
return IsNetworkOwner(Object.Parent)
end
game.DescendantAdded:Connect(function(Obj)
if Obj:IsA("LocalScript") then
--if not Obj:IsDescendantOf(workspace) then --// when will I be able to spoof network replication :(
Obj.Disabled = true --// Not my fault if a game dev is actually smart (or maybe it is)
--end
end
end)
repeat
task.wait(0.5) --// There's no rush
until RunService:IsRunning()
end
local LocalPlayer = Players.LocalPlayer
local InstancesCreated, InstancesTotal = 0, #game:GetDescendants()
local Place = game:GetService("MarketplaceService"):GetProductInfo(game.PlaceId)
local GameName = tostring(Place and Place.Name or "Unknown Game"):gsub("[^%w%s]", "")
local MainDirectory, SubDirectory, FileName, FileType, Final = "Game Dumps/", ("%d-%s/"):format(game.PlaceId, GameName), ("Scripts for %s [%s-%s]"):format(GameName, game.GameId, game.PlaceVersion), ".rbxlx", ""
if not isfolder(MainDirectory) then
makefolder(MainDirectory)
end
if not isfolder(MainDirectory..SubDirectory) then
makefolder(MainDirectory..SubDirectory)
end
if isfile(MainDirectory..SubDirectory..FileName..FileType) then
local Name, Count = "", 0
repeat
Count += 1
Name = FileName..(" (%d)"):format(Count)
until not isfile(MainDirectory..SubDirectory..Name..FileType)
FileName = Name
end
Final = MainDirectory..SubDirectory..FileName..FileType
local function GiveColour(Current, Max)
return (Current < Max * 0.25 and "@@RED@@") or (Current < Max * 0.5 and "@@YELLOW@@") or (Current < Max * 0.75 and "@@CYAN@@") or "@@GREEN@@"
end
local function GetLoading()
local SpinnerCount = 0
return function()
local Chars = { "|", "/", "—", "\\" }
SpinnerCount += 1
if SpinnerCount > #Chars then
SpinnerCount = 1
end
return " "..Chars[SpinnerCount]
end
end
local function ProgressBar(Header, Current, Max, Thread)
local Size, PreviousCur, PreviousMax, Complete = 80, Current, Max, Current == Max
local Loading = GetLoading()
local LoadingChar = Loading()
local function Update(Current, Max, Extra_After)
local Progress, Percentage = math.floor(Size * Current / Max), math.floor(100 * Current / Max)
if Complete then
return;
end
PreviousCur = Current
PreviousMax = Max
rconsoleprint(GiveColour(Current, Max))
rconsoleprint(("\13%s%s %s%s"):format(("#"):rep(Progress), ("."):rep(Size - Progress), Percentage.."%", Percentage == 100 and "!\n" or Extra_After or LoadingChar))
rconsoleprint("@@WHITE@@")
if Percentage == 100 then
Complete = true
end
end
rconsoleprint(Header.."\n")
task.spawn(function()
while not Complete and (not Thread and true or coroutine.status(Thread) ~= "dead") do
LoadingChar = Loading()
Update(PreviousCur, PreviousMax, LoadingChar)
task.wait(0.25)
end
end)
return function(...)
task.spawn(Update, ...)
end
end
local function CheckObject(Object)
for _, v in next, Instances do
if Object:FindFirstChildWhichIsA(v, true) or Object:IsA(v) then
return true
end
end
return false
end
local function FindService(Service)
local Success, Response = pcall(game.FindService, game, Service)
return Success and Response
end
local function FindScripts(Table)
for i, v in next, Table do
if typeof(v) == "Instance" and (v:IsA("LocalScript") or v:IsA("ModuleScript")) or (not IgnoreEmpty or IgnoreEmpty and not gethash(v)) then
return true
end
end
return false
end
local function GetClassName(Object)
local ClassName = Object.ClassName
if (Object:IsA("LocalScript") or Object:IsA("ModuleScript")) and not gethash(Object) and IgnoreEmpty then
if not FindScripts(Object:GetDescendants()) then
return;
end
end
if table.find(Instances, ClassName) or table.find(Services, ClassName) or FindService(ClassName) then
return ClassName
end
return "Folder"
end
local function SteralizeString(String)
return String:gsub("['\"<>&]", SpecialCharacters)
end
local function MakeInstance(Object, PGB)
local ClassName = GetClassName(Object)
if not ClassName then
return ""
end
local IntResult = ("<Item class=\"%s\" referent=\"RBX%s\"><Properties><string name=\"Name\">%s</string>"):format(ClassName, Object:GetDebugId(0), SteralizeString(getname(Object)))
if (ClassName == "LocalScript" or ClassName == "ModuleScript") then
local Hash = gethash(Object)
local Source = Hash and (DecompiledScripts[Hash] or "--// Failed to decompile") or "--// Script has no bytecode"
if ClassName == "LocalScript" then
IntResult ..= ("<bool name=\"Disabled\">%s</bool>"):format(tostring(Object.Disabled or not Hash))
end
IntResult ..= ([==[<ProtectedString name="Source"><![CDATA[%s]]></ProtectedString>]==]):format(("--// Hash: %s\n%s"):format(Hash or "nil", Source))
end
IntResult ..= "</Properties>"
for _, v in next, Object:GetChildren() do
if v ~= nil and v ~= game and CheckObject(v) then --// Give me stength
IntResult ..= MakeInstance(v, PGB)
end
end
IntResult ..= "</Item>"
InstancesCreated += 1
PGB(InstancesCreated, InstancesTotal)
return IntResult
end
local function Save()
Result ..= "</roblox>"
writefile(Final, Result)
end
local function GetScripts(Table, C)
local PGB = ProgressBar(("Collecting Scripts [%s]"):format(C), 0, 1, coroutine.running())
for i, v in next, Table do
if (not v:IsA("LocalScript") and not v:IsA("ModuleScript")) or (v:IsDescendantOf(CoreGui) or v:IsDescendantOf(CorePackages)) or table.find(Scripts, v) then
continue;
end
PGB(i, #Table)
table.insert(Scripts, v)
end
PGB(1, 1)
end
local function Decompile(...)
--if Timeout == 0 then
return decompile(...)
--end
--[[local Thread, Completed = coroutine.running(), false
local DecompThread = task.spawn(function(...)
local Source = decompile(...)
Completed = true
if coroutine.status(Thread) ~= "suspended" then
repeat
task.wait(0.2) --// There's no rush
until coroutine.status(Thread) == "suspended"
end
return coroutine.resume(Thread, Source)
end, ...)
task.delay(Timeout, function()
if Completed then
return;
end
coroutine.close(DecompThread)
return coroutine.resume(Thread)
end)
return coroutine.yield()]]
end
local function FindNextScript()
for i, v in next, Scripts do
Scripts[i] = nil
return v
end
end
local function DecompileScripts()
local ThreadingGroup = Threading.new("Group", true)
local Ended = false
local PGB = ProgressBar(("\nDecompiling Scripts [%s]"):format(#Scripts), 0, #Scripts, coroutine.running())
while true do
if Ended then
break;
elseif ThreadingGroup.Active == Threads then
ThreadingGroup.Available:Wait("fg", Threads)
end
ThreadingGroup:Add(function()
local Script = FindNextScript()
if not Script then
Ended = true
ThreadingGroup.Ended:Fire()
return;
end
local Hash = gethash(Script)
if Hash and not DecompiledScripts[Hash] then
DecompiledScripts[Hash] = "--// Decompiling..."
DecompiledScripts[Hash] = Decompile(Script) or "--// Failed to decompile"
end
Decompiled += 1
PGB(Decompiled, #Scripts)
end)
end
ThreadingGroup.Ended:Wait()
end
RunService:Set3dRenderingEnabled(false)
rconsoleclear()
rconsolename("Script Dumper")
GetScripts(getscripts(), "Running")
GetScripts(getnilinstances(), "Nil")
GetScripts(game:GetDescendants(), "Game")
DecompileScripts()
local InstanceCreatedPGB = ProgressBar("\nCreating XML", InstancesCreated, InstancesTotal, coroutine.running())
for i, v in next, game:GetChildren() do
if v == CoreGui or v == CorePackages then
continue;
end
Result ..= MakeInstance(v, InstanceCreatedPGB)
end
Result..= MakeInstance({
ClassName = "Folder";
Name = "Nil Instances";
Parent = game;
GetChildren = function()
return getnilinstances()
end;
GetDebugId = function()
return Instance.new("Folder"):GetDebugId(0)
end;
FindFirstChildWhichIsA = function()
return true
end;
IsA = function(_, IsA)
return IsA == "Folder"
end
}, InstanceCreatedPGB)
InstanceCreatedPGB(1, 1)
Save()
rconsoleprint("\nFinished")
RunService:Set3dRenderingEnabled(true)