-- FlowAuth isolated console return (function(...) local kind,protect,raise=type,pcall,error local getEnvironment,setEnvironment,compile=getfenv,setfenv,loadstring if kind(getEnvironment)~="function" or kind(setEnvironment)~="function" then return nil,"Silent execution is unavailable in this executor" end local base=getEnvironment() local inherited=rawget(base,"__flowauth_console_scope") local shared=base if kind(getgenv)=="function" then local ok,value=protect(getgenv);if ok and kind(value)=="table" then shared=value end end if kind(inherited)=="table" and kind(inherited.base)=="table" and kind(inherited.compile)=="function" then base,shared,compile=inherited.base,inherited.shared,inherited.compile end local unpackValues=table.unpack or unpack local function pack(...)return {n=select("#",...),...}end local quiet=nil local pending={} local authoredError local nativeProtectedRuntime=false local nativePrint,nativeWarn=base.print,base.warn local nativeRawGet,nativeRawSet=rawget,rawset local function output(fn,...) if quiet==nil then if #pending<32 then pending[#pending+1]={fn,pack(...)}end elseif not quiet and kind(fn)=="function" then fn(...)end end local function decide(value) if quiet~=nil then return end quiet=value if not quiet then for _,entry in ipairs(pending)do if kind(entry[1])=="function" then entry[1](unpackValues(entry[2],1,entry[2].n))end end end pending={} end local scope,sharedScope={},{} setmetatable(scope,{__index=base,__newindex=base}) setmetatable(sharedScope,{__index=shared,__newindex=shared}) local function mutedPrint(...)output(nativePrint,...)end local function mutedWarn(...)output(nativeWarn,...)end local function scopedCompile(text,name) -- Luraph STATIC_ENVIRONMENT forbids changing the compiled function's -- environment. Keep its native globals and compiler, including the -- customer chunks it compiles. Output isolation applies only to the -- plaintext launcher/init/UI paths that support environment rebinding. if name=="=FlowAuthRuntime" then nativeProtectedRuntime=true return compile(text,name) end if kind(text)=="string" then local prefix=string.sub(text,1,256) if string.find(prefix,"-- FlowAuth console: silent",1,true)then decide(true) elseif string.find(prefix,"-- FlowAuth console: normal",1,true)then decide(false)end end local chunk,reason=compile(text,name) if kind(chunk)=="function" then if name=="=FlowAuth" or name=="=FlowAuthInit" or name=="=FlowAuthUI" then setEnvironment(chunk,base) local function authored(fn) return function(...) local values=pack(protect(fn,...)) if not values[1] then authoredError=values[2];raise(values[2],0)end if name=="=FlowAuthInit" and kind(values[2])=="function" then values[2]=authored(values[2])end return unpackValues(values,2,values.n) end end return authored(chunk) end setEnvironment(chunk,scope) end return chunk,reason end local function scopedRawGet(environment,key) if environment==scope or environment==sharedScope then local own=nativeRawGet(environment,key) if own~=nil then return own end return nativeRawGet(environment==scope and base or shared,key) end return nativeRawGet(environment,key) end local function scopedRawSet(environment,key,value) if environment==scope then nativeRawSet(base,key,value);return environment end if environment==sharedScope then nativeRawSet(shared,key,value);return environment end return nativeRawSet(environment,key,value) end for _,environment in ipairs({scope,sharedScope})do rawset(environment,"__flowauth_console_scope",{base=base,shared=shared,compile=compile}) rawset(environment,"rawget",scopedRawGet);rawset(environment,"rawset",scopedRawSet) rawset(environment,"print",mutedPrint);rawset(environment,"warn",mutedWarn) rawset(environment,"loadstring",scopedCompile) rawset(environment,"getgenv",function()return sharedScope end) rawset(environment,"_G",sharedScope) end local function run(...) local credential=... local type,pcall,error,tostring,tonumber=type,pcall,error,tostring,tonumber local rawset,getfenv=rawset,getfenv local globals,host=_G,game local byte,gsub,find=string.byte,string.gsub,string.find local wait=type(task)=="table"and task.wait local clock=os.clock local compile=loadstring local function member(value,key) local ok,result=pcall(function()return value[key]end) if ok then return result end end local keyless=false if keyless then credential="" elseif type(credential)~="string"then for lv=2,4 do local f,sc=pcall(getfenv,lv) local v=f and type(sc)=="table"and member(sc,"script_key") if type(v)=="string"then credential=v;pcall(rawset,sc,"script_key",nil);break end end end local spawn=member(task,"spawn") local fetch=member(host,"HttpGet") local ok,senv=pcall(function()return getfenv()end) if not ok or type(senv)~="table"then senv=globals end local ok,environment=pcall(function()return getgenv()end) if not ok or type(environment)~="table"then environment=senv end local function global(key)return member(environment,key)or member(senv,key)or member(globals,key)end local sample=20 local platform="?" pcall(function() local input=host:GetService("UserInputService") platform=input.TouchEnabled and not input.KeyboardEnabled and"m"or"d" end) local function ms(x)return math.floor(x*1000+.5)end local reqs,seen={},{} local function add(fn,name) if type(fn)=="function"and not seen[fn]then seen[fn]=true;reqs[#reqs+1]={fn,name}end end add(global("request"),"request") add(global("http_request"),"http_request") add(global("httpRequest"),"httpRequest") add(global("httprequest"),"httprequest") add(member(global("http"),"request"),"http.request") add(member(global("syn"),"request"),"syn.request") local bt=member(global("buffer"),"tostring") local url="\104\116\116\112\115\58\47\47\102\108\111\119\97\117\116\104\46\110\101\116\47\97\115\115\101\116\115\47\102\108\111\119\97\117\116\104\47\115\104\97\50\53\54\47\55\52\97\56\55\54\52\54\98\48\56\51\50\99\102\54\52\101\99\100\49\99\99\57\52\101\99\101\57\52\57\57\98\102\55\51\55\56\51\101\98\49\51\102\57\56\48\50\51\49\54\49\56\49\54\53\101\48\54\100\53\102\97\53\47\118\52\95\98\111\111\116\115\116\114\97\112\112\101\114\95\109\97\114\98\101\103\46\108\117\97" local fallback="" local fresh=url.."?retry=0de595c622fa90f5" local retry=gsub(url,"/sha256/[a-f0-9]+/","/").."?retry=0de595c622fa90f5" local expected=854116 local runtime,reason,issue,pr=nil,nil,"timed out",0 local transport,issueTransport="HttpGet","HttpGet" local function problem(message,rank) if rank>=pr then issue,pr,issueTransport=message,rank,transport end end local arrived,ck,cm=0,0,0 local function accept(value) local began=clock() if type(value)=="buffer"then local ok,text=pcall(bt,value);value=ok and text or nil end if type(value)~="string"then problem("unsupported response body",1);return end if #value~=expected then if #value<1024 and find(value,"Failed to send HTTP request.",1,true)then problem(find(value,"timed out",1,true)and"HTTP request timed out"or"HTTP request failed",2) else problem("received "..#value.." bytes; expected "..expected,2)end return end local s1,s2,i=1.0,0.0,1 while i+7<=#value do local a,b,c,d,e,f,g,h=byte(value,i,i+7) s2=(s2+8*s1+8*a+7*b+6*c+5*d+4*e+3*f+2*g+h)%65521 s1=(s1+a+b+c+d+e+f+g+h)%65521;i=i+8 end while i<=#value do s1=(s1+byte(value,i))%65521;s2=(s2+s1)%65521;i=i+1 end if s2*65536.0+s1~=2093046188 then problem("runtime checksum mismatch",3);return end local t=clock();ck=t-began local ok,compiled,detail=pcall(compile,value,"=FlowAuthRuntime") local text=not(ok and type(compiled)=="function")and tostring(ok and detail or compiled) if text and not(find(text,"FlowAuthRuntime:")or find(text,"xpected")or find(text,"syntax"))then if wait then pcall(wait,1.5)end ok,compiled,detail=pcall(compile,value,"=FlowAuthRuntime") end cm=clock()-t if ok and type(compiled)=="function"then runtime=compiled;return true end reason=(ok and detail or compiled)or"compiler returned no function";issueTransport=transport return false end local cs={{fetch,"HttpGet",url}} if fallback~=""then cs[#cs+1]={fetch,"HttpGet",fallback,true}end for i=1,#reqs do local candidate=reqs[i] if fallback~=""then cs[#cs+1]={candidate[1],candidate[2],fallback,true}end cs[#cs+1]={candidate[1],candidate[2],fresh} end cs[#cs+1]={fetch,"HttpGet",retry} local started,ni,ls,idle=clock(),1,0,0 local js,shut,alternate={},false,false local asynchronous=type(spawn)=="function"and type(wait)=="function" local function launch() local candidate=cs[ni];ni=ni+1;ls=clock() local job={name=candidate[2],alternate=candidate[4]};js[#js+1]=job local function run() if shut or job.started then return end job.started=true local ok,response if job.name=="HttpGet"then ok,response=pcall(candidate[1],host,candidate[3]) else ok,response=pcall(candidate[1],{Url=candidate[3],Method="GET"})end if not shut then job.ok,job.response,job.done=ok,response,true end end if asynchronous then local ok,thread=pcall(spawn,run);job.thread=ok and thread or nil if not job.started and type(job.thread)~="thread"then asynchronous=false;run()end else run()end end launch() for poll=1,4000 do local active,completed=0,false for i=1,#js do local job=js[i] if not job.done then active=active+1 elseif not job.read then job.read=true;completed=true;transport=job.name;arrived=clock()-started local response=job.response;job.response=nil if not job.ok then problem("request failed",1) elseif type(response)=="table"then local status=tonumber(member(response,"StatusCode")or member(response,"status_code")or member(response,"Status")or member(response,"status"))or 0 local success=member(response,"Success");if success==nil then success=member(response,"success")end if status==0 and success==true then status=200 end if success==false and status<400 then status=500 end if status>=200 and status<300 then accept(member(response,"Body")or member(response,"body")or member(response,"ResponseBody")or member(response,"response_body")) else problem("HTTP "..status,2)end else accept(response)end if runtime or reason then alternate=job.alternate;break end end end if runtime or reason or(active==0 and ni>#cs)then break end local t=clock() if t-started-idle>=40 then problem("HTTP download timed out after 40 seconds",4);break end if ni<=#cs and(active==0 or(active<2 and(completed or t-ls>=8)))then launch() elseif not pcall(wait,.03)then problem("HTTP download wait unavailable",4);break else idle=idle+math.max(clock()-t-1,0)end end shut=true for i=1,#js do js[i].response=nil end local function send(base,path,body,delay) local query="?p="..gsub('{"protocol":3,"loader_hash":"\54\52\55\48\51\53\57\51\49\98\55\57\51\55\100\51\49\100\50\99\56\52\49\99\50\57\98\52\56\56\57\52","\108\97\117\110\99\104\95\116\105\99\107\101\116":"\118\50\58\49\85\107\119\74\53\76\65\90\111\109\101\105\90\101\71\58\71\103\120\85\56\114\65\105\69\76\103\99\71\120\80\99\66\77\54\57\83\65\58\68\54\73\115\66\97\48\119\119\75\69\66\103\111\114\89\118\102\119\117\86\111\111\116\111\67\122\75\113\89\111\78\82\85\77\78\76\110\66\106\113\76\65\53\105\116\112\69\67\53\85\69\81\87\97\107\97\51\115\77\111\119\66\78\83\99\76\51\84\65\106\52\115\118\100\116\54\49\98\52\77\117\105\75\52\75\118\57\78\45\55\87\106\114\99\67\112\98\118\102\120\85\89\116\53\122\57\49\112\110\102\74\48\112\119\112\116\75\97\57\57\112\68\73\65\115\50\80\89\120\101\117\54\99\109\117\86\70\87\86\82\101\81\120\108\121\108\84\45\120\112\116\86\119\103\98\56\56\118\120\112\51\105\101\48\101\75\115\102\73\84\120\115\82\117\104\51\108\54\83\48\117\50\89\86\70\102\74\76\107\112\55\104\76\108\115\104\83\75\108","stage":"'..body,"[^%w]",function(c)return string.format("%%%02X",byte(c))end) pcall(spawn,function() if delay then pcall(wait,delay)end local target=gsub(base,"/assets/.*",path)..query if not pcall(fetch,host,target)and reqs[1]then pcall(reqs[1][1],{Url=target,Method="GET"})end end) end if not runtime then pcall(function() local text=gsub(issueTransport..": "..tostring(reason or issue),"[^%w .:;,()=/_-]","?") local body=(reason and"launcher_load"or"launcher_download")..'","executor":"launcher","diag":["pf='..platform..'"],"error":"'..string.sub(text,1,160)..'"}' for _,base in ipairs{url,fallback}do if base~=""then send(base,"/v1/telemetry/executor",body)end end end) if reason then error("FlowAuth runtime compilation failed: "..tostring(reason),0)end error("FlowAuth runtime download failed ("..issueTransport.."): "..tostring(issue)..". Please run the loader again.",0) end if sample>0 and spawn and math.random(sample)==1 then pcall(send,alternate and fallback or url,"/v1/telemetry/load",'load","pf":"'..platform..'","tp":"'..transport..'","fb":'..(alternate and 1 or 0)..',"tr":'..#js..',"dl":'..ms(arrived)..',"ck":'..ms(ck)..',"cm":'..ms(cm)..',"w":'..sample..'}',2) end if asynchronous then pcall(wait)end local handoff=alternate and nil or {"\255\102\125\201\152\76\133\154\136\43\175\13\110\204\80\206\12\251\32\11\139\248\189\113\36\173\18\193\201\54\58\190\84\76\222\253\3\171\78\247\18\253\189\219\189\72\183\30\108\155\64\221\68\35\99\254\252\106\188\151\188\153\41\163\64\199\217\73\117\167\178\136\216\211\204\88\81\9\180\25\110\229\94\17\117\50\198\227\121\27\112\222\27\25\111\135\108\92\231\41\218\100\138\196\46\136\195\4\48\53\40\111\74\102\114\94\24\67\70\2\106\10\188\16\4\156\75\179\6\55\175\173\53\165\96\46\33\153\237\220\181\33\123\139\51\204\14\94\76\195\150\35\6\139\53\116\112\101\170\190\4\60\184\74\43\99\86\224\208\222\20\157\37\75\32\101\224\212\180\39\23\248\68\228\118\35\134\58\93\0\134\212\31\68\135\236\201\218\237\43\4\187\176\149\171\253\12\224\129\163\167\28\15\236\116\173\170\121\185\244\75\116\58\77\103\165\75\65\156\225\18\84\49\221\54\150\44\144\36\240\89\154\77\180\221\64\35\4\180\48\216\101\213\210\208\255\168\100\87\62\38\102\105\119\11\133\114\165\187\82\154\140\51\63\122\65\92\74\10\217\170\124\134\57\98\199\220\22\123\192\60\85\75\131\250\107\122\141\145\17\140\58\59\213\167",191816880,435643786} local function publish(target) if type(target)=="table"then pcall(rawset,target,"_bsdata0",handoff)end end publish(environment) publish(globals) _bsdata0=handoff pcall(function()publish(getfenv(runtime))end) handoff=nil return runtime(credential) end setEnvironment(run,scope) local result=pack(protect(run,...)) if not result[1] then if nativeProtectedRuntime or quiet==false or (authoredError~=nil and authoredError==result[2]) then raise(result[2],0)end return nil,result[2] end return unpackValues(result,2,result.n) end)(...)