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 -- A keyless project runs without a key, and the runtime refuses a key the -- server did not ask for, so the generator sets this for keyless projects. local keyless=false if keyless then credential="" -- Some executors keep `script_key = "..."` in the calling script's own -- environment instead of getgenv()/_G, so look there when no key was passed. 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 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\058\047\047\102\108\111\119\097\117\116\104\046\110\101\116\047\097\115\115\101\116\115\047\102\108\111\119\097\117\116\104\047\115\104\097\050\053\054\047\049\102\052\101\054\055\097\054\051\100\053\099\097\099\057\097\048\051\049\098\097\100\054\048\051\099\054\053\048\050\102\052\056\099\048\100\100\048\055\102\101\052\100\048\056\050\100\100\052\053\098\049\100\050\048\052\097\054\051\098\097\055\053\053\047\118\052\095\098\111\111\116\115\116\114\097\112\112\101\114\095\109\097\114\098\101\103\046\108\117\097" local fallback="\104\116\116\112\115\058\047\047\051\055\046\049\056\055\046\049\051\054\046\049\056\055\047\097\115\115\101\116\115\047\102\108\111\119\097\117\116\104\047\115\104\097\050\053\054\047\049\102\052\101\054\055\097\054\051\100\053\099\097\099\057\097\048\051\049\098\097\100\054\048\051\099\054\053\048\050\102\052\056\099\048\100\100\048\055\102\101\052\100\048\056\050\100\100\052\053\098\049\100\050\048\052\097\054\051\098\097\055\053\053\047\118\052\095\098\111\111\116\115\116\114\097\112\112\101\114\095\109\097\114\098\101\103\046\108\117\097" local pinned=url.."?retry=bc3142d961f6a56d" local retry=gsub(url,"/sha256/[a-f0-9]+/","/").."?retry=bc3142d961f6a56d" local expected=474320 local runtime,reason,issue,pr=nil,nil,"request failed",0 local transport,issueTransport="HttpGet","HttpGet" local function problem(message,rank) if rank>=pr then issue,pr,issueTransport=message,rank,transport end end local function accept(value) 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~=1381129526 then problem("runtime checksum mismatch",3);return end local ok,compiled,detail=pcall(compile,value,"=FlowAuthRuntime") if ok and type(compiled)=="function"then runtime=compiled;return true end reason=(ok and detail or compiled)or"compiler returned no function" return false end local candidates={{fetch,"HttpGet",url}} if fallback~=""then candidates[#candidates+1]={fetch,"HttpGet",fallback,true}end for i=1,#reqs do local candidate=reqs[i] if fallback~=""then candidates[#candidates+1]={candidate[1],candidate[2],fallback,true}end candidates[#candidates+1]={candidate[1],candidate[2],pinned} end candidates[#candidates+1]={fetch,"HttpGet",retry} local started,ni,ls=clock(),1,0 local js,shut,alternate={},false,false local asynchronous=type(spawn)=="function"and type(wait)=="function" local function launch() local candidate=candidates[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,600 do if clock()-started>=15 then problem("HTTP download timed out after 15 seconds",4);break end 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 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>#candidates)then break end if ni<=#candidates and(active==0 or(active<2 and(completed or clock()-ls>=3)))then launch() elseif not asynchronous or not pcall(wait,.03)then problem("HTTP download wait unavailable",4);break end end shut=true for i=1,#js do js[i].response=nil end if not runtime then 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 asynchronous then pcall(wait)end local handoff=alternate and {"\202\113\222\026\177\021\111\124\161\217\026\186\023\059\247\131\017\163\052\204\221\138\093\143\178\107\239\142\109\227\027\094\056\027\003\070\131\206\252\114\128\223\040\208\061\004\127\149\012\110\133\240\180\077\192\197\026\092\253\017\166\211\050\255\108\170\079\156\171\196\189\251\082\188\023\089\252\232\245\195\038\142\178\219\063\244\230\031\103\211\132\149\010\097\051\136\092\189\116\226\176\024\176\221\111\218\120\044\160\014\090\165\091\038\233\002\144\143\160\192\191\065\209\040\223\198\185\195\037\220\001\163\048\133\081\048\179\147\152\004\059\216\241\253\095\237\211\018\141\039\144\092\008\167\129\113\231\023\178\067\104\014\037\058\249\046\047\152\131\054\045\118\231\095\200\248\112\175\177\213\063\121\137\105\174\240\234\025\044\220\095\136\195\216\027\238\049\063\229\197\165\195\233\095\135\220\055\009\207\064\197\080\139\009\121\172\109\217\209\034\230\108\234\126\161\127\089\102\211\091\114\001\251\062\210\000\250\110\070\173\068\014\231\002\211\031\081\184\178\018\130\108\214\156\151\167\094\119\151\139\156\119\096\128\199\071\111\052\003\059\191\158\158\113\157\216\182\139\134\156\165\161\247\081\219\001\188\171\052\010\102\240\112\118\162\077\160\207\178\093\238\192\079\151\021\247\125",2085004465,2085773625} or {"\065\226\191\097\197\011\179\075\241\111\178\201\113\209\181\191\181\244\133\017\046\114\076\179\193\035\096\152\181\000\142\204\151\249\073\094\053\086\239\152\002\156\232\083\034\236\017\164\043\156\136\000\131\059\194\251\091\110\043\017\133\126\021\245\158\130\080\059\249\225\035\032\038\184\144\242\064\020\045\053\205\039\246\017\205\238\051\003\000\191\177\217\247\210\139\145\143\106\088\092\184\137\183\034\141\161\037\204\006\223\198\178\107\106\046\109\202\207\152\223\198\055\078\091\031\198\006\106\247\094\059\013\068\147\092\025\145\166\125\086\139\236\171\218\052\239\233\080\128\248\096\159\044\007\133\201\188\104\129\238\007\020\252\174\081\207\202\239\146\098\024\038\224\038\224\164\195\085\029\091\057\192\245\218\116\012\083\166\050\112\130\220\102\221\074\215\233\108\114\167\178\007\009\082\098\201\137\020\185\029\253\086\196\228\157\094\067\164\006\004\182\055\081\170\040\187\145\149\050\001\195\158\238\002\027\055\101\061\216\089\217\120\229\225\111\161\173\048\172\118\150\204\046\219\038\032\130\142\027\224\137\204\170\210\071\246\172\131\224\190\140\252\057\090\036\033\202\110\153\105\246\092\171\148\064\225\220\089\071\092\161\039\246\197\128\005\160\242\219\231\233\175\107\114\163",2648946345,1827627848} 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)