Advertisement
Shocker130000

Decom

Aug 7th, 2018
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.67 KB | None | 0 0
  1. local Classes; -- Author @Rerumu <3
  2. local Props = {};
  3. local Concat = table.concat; -- Concatenation is going to get reworked just a couple times maybe?
  4. local tostring = tostring;
  5. local Players = game:GetService('Players');
  6. local Beat = game:GetService('RunService').Heartbeat;
  7.  
  8. -- Changelog
  9. --[[
  10. * Whatever version this is
  11. - Delays improved
  12. - Changed how LocalPlayer and nil are handled
  13. -- Fixed Synapse support
  14. --- Added a cache tick for Elysian
  15. ---- Fix to an error that broke IO
  16. ]]
  17.  
  18. local UseCache = true; -- Set to false to disable script decompile cache
  19.  
  20. local InNil;
  21. local Print;
  22. local WritesFl;
  23. local Decompile;
  24.  
  25. local SaveList = {
  26. game:GetService('Workspace');
  27. game:GetService('ReplicatedFirst');
  28. game:GetService('ReplicatedStorage');
  29. game:GetService('ServerStorage'); -- Internal stuff
  30. game:GetService('Lighting');
  31. game:GetService('StarterGui');
  32. game:GetService('StarterPack');
  33. game:GetService('StarterPlayer');
  34. game:GetService('Teams');
  35. game:GetService('InsertService');
  36. };
  37.  
  38. local IgnoredList = {
  39. 'CameraScript';
  40. 'ControlScript';
  41. 'ChatScript';
  42. 'BubbleChat';
  43. 'Camera';
  44. }
  45.  
  46. local NoNoProp = {
  47. Instance = {
  48. Archivable = true,
  49. DataCost = true,
  50. ClassName = true,
  51. RobloxLocked = true,
  52. Parent = true
  53. };
  54. BasePart = {
  55. Position = true,
  56. Rotation = true
  57. };
  58. };
  59.  
  60. for Idx = 1, 3 do
  61. local Ran, Err = ypcall(function()
  62. Classes = game:HttpGet('http://anaminus.github.io/rbx/json/api/latest.json', true);
  63. -- Classes = game:GetService('HttpService'):GetAsync('http://anaminus.github.io/rbx/json/api/latest.json');
  64. end);
  65.  
  66. if (not Ran) then
  67. if (Idx == 3) then
  68. error(Err, 0);
  69. else
  70. wait(1);
  71. end;
  72. else -- Setup stuff
  73. local Me = Players.LocalPlayer;
  74.  
  75. for _, Player in next, Players:GetPlayers() do
  76. if (Player ~= Me) then
  77. table.insert(IgnoredList, tostring(Player)); -- Let's *not*
  78. end;
  79. end;
  80.  
  81. local NumIg = #IgnoredList;
  82.  
  83. Classes = game:GetService('HttpService'):JSONDecode(Classes);
  84.  
  85. for Idx = 1, NumIg do
  86. IgnoredList[IgnoredList[Idx]] = true;
  87. IgnoredList[Idx] = nil;
  88. end;
  89.  
  90. break;
  91. end;
  92. end;
  93.  
  94. if elysianexecute then -- Scripts is handled async in Elysian because the decompiler is callback based
  95. local Sources = {};
  96.  
  97. InNil = getnilinstances;
  98. WritesFl = writefile;
  99.  
  100. function Decompile(Script) -- Austin finna gonna make me die
  101. local Name = Script.Name; -- Remove if you don't want a cache
  102. local Scr;
  103.  
  104. if UseCache then
  105. Scr = Sources[Name];
  106. end;
  107.  
  108. if (not Scr) then
  109. local Timeout = tick() + 8;
  110.  
  111. local Ran, Err = decompile(Script, 'unluac', newcclosure(function(Res, Err) -- Fix or something on newcclosure
  112. if Res then
  113. Scr = Res:gsub('\r+', ''); -- Austin-proof newline machine
  114. else
  115. Scr = '--[[\n' .. tostring(Err) .. '\n--]]';
  116. end;
  117. end));
  118.  
  119. if (not Ran) then
  120. Scr = '--[[\n' .. tostring(Err) .. '\n--]]';
  121. else
  122. Print('Decompiling ' .. Script:GetFullName());
  123.  
  124. Beat:wait();
  125. end;
  126.  
  127. while (not Scr) do
  128. if (tick() > Timeout) then
  129. Print('Script timeout ' .. Script:GetFullName());
  130.  
  131. Scr = '-- Unluac timed out, falling back to LuaDec\n';
  132.  
  133. Beat:wait();
  134. Beat:wait();
  135.  
  136. Ran, Err = decompile(Script);
  137.  
  138. if Ran then
  139. Print('LuaDec fallback succeeded');
  140.  
  141. Scr = Scr .. Ran;
  142. else
  143. Scr = Scr .. '--[[\n' .. tostring(Err) .. '\n--]]';
  144. end;
  145.  
  146. break;
  147. else
  148. Beat:wait(); -- Shouldn't cause an issue
  149. Beat:wait();
  150. end;
  151. end;
  152.  
  153. Sources[Name] = Scr;
  154. end;
  155.  
  156. return Scr;
  157. end;
  158.  
  159. function Print(String)
  160. printconsole(String, 100, 200, 180);
  161. end;
  162.  
  163. Print('ReruSavePlace detected Elysian, functions loaded');
  164. elseif Synapse then -- Oh my god 3ds why couldn't you just use '.' syntax
  165. function InNil()
  166. return Synapse:GetNilInstances();
  167. end;
  168.  
  169. function WritesFl(Location, Data)
  170. return Synapse:WriteFile(Location, Data);
  171. end;
  172.  
  173. function Decompile(Script)
  174. return Synapse:Decompile(Script);
  175. end;
  176.  
  177. Print = warn;
  178.  
  179. Print('ReruSavePlace detected Synapse, functions loaded');
  180. else
  181. error('This exploit may not be supported by RSP, please contact me');
  182. end;
  183.  
  184. do
  185. local Temp = {};
  186.  
  187. for Idx, Val in next, Classes do
  188. if (Val.type == 'Class') then
  189. Temp[Val.Name] = Val;
  190. Temp[Val.Name].Properties = {};
  191. elseif (Val.type == 'Property') then
  192. local Ignore;
  193.  
  194. for _, Tag in next, Val.tags do
  195. if (Tag == 'deprecated') or (Tag == 'readonly') then
  196. Ignore = true;
  197.  
  198. break;
  199. end;
  200. end;
  201.  
  202. if (not Ignore) then
  203. local Ignored = NoNoProp[Val.Class];
  204.  
  205. if Ignored and Ignored[Val.Name] then
  206. Ignore = true;
  207. end;
  208.  
  209. if (not Ignore) then
  210. local Props = Temp[Val.Class].Properties;
  211.  
  212. Props[#Props + 1] = Val;
  213. end;
  214. end;
  215. end;
  216. end;
  217.  
  218. Classes = Temp;
  219. end;
  220.  
  221. local function PropsOf(Obj)
  222. if Props[Obj.ClassName] then
  223. return Props[Obj.ClassName];
  224. end;
  225.  
  226. local Prop = {};
  227. local Class = Obj.ClassName;
  228.  
  229. while Class do
  230. local Curr = Classes[Class];
  231.  
  232. for Index, Value in next, Curr.Properties do
  233. Prop[#Prop + 1] = Value;
  234. end;
  235.  
  236. Class = Curr.Superclass;
  237. end;
  238.  
  239. table.sort(Prop, function(A, B)
  240. return A.Name < B.Name;
  241. end);
  242.  
  243. Props[Obj.ClassName] = Prop;
  244.  
  245. return Prop;
  246. end;
  247.  
  248. local function SetParent(Obj, Parent)
  249. local Cloned;
  250.  
  251. if Obj.Archivable then
  252. Cloned = Obj:Clone();
  253. end;
  254.  
  255. if (not Cloned) then
  256. local pcall = pcall;
  257.  
  258. Cloned = Instance.new'Folder'
  259.  
  260. for Index, Child in next, Obj:GetChildren() do
  261. pcall(SetParent, Child, Cloned);
  262. end;
  263.  
  264. Cloned.Name = Obj.Name .. ':' .. Obj.ClassName;
  265. end;
  266.  
  267. Cloned.Parent = Parent;
  268. end;
  269.  
  270. local function SavePlaceAsync()
  271. local Count = 0;
  272. local Final = {};
  273. local Timer = tick();
  274. local Saved = setmetatable({}, {__index = function(This, Idx) local C = Count + 1; Count = C; This[Idx] = C; return C; end});
  275.  
  276. local pcall = pcall; -- Skid syndrome
  277.  
  278. Final[1] = '<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"><External>null</External><External>nil</External>';
  279. Print('Saving place...');
  280.  
  281. local function SaveInstance(Obj)
  282. if Classes[Obj.ClassName] and (not IgnoredList[Obj.Name]) then
  283. local Props = PropsOf(Obj);
  284. local Num = Saved[Obj];
  285. local Conversions = {
  286. ['&'] = '&amp;';
  287. ['<'] = '&lt;';
  288. ['>'] = '&gt;';
  289. }
  290.  
  291. Final[#Final + 1] = '<Item class="' .. Obj.ClassName .. '" referent="RBX' .. Num .. '"><Properties>';
  292.  
  293. if ((Num % 1080) == 0) then
  294. Beat:wait();
  295. end;
  296.  
  297. for _, Prop in next, Props do
  298. local Append;
  299. local Type = Prop.ValueType;
  300. local ObjProp = Prop.Name;
  301. local Objp = Obj[ObjProp];
  302.  
  303. if (typeof(Objp) == 'EnumItem') then
  304. Append = '<token name="' .. ObjProp .. '">' .. Objp.Value .. '</token>';
  305. else
  306. if (Type == 'bool') then
  307. Append = '<bool name="' .. ObjProp .. '">' .. tostring(Objp) .. '</bool>';
  308. elseif (Type == 'float') then
  309. Append = '<float name="' .. ObjProp .. '">' .. tostring(Objp) .. '</float>';
  310. elseif (Type == 'int') then
  311. Append = '<int name="' .. ObjProp .. '">' .. tostring(Objp) .. '</int>';
  312. elseif (Type == 'double') then
  313. Append = '<float name="' .. ObjProp .. '">' .. tostring(Objp) .. '</float>';
  314. elseif (Type == 'string') then
  315. local String = Objp:gsub("[&<>]", Conversions); -- Because I got C O M P L A I N T S
  316.  
  317. Append = '<string name="' .. ObjProp .. '">' .. String .. '</string>';
  318. elseif (Type == 'BrickColor') then
  319. Append = '<int name="' .. ObjProp .. '">' .. Objp.Number .. '</int>';
  320. elseif (Type == 'Vector2') then
  321. Append =
  322. '<Vector2 name="' .. ObjProp .. '">'
  323. .. '<X>' .. Objp.x .. '</X>'
  324. .. '<Y>' .. Objp.y .. '</Y>'
  325. .. '</Vector2>'
  326. elseif (Type == 'Vector3') then
  327. Append =
  328. '<Vector3 name="' .. ObjProp .. '">'
  329. .. '<X>' .. Objp.x .. '</X>'
  330. .. '<Y>' .. Objp.y .. '</Y>'
  331. .. '<Z>' .. Objp.z .. '</Z>'
  332. .. '</Vector3>'
  333. elseif (Type == 'CoordinateFrame') then
  334. local X, Y, Z, R00, R01, R02, R10, R11, R12, R20, R21, R22 = Objp:components()
  335.  
  336. Append =
  337. '<CoordinateFrame name="' .. ObjProp .. '">'
  338. .. '<X>' .. X .. '</X>'
  339. .. '<Y>' .. Y .. '</Y>'
  340. .. '<Z>' .. Z .. '</Z>'
  341. .. '<R00>' .. R00 .. '</R00>'
  342. .. '<R01>' .. R01 .. '</R01>'
  343. .. '<R02>' .. R02 .. '</R02>'
  344. .. '<R10>' .. R10 .. '</R10>'
  345. .. '<R11>' .. R11 .. '</R11>'
  346. .. '<R12>' .. R12 .. '</R12>'
  347. .. '<R20>' .. R20 .. '</R20>'
  348. .. '<R21>' .. R21 .. '</R21>'
  349. .. '<R22>' .. R22 .. '</R22>'
  350. .. '</CoordinateFrame>'
  351. elseif (Type == 'Content') then
  352. local String = Objp:gsub("[&<>]", Conversions);
  353.  
  354. Append = '<Content name="' .. ObjProp .. '"><url>' .. String .. '</url></Content>';
  355. elseif (Type == 'UDim2') then
  356. local Objp = Objp;
  357.  
  358. Append =
  359. '<UDim2 name="' .. ObjProp .. '">'
  360. .. '<XS>' .. Objp.X.Scale .. '</XS>'
  361. .. '<XO>' .. Objp.X.Offset .. '</XO>'
  362. .. '<YS>' .. Objp.Y.Scale .. '</YS>'
  363. .. '<YO>' .. Objp.Y.Offset .. '</YO>'
  364. .. '</UDim2>'
  365. elseif (Type == 'Color3') then
  366. Append =
  367. '<Color3 name="' .. ObjProp .. '">'
  368. .. '<R>' .. Objp.r .. '</R>'
  369. .. '<G>' .. Objp.g .. '</G>'
  370. .. '<B>' .. Objp.b .. '</B>'
  371. .. '</Color3>'
  372. elseif (Type == 'NumberRange') then
  373. Append =
  374. '<NumberRange name="' .. ObjProp .. '">'
  375. .. tostring(Objp.Min)
  376. .. ' '
  377. .. tostring(Objp.Max)
  378. .. '</NumberRange>'
  379. elseif (Type == 'NumberSequence') then
  380. local Ob = {};
  381.  
  382. Ob[1] = '<NumberSequence name="' .. ObjProp .. '">'
  383.  
  384. for i, v in next, Objp.Keypoints do
  385. Ob[#Ob + 1] = tostring(v.Time) .. ' ' .. tostring(v.Value) .. ' ' .. tostring(v.Envelope) .. ' ';
  386. end
  387.  
  388. Ob[#Ob + 1] = '</NumberSequence>';
  389.  
  390. Append = Concat(Ob);
  391. elseif (Type == 'ColorSequence') then
  392. local Ob = {};
  393.  
  394. Ob[1] = '<ColorSequence name="' .. ObjProp .. '">'
  395.  
  396. for i, v in next, Objp.Keypoints do
  397. Ob[#Ob + 1] = Concat{tostring(v.Time) .. ' ' .. tostring(v.Value.r) .. ' ' .. tostring(v.Value.g) .. ' ' .. tostring(v.Value.b), " 0 "};
  398. end
  399.  
  400. Ob[#Ob + 1] = '</ColorSequence>';
  401.  
  402. Append = Concat(Ob);
  403. elseif (Type == 'Rect2D') then
  404. Append =
  405. '<Rect2D name="' .. ObjProp .. '">'
  406. .. '<min>'
  407. .. '<X>' .. tostring(Objp.Min.X) .. '</X>'
  408. .. '<Y>' .. tostring(Objp.Min.Y) .. '</Y>'
  409. .. '</min>'
  410. .. '<max>'
  411. .. '<X>' .. tostring(Objp.Max.X) .. '</X>'
  412. .. '<Y>' .. tostring(Objp.Max.Y) .. '</Y>'
  413. .. '</max>'
  414. .. '</Rect2D>'
  415. elseif (Type == 'ProtectedString') then
  416. local Src;
  417.  
  418. if (ObjProp == 'Source') then
  419. if (Obj.ClassName ~= 'Script') then
  420. local Sc, Er = Decompile(Obj);
  421.  
  422. if (not Sc) then
  423. Src = '--[[\n\t' .. Er .. '\n--]]';
  424. else
  425. Src = Sc;
  426. end;
  427. else
  428. Src = '-- Server script not decompiled :(';
  429. end;
  430. else
  431. Src = '';
  432. end;
  433.  
  434. Append = '<ProtectedString name="' .. ObjProp .. '"><![CDATA[' .. Src .. ']]></ProtectedString>';
  435. elseif (Type == 'Object') then
  436. if (not Objp) then
  437. Objp = 'null';
  438. else
  439. Objp = 'RBX' .. Saved[Objp];
  440. end;
  441.  
  442. Append = '<Ref name="' .. ObjProp .. '">' .. Objp .. '</Ref>';
  443. elseif (Type == 'PhysicalProperties') then
  444. if Objp then
  445. Append =
  446. '<PhysicalProperties name="' .. ObjProp .. '"><CustomPhysics>true</CustomPhysics>'
  447. .. '<Density>' .. tostring(Objp.Density) .. '</Density>'
  448. .. '<Friction>' .. tostring(Objp.Friction) .. '</Friction>'
  449. .. '<Elasticity>' .. tostring(Objp.Elasticity) .. '</Elasticity>'
  450. .. '<FrictionWeight>' .. tostring(Objp.FrictionWeight) .. '</FrictionWeight>'
  451. .. '<ElasticityWeight>' .. tostring(Objp.ElasticityWeight) .. '</ElasticityWeight>'
  452. .. '</PhysicalProperties>'
  453. else
  454. Append = '<PhysicalProperties name="' .. ObjProp .. '"><CustomPhysics>false</CustomPhysics></PhysicalProperties>';
  455. end;
  456. end;
  457. end;
  458.  
  459. if Append then
  460. Final[#Final + 1] = Append;
  461. end;
  462. end
  463.  
  464. Final[#Final + 1] = '</Properties>';
  465.  
  466. for _, Obj in next, Obj:GetChildren() do
  467. SaveInstance(Obj);
  468. end;
  469.  
  470. Final[#Final + 1] = '</Item>';
  471. end;
  472. end;
  473.  
  474. do
  475. local Other = Instance.new'Folder';
  476.  
  477. local Real = Players.LocalPlayer;
  478. local Play = Instance.new'Folder';
  479.  
  480. Other.Name = 'Other';
  481. Other.RobloxLocked = true;
  482. Other.Parent = game;
  483.  
  484. Play.Parent = Other;
  485. Play.Name = 'LocalPlayer';
  486.  
  487. for _, Des in next, Real:GetChildren() do
  488. pcall(SetParent, Des, Play);
  489. end;
  490.  
  491. if InNil then
  492. local Extr = Instance.new'Folder';
  493.  
  494. Extr.Parent = Other;
  495. Extr.Name = 'Nil_Instances';
  496.  
  497. for _, Nil in next, InNil() do
  498. pcall(SetParent, Nil, Extr);
  499. end;
  500. end;
  501.  
  502. SaveList[#SaveList + 1] = Other;
  503. end;
  504.  
  505. for _, Child in next, SaveList do
  506. SaveInstance(Child);
  507. end;
  508.  
  509. Final[#Final + 1] = '</roblox>';
  510.  
  511. local Place = game:GetService('MarketplaceService'):GetProductInfo(game.PlaceId);
  512.  
  513. if Place.Name then
  514. Place = string.gsub(Place.Name, '%W', '-'):gsub('%-+', '-');
  515. else
  516. Place = 'Unknown';
  517. end;
  518.  
  519. Final = Concat(Final);
  520.  
  521. Print(string.format('Done serializing, saving (%d bytes)', #Final));
  522.  
  523. WritesFl(Place .. '.rbxl', Final);
  524.  
  525. Print(string.format('Saving took %d second(s), please check your workspace folder', tick() - Timer));
  526. end;
  527.  
  528. SavePlaceAsync();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement