Advertisement
XZTablets

Kronos

May 3rd, 2020
322
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 15.11 KB | None | 0 0
  1. local _DATA = ':--::DATA::--:'
  2. local Settings = plugin:GetSetting(_DATA)
  3. if not Settings then
  4.     Settings = {
  5.         ['pluginIcon'] = 'rbxassetid://2260584969';
  6.         ['Version'] = 'Version 2.1b';
  7.         ['isScanning'] = false;
  8.         ['isCooldown'] = tick();
  9.         ['totalObjs'] = 0;
  10.     };
  11.     plugin:SetSetting(_DATA, Settings)
  12. end
  13.  
  14. local Util = {
  15.     MaliciousStrings = {
  16.         ['tonumber']=true;
  17.         ['unpack']=true;
  18.         ['char']=true;
  19.         ['require']=true;
  20.     };
  21.     MaliciousServices = {
  22.         'JointsService';
  23.         'InsertService';
  24.     };
  25.     Backdoors = {
  26.         ['loadstring'] = {
  27.             'lua';
  28.             'lbi';
  29.         };
  30.         ['modulescript'] = {
  31.             {'luax','luay','luaz'};
  32.             {'lbi'};
  33.         };
  34.     };
  35.     Obfuscated_Code = {
  36.         ['if not market:PlayerOwnsAsset%(player,wat%) then'] = '';
  37.         ['market:PromptPurchase%(player,wat%)'] = '';
  38.         ['if not market:PlayerOwnsAsset%(v,wat%) then'] = true;
  39.         ['market:PromptPurchase%(v,wat%)'] = true;
  40.         ['wat%='] = true;
  41.     };
  42.     Service = setmetatable({}, {
  43.         __index = function(_,i)
  44.             return game:GetService(i) or nil
  45.         end;
  46.     });
  47.     Setup = function(self)
  48.         for i, v in next, self.MaliciousServices do
  49.             self.MaliciousServices[v] = true
  50.         end
  51.     end
  52. }
  53.        
  54. Util:Setup()
  55.  
  56. local toolBar = plugin:CreateToolbar('-:Backdoor:-:Scanner:-')
  57. local pluginButton = toolBar:CreateButton(':Kronos:',"::Scans your game for backdoors or viruses::", Settings.pluginIcon)
  58.  
  59. local function DebugInfo(t)
  60.     local Object, FullName = rawget(t,1), rawget(t,5) and rawget(t,5):GetFullName() or 'NIL'
  61.     warn(('%s %s: %s%s --> (%s %s)'):format((rawget(t,6) and '[' .. rawget(t,6) .. '] ' or '') .. '[' .. rawget(t,2):upper() .. ']', Object.Name or tostring(Object) or 'NIL', rawget(t,4) and '(' .. FullName .. '): ' or '', Object.Parent ~= nil and Object:GetFullName() or 'NIL', rawget(t,3) or '', rawget(t,4) and 'ID: ' .. rawget(t,4) or ''))
  62. end
  63.  
  64. local function LoadModel(ID)
  65.     local Result, Return = pcall(function()
  66.         return game:GetObjects(('rbxassetid://%d'):format(tonumber(ID)))
  67.     end)
  68.     if Result and Return then
  69.         return rawget(Return, 1)
  70.     end
  71. end
  72.  
  73. local function GetClass(Object) -- Used to work ...
  74.     local a, b = pcall(function()
  75.        return Object.ClassName or tostring(Object)
  76.     end)
  77.     if not a then
  78.         local m = getmetatable(Object)
  79.         if m and not m.__tostring then
  80.             m = {
  81.                 __tostring = function(self)
  82.                     local _, n = pcall(function()
  83.                         return self[1]
  84.                     end)
  85.                     return n:gsub('%d+ is not a valid member of ','')
  86.                 end;
  87.             }
  88.             a = m.__tostring(Object)
  89.         end
  90.         return a
  91.     end
  92.     return b or type(Object)
  93. end
  94.  
  95. local function loadSafe(Func,...)
  96.     _a = {...}
  97.     table.foreach(_a, function(_,...)
  98.         _a[_]=type(...)~='number'and(...):lower()or...
  99.     end)
  100.     local _s, _r = xpcall(function()
  101.         return Func(unpack(_a))
  102.     end, function(_e)
  103.         -- warn(('Failed to load function (%s)'):format(tostring(Func))) --> debug disabled k?
  104.     end)
  105.     return _s and _r
  106. end
  107.  
  108. local function rM(s)
  109.     local s,f,_s = s:sub(-s:len()+1),{},'';s=s:sub(1,s:len()-1)
  110.     for a in s:gmatch('%b()') do
  111.         local n = a:match('%d')
  112.         if not n then
  113.             if s:match('require%('..a) then
  114.                 table.insert(f,a)
  115.             else
  116.                 local _n = a:gsub('%(',''):gsub('%)','')
  117.                 if s:match('%)%('.._n) then
  118.                     table.insert(f,a)
  119.                 end
  120.             end
  121.         end
  122.     end
  123.     for _, _f in next, f do
  124.         _s=_s.._f
  125.     end
  126.     _s=_s:gsub('%(','%%('):gsub('%)','%%)')
  127.     return s:match('require'.._s)
  128. end
  129.    
  130. local function getString(s)
  131.     local t,mt = '',{}
  132.     if type(s) ~= 'string' then
  133.         return
  134.     end
  135.     s = s:gsub('%\\',' ')
  136.     for a in s:gmatch('%d+') do
  137.         table.insert(mt,tonumber(a))
  138.     end
  139.     for i=1,#mt do
  140.         local n = mt[i]
  141.         if n >= 0 and n <= 31 then
  142.             if n == 12 then
  143.                 t = t .. string.char(12)
  144.             end
  145.         elseif n >= 32 then
  146.             pcall(function()
  147.                 t = t .. string.char(n)
  148.             end)
  149.         end
  150.     end
  151.     return t == '' and nil or t
  152. end
  153.  
  154. local function fS(a)
  155.     for b in a:gmatch('%b()') do
  156.         local c = b:sub(1,-2):sub(2,b:len())
  157.         for d in c:gmatch('%b()') do
  158.             local e = d:sub(1,-2):sub(2,d:len())
  159.             if e:len()>8 then
  160.                 return c:match('require') and loadSafe(math.sqrt, e)
  161.             end
  162.         end
  163.     end
  164. end
  165.  
  166. function findChild(...)
  167.     local a, c, r, _r = {...}, {}, 0, 0
  168.     local tn = {}
  169.     if rawequal(type(a[1]), 'userdata') and rawequal(type(a[2]), 'table') then
  170.         if rawequal(type(a[2][1]), 'table') then
  171.             local t = a[2]
  172.             for n, _b in next, t do
  173.                 tn[n]={r1=0;r=0;tb={}}
  174.                 local curr = tn[n]
  175.                 for _, _n in next, _b do
  176.                     curr.tb[_n:lower()]=true;curr.r=curr.r+1
  177.                 end
  178.                 for _, b in next, a[1]:GetChildren() do
  179.                     if curr.tb[b.Name:lower()] then
  180.                         curr.r1=curr.r1+1
  181.                     end
  182.                 end
  183.                 r, _r = curr.r1, curr.r
  184.                 if r ~= 0 and r == _r then
  185.                     break
  186.                 end
  187.             end
  188.         else
  189.             for _, _n in next, a[2] do
  190.                 c[_n:lower()]=true;_r=_r+1
  191.             end
  192.             for _, b in next, a[1]:GetChildren() do
  193.                 if c[b.Name:lower()] then
  194.                     r=r+1
  195.                 end
  196.             end
  197.         end
  198.     end
  199.     return r ~= 0 and r == _r
  200. end
  201.  
  202. local Num = 0 repeat wait(1) Num = Num + 1 warn(('KRONOS: Loading %s'):format((Num<=1 and '.') or (Num<=2 and '..')or (Num<=3 and '...'))) if Num >= 3 then warn("KRONOS: Couldn't detect place owner.") break end until game.PlaceId ~= 0 warn'\n'
  203. local PlaceInfo = loadSafe(Util.Service.MarketplaceService.GetProductInfo, game.PlaceId)
  204. local OwnerId, groupOwnerId, ownType
  205. if type(PlaceInfo) == 'table' then
  206.     if PlaceInfo.Creator.CreatorType == 'User' then
  207.         OwnerId = PlaceInfo.Creator.CreatorTargetId
  208.     elseif PlaceInfo.Creator.CreatorType == 'Group' then
  209.         OwnerId = Util.Service.GroupService:GetGroupInfoAsync(PlaceInfo.Creator.CreatorTargetId).Owner.Id
  210.         groupOwnerId = PlaceInfo.Creator.CreatorTargetId
  211.         ownType = true
  212.     end
  213. end
  214. OwnerId = type(OwnerId) ~= 'number' and game.CreatorId or OwnerId
  215. local function idScan(id)
  216.     if id and tonumber(id) then
  217.         local Result, Return = pcall(function()
  218.             return Util.Service.MarketplaceService:GetProductInfo(tonumber(id))
  219.         end)
  220.         local Product_Info = Result and Return or nil
  221.         if Product_Info then
  222.             local madeByGroup = Product_Info.CreatorType == 'Group'
  223.             if madeByGroup then
  224.                 if Product_Info.Creator.CreatorTargetId ~= groupOwnerId then
  225.                     return Product_Info
  226.                 end
  227.             elseif Product_Info.Creator.CreatorTargetId ~= OwnerId then
  228.                 return Product_Info
  229.             end
  230.         end
  231.     end
  232. end
  233.  
  234. local function scanScript(Script)
  235.     local Result, Source = pcall(function()
  236.         return Script.Source
  237.     end)
  238.     if not Result or not Source then
  239.         return
  240.     end
  241.     local StringSource = tostring(Source)
  242.     for Each in StringSource:gmatch('%b()') do
  243.         local NumbersFound = Each:match('%d+')
  244.         if NumbersFound and NumbersFound:len() >= 8 then
  245.             if StringSource:match('require%('..NumbersFound..'%)') then
  246.                 local GetModel = LoadModel(NumbersFound)
  247.                 if GetModel then
  248.                     local Scanned = ScanObject(GetModel,true,'MODEL',tostring(NumbersFound),Script)
  249.                     if Scanned then
  250.                         warn'debug-1'
  251.                         --DebugInfo(Scanned)
  252.                     else
  253.                         for _, Object in next, GetModel:GetDescendants() do
  254.                             local Scanned = ScanObject(Object,true,'MODEL',tostring(NumbersFound),Script)
  255.                             if Scanned then
  256.                                 --DebugInfo(Scanned)
  257.                             end
  258.                         end
  259.                     end
  260.                 end
  261.             end
  262.         end
  263.     end
  264. end
  265.  
  266. local function ObjectScan(Object, ...)
  267.     local Result, ObjectName = pcall(function()
  268.         return Object.Name or tostring(Object)
  269.     end)
  270.     if Result then
  271.         local Class, Args = GetClass(Object), {...}
  272.         local BT1, BT2, String = Util.Backdoors[ObjectName:lower()], Util.Backdoors[Class:lower()], rawget(Args,1)
  273.         if BT1 and rawequal(type(BT1), 'table') then
  274.             if findChild(Object, BT1) then
  275.                 return {Object, 'BACKDOOR-EXECUTOR', ...}
  276.             end
  277.         end
  278.         if BT2 and rawequal(type(BT2), 'table') then
  279.             if findChild(Object, BT2) then
  280.                 return {Object, 'BACKDOOR-EXECUTOR', ...}
  281.             end
  282.         end
  283.         if Class ~= 'CoreScript' and (Class == 'ModuleScript' or Class == 'Script') then
  284.             local Result, Source = pcall(function()
  285.                 return Object.Source
  286.             end)
  287.             if not Result or not Source then
  288.                 return
  289.             end
  290.             local SubbedSource = tostring(Source):gsub('\n',''):gsub('  ','')
  291.             local Scanned, FoundStuff = not String and scanScript(Object), {ScannedEach={F1=0;F2=0};MaliciousStrings=0;OtherStuff={F1=0;F2=0}}
  292.             if Scanned then
  293.                 return Scanned
  294.             end
  295.             for each in Source:gmatch('%b()') do
  296.                 if each:match('math') and each:match('getfenv') then
  297.                     FoundStuff.Return={Object,"BACKDOOR-LOADER",...}
  298.                     break
  299.                 elseif each:match('loadstring%(') and each:match('%)%(%)') then
  300.                     FoundStuff.Return={Object,"BACKDOOR-LOADER",...}
  301.                     break
  302.                 end
  303.                 local _cE = rM(each)
  304.                 if _cE and _cE ~= 'require' and Source:match(_cE .. '%(') then
  305.                     FoundStuff.Return={Object,"BACKDOOR-LOADER",...}
  306.                     break
  307.                 end
  308.                 local _fS = fS(each)
  309.                 if _fS then
  310.                     FoundStuff.Return={Object,'BACKDOOR-LOADER',...}
  311.                     break
  312.                 end
  313.             end
  314.             if FoundStuff.Return then
  315.                 return FoundStuff.Return
  316.             end
  317.             for each in Source:gmatch('%b[]') do
  318.                 if each:match('"') or each:match("'") then
  319.                     local Number = each:gsub('"',''):gsub('"',''):gsub(' ',''):gsub('   ',''):gsub('%[',''):gsub('%]','')
  320.                     if Number:match('%\\') then
  321.                         local LookForString = getString(Number)
  322.                         if LookForString then
  323.                             local MaliciousString = LookForString:reverse()
  324.                             if Util.MaliciousStrings[LookForString] or Util.MaliciousStrings[MaliciousString] then
  325.                                 FoundStuff.MaliciousStrings = FoundStuff.MaliciousStrings + 1
  326.                             end
  327.                         end
  328.                     end
  329.                 end
  330.             end
  331.             if Source:match('PlayerOwnsAsset') and (Source:match('PromptProductPurchase') or Source:match('PromptPurchase')) and Source:match('while') and Source:match('do') then
  332.                 local _f; for Stuff in Source:gmatch('PlayerOwnsAsset%b()') do
  333.                     local Scanned = idScan(Stuff:match('%d+'))
  334.                     if Scanned then
  335.                         _f = {Object, 'PRODUCT-SPAMMER',...}
  336.                         break
  337.                     end
  338.                 end
  339.                 return _f
  340.             end
  341.             local function scanEach(Each,Num)
  342.                 if Each:lower():match('isstudio') or Each:lower():match('placeid') or Each:lower():match('load') then
  343.                     pcall(function()
  344.                         if Source:match(('= %s'):format(Each)) or Source:match(('=%s'):format(Each)) then
  345.                             FoundStuff.ScannedEach.F1 = Num == 1 and FoundStuff.ScannedEach.F1 + 1 or FoundStuff.ScannedEach.F1
  346.                             FoundStuff.ScannedEach.F2 = Num == 2 and FoundStuff.ScannedEach.F2 + 1 or FoundStuff.ScannedEach.F2
  347.                         end
  348.                     end)
  349.                 end
  350.             end
  351.             for Each in Source:gmatch('%b""') do
  352.                 scanEach(tostring(Each),1)
  353.             end
  354.             for Each in Source:gmatch("%b''") do
  355.                 scanEach(tostring(Each),2)
  356.             end
  357.             if FoundStuff.ScannedEach.F1 == 3 or FoundStuff.ScannedEach.F2 == 3 or FoundStuff.MaliciousStrings > 1 then
  358.                 return {Object, "BACKDOOR-LOADER",...}
  359.             end
  360.             local SecretSource = Source:gsub('  ','')
  361.             if Source:match('SynapseXen%_') or Source:match('=getfenv or function%(%)return _ENV end;') or Source:match(',getfenv%(%)%)%(%)') then
  362.                 return {Object, "OBFUSCATED-LOADER",...}
  363.             elseif Source:match("require%(math%.") or Source:match("require%(table%.") or Source:match("require%(tonumber%(")  then
  364.                 return {Object, "BACKDOOR-LOADER",...}
  365.             elseif (SecretSource:match("getfenv%(%)%[%'") or SecretSource:match('getfenv%(%)%[%"') or Source:match("getfenv%(%)%[%'") or Source:match('getfenv%(%)%[%"')) and not Source:match("getfenv%(%)%[%'script'%]") then
  366.                 return {Object, "BACKDOOR-LOADER",...}
  367.             elseif ((Source:match('load%(game') and Source:match('PlaceId')) and (Source:match('OnServerEvent') or Source:match('OnInvokeServer') or Source:match('HttpService'))) and not Source:match("'PlaceId'") then
  368.                 return {Object, "BACKDOOR-LOADER",...}
  369.             --elseif Source:match('getfenv%[') then
  370.                 --return {Object, "BACKDOOR-LOADER"}
  371.             end
  372.             if Source:match("while true do") or (Source:match("while wait") and Source:match('do')) then
  373.                 if Source:match('Instance%.+new%(%"+Fire') or Source:match("Instance%.+new%(%'+Fire") or Source:match('Instance%.+new%(%[+Fire') then
  374.                     return {Object, "FIRE/INSTANCE-VIRUS",...}
  375.                 end
  376.             end
  377.             for ObfCode, Val in next, Util.Obfuscated_Code do
  378.                 if type(Val) == 'string' then
  379.                     if Source:match(ObfCode) or SubbedSource:match(ObfCode) then
  380.                         FoundStuff.OtherStuff.F1 = FoundStuff.OtherStuff.F1 + 1
  381.                     end
  382.                 elseif type(Val) == 'boolean' then
  383.                     if Source:match(ObfCode) or SubbedSource:match(ObfCode) then
  384.                         FoundStuff.OtherStuff.F2 = FoundStuff.OtherStuff.F2 + 1
  385.                     end
  386.                 end
  387.             end
  388.             if FoundStuff.OtherStuff.F1 == 2 or FoundStuff.OtherStuff.F2 == 2 then
  389.                 return {Object, "PRODUCT-SPAMMER",...}
  390.             end
  391.             if Source:len() > 1000000 then
  392.                 return {Object, "CRASHING-HUGE-SCRIPT",...}
  393.             end
  394.         end
  395.     end
  396. end
  397.  
  398. local HttpService = Util.Service.HttpService
  399. function HttpEnabled()
  400.     return pcall(function()
  401.         HttpService:GetAsync('http://www.google.com/')
  402.     end)
  403. end
  404. function scanPluginsModels()
  405.     local Genres = {'Plugin','Model'}
  406.     local ID = (OwnerId~=0 and OwnerId) or loadSafe(Util.Service.GroupService.GetGroupInfoAsync, game.CreatorId) or game.CreatorId
  407.     if type(ID) == 'table' then
  408.         ID = ID.Owner.Id
  409.     end
  410.     if rawequal(ID, 0) then
  411.         return
  412.     elseif not HttpEnabled() then
  413.         return warn'For Plugin-Model scans, please enable Http Requests.'
  414.     end
  415.     for _, Genre in next, Genres do
  416.         local link = 'https://inventory.rprxy.xyz/v1/users/%s/inventory/%s'
  417.         local Result, Return = pcall(HttpService.GetAsync, HttpService, link:format(ID,Genre))
  418.         if Result then
  419.             Return = HttpService:JSONDecode(Return)
  420.             local plugins = Return.data
  421.             for _, id in next, plugins do
  422.                 local GetModel = LoadModel(id)
  423.                 if GetModel then
  424.                     local Scanned = ScanObject(GetModel,true,Genre:upper(),tostring(id),nil,Genre:upper())
  425.                     if Scanned then
  426.                         warn'stuff'
  427.                     else
  428.                         for _, Object in next, GetModel:GetDescendants() do
  429.                             ScanObject(Object,true,Genre:upper(),tostring(id),nil,Genre:upper())
  430.                         end
  431.                     end
  432.                 end
  433.             end
  434.         elseif not ownType then
  435.             warn(("Failed to load User (%s)'s inventory. Make sure it is enabled! -> Plugin/Model checks have been disabled."):format(ID,Genre:upper()))
  436.             break
  437.         end
  438.     end
  439. end
  440.  
  441. function ScanObject(Parent,Single,String,ID,Orig,PM)
  442.     local ToScan = Single and {Parent} or Parent:GetDescendants()
  443.     for _, Object in next, ToScan do
  444.         local Info = ObjectScan(Object,String,ID,Orig,PM)
  445.         if Info then
  446.             local removeObject, secretFolder = rawget(Info, 5) or rawget(Info, 1) or Object, Util.Service.ServerStorage:FindFirstChild'Backdoors'
  447.             if (secretFolder and removeObject.Parent ~= secretFolder) or not secretFolder then
  448.                 DebugInfo(Info)
  449.                 if secretFolder then
  450.                     removeObject.Parent = secretFolder
  451.                 end
  452.             end
  453.         end
  454.     end
  455. end
  456.  
  457. local function StartScanning()
  458.     if Settings.isScanning then
  459.         return print('KRONOS: Already Scanning!')
  460.     end
  461.     Settings.isScanning = true
  462.     Settings.isCooldown = tick()
  463.     print('KRONOS: Started scanning ...')
  464.     Settings.totalObjs = #game:GetDescendants()
  465.     ScanObject(game)
  466.     warn('\n')
  467.     scanPluginsModels()
  468.     print(("KRONOS: Took %s seconds to scan %s objects."):format((tostring(tick()-Settings.isCooldown)):sub(1,4), Settings.totalObjs))
  469.     Settings.isScanning = false
  470. end
  471.  
  472. pluginButton.Click:Connect(StartScanning)
  473. warn('KRONOS: Loaded!')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement