| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178 |
- /**
- * Sentinel Turnstile VM executor.
- * Usage: node solve_turnstile.js <sentinel_response_json> <requirements_token>
- * Output: the "t" value on stdout.
- */
- const sentinelData = JSON.parse(process.argv[2]);
- const reqToken = process.argv[3];
- const dx = sentinelData.turnstile?.dx;
- if (!dx) { process.stdout.write(''); process.exit(0); }
- /* ---- browser shims ---- */
- global.window = global; global.self = global; global.top = global; global.parent = global;
- global.document = {
- createElement:()=>({style:{},src:'',async:!1,defer:!1,onload:null,onerror:null,innerHTML:'',nonce:'',appendChild:()=>{},getElementsByTagName:()=>[{appendChild:()=>{}}],addEventListener:(e,c)=>{if(e==='load')setTimeout(c,1)},height:1,width:1,contentWindow:{document:{createElement:()=>({innerHTML:'',nonce:''}),getElementsByTagName:()=>[{appendChild:()=>{}}]},postMessage:()=>{}}}),
- getElementsByTagName:()=>[{appendChild:(el)=>{if(el.onload)setTimeout(el.onload,1)}}],
- body:{appendChild:()=>{}},head:{appendChild:()=>{}},readyState:'complete',documentElement:{style:{}},
- scripts:[],querySelectorAll:()=>[],cookie:''
- };
- global.navigator={userAgent:'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36',language:'en-US',languages:['en-US','en'],platform:'MacIntel',vendor:'Google Inc.',hardwareConcurrency:8,maxTouchPoints:0,cookieEnabled:true,doNotTrack:null,connection:{},plugins:{length:0},mimeTypes:{length:0},pdfViewerEnabled:true,webdriver:false,scheduling:{},userActivation:{},geolocation:{},credentials:{},mediaDevices:{},permissions:{},locks:{},ink:{},webkitTemporaryStorage:{},webkitPersistentStorage:{},productSub:'20030107',vendorSub:''};
- global.screen={width:1920,height:1080,colorDepth:24,pixelDepth:24,availWidth:1920,availHeight:1080};
- global.location={href:'https://auth.openai.com/create-account',origin:'https://auth.openai.com',pathname:'/create-account',search:'',hostname:'auth.openai.com',protocol:'https:'};
- global.history={length:2};
- global.localStorage={getItem:()=>null,setItem:()=>{},removeItem:()=>{},length:0};
- global.sessionStorage={getItem:()=>null,setItem:()=>{},removeItem:()=>{},length:0};
- const _ps=Date.now()-5000;
- global.performance={now:()=>Date.now()-_ps,timeOrigin:_ps};
- global.Reflect=Reflect;global.InstallTrigger=undefined;
- global.btoa=(s)=>Buffer.from(s,'binary').toString('base64');
- global.atob=(s)=>Buffer.from(s,'base64').toString('binary');
- global.fetch=async()=>({ok:true,json:async()=>({}),text:async()=>''});
- global.crypto={getRandomValues:(a)=>{for(let i=0;i<a.length;i++)a[i]=Math.floor(Math.random()*256);return a},subtle:{}};
- global.TextEncoder=TextEncoder;global.TextDecoder=TextDecoder;
- global.MutationObserver=class{observe(){}disconnect(){}};
- global.addEventListener=()=>{};global.removeEventListener=()=>{};global.postMessage=()=>{};
- global.requestAnimationFrame=(cb)=>setTimeout(cb,16);global.cancelAnimationFrame=clearTimeout;
- global.getComputedStyle=()=>new Proxy({},{get:()=>''});
- global.matchMedia=()=>({matches:false,addListener:()=>{},removeListener:()=>{}});
- global.Image=class{set src(v){}get src(){return''}};
- /* ---- helpers ---- */
- function Tn(a,b){let r='';for(let i=0;i<a.length;i++)r+=String.fromCharCode(a.charCodeAt(i)^b.charCodeAt(i%b.length));return r;}
- /* ---- decode instructions ---- */
- const instructions=JSON.parse(Tn(atob(dx),reqToken));
- /* ---- VM ---- */
- const bn=new Map();
- const Zt_key=9;
- let resolved=false, resolvedValue='', kn=0;
- // $t=0: initial empty value
- bn.set(0,'');
- // Ft=1: XOR
- bn.set(1,(n,e)=>bn.set(n,Tn(''+bn.get(n),''+bn.get(e))));
- // Lt=2: SET literal
- bn.set(2,(n,e)=>bn.set(n,e));
- // Jt=3: RESOLVE -> e(btoa(t))
- bn.set(3,(t)=>{if(!resolved){resolved=true;resolvedValue=btoa(''+t);}});
- // Gt=4: REJECT -> r(btoa(t))
- bn.set(4,(t)=>{if(!resolved){resolved=true;resolvedValue=btoa(''+t);}});
- // Wt=5: APPEND (array push or string concat)
- bn.set(5,(n,e)=>{const v=bn.get(n);if(Array.isArray(v))v.push(bn.get(e));else bn.set(n,v+bn.get(e));});
- // zt=6: INDEX -> bn.set(n, bn.get(e)[bn.get(r)])
- bn.set(6,(n,e,r)=>bn.set(n,bn.get(e)[bn.get(r)]));
- // Vt=7: CALL -> bn.get(n)(...args.map(x=>bn.get(x)))
- bn.set(7,(n,...e)=>bn.get(n)(...e.map(x=>bn.get(x))));
- // Bt=8: COPY
- bn.set(8,(n,e)=>bn.set(n,bn.get(e)));
- // Zt=9: instruction list
- bn.set(9,[]);
- // Kt=10: window
- bn.set(10,global.window);
- // Qt=11: find script by src
- bn.set(11,(n,e)=>{
- const p=bn.get(e);
- const s=Array.from(document.scripts||[]).filter(x=>x?.src?.search?.(p)>=0);
- bn.set(n,(s.map(x=>x?.nonce)?.[0]??[])?.[0]??null);
- });
- // Yt=12: get VM map
- bn.set(12,(n)=>bn.set(n,bn));
- // Xt=13: try-catch
- bn.set(13,(n,e,...r)=>{try{bn.get(e)(...r);}catch(err){bn.set(n,''+err);}});
- // tn=14: JSON.parse
- bn.set(14,(n,e)=>bn.set(n,JSON.parse(''+bn.get(e))));
- // nn=15: JSON.stringify
- bn.set(15,(n,e)=>bn.set(n,JSON.stringify(bn.get(e))));
- // en=16: XOR key (set to requirements token)
- bn.set(16,reqToken);
- // rn=17: async call with result
- bn.set(17,(n,e,...r)=>{
- try{
- const fn=bn.get(e);
- const res=typeof fn==='function'?fn(...r.map(x=>bn.get(x))):fn;
- if(res&&typeof res.then==='function')return res.then(v=>bn.set(n,v)).catch(err=>bn.set(n,''+err));
- bn.set(n,res);
- }catch(err){bn.set(n,''+err);}
- });
- // on=18: atob
- bn.set(18,(n)=>bn.set(n,atob(''+bn.get(n))));
- // cn=19: btoa
- bn.set(19,(n)=>bn.set(n,btoa(''+bn.get(n))));
- // un=20: conditional exec: if bn.get(n)===bn.get(e) then call bn.get(r)
- bn.set(20,(n,e,r,...o)=>{if(bn.get(n)===bn.get(e))return bn.get(r)(...o);});
- // an=21: abs comparison: Math.abs(bn.get(n)-bn.get(e))>bn.get(r) then call
- bn.set(21,(n,e,r,o,...i)=>{if(Math.abs(Number(bn.get(n))-Number(bn.get(e)))>Number(bn.get(r)))return bn.get(o)(...i);});
- // fn=22: execute sub-instructions
- bn.set(22,(n,e)=>{
- const saved=[...bn.get(Zt_key)];
- bn.set(Zt_key,[...e]);
- return executeVM().catch(err=>{bn.set(n,''+err);}).finally(()=>{bn.set(Zt_key,saved);});
- });
- // sn=23: void check + call: if bn.get(n)!==undefined then bn.get(e)(...r)
- bn.set(23,(n,e,...r)=>{if(void 0!==bn.get(n))return bn.get(e)(...r);});
- // Ht=24: property access + bind: bn.set(n, bn.get(e)[bn.get(r)].bind(bn.get(e)))
- bn.set(24,(n,e,r)=>{
- const obj=bn.get(e);
- const prop=bn.get(r);
- const val=obj?.[prop];
- bn.set(n,typeof val==='function'?val.bind(obj):val);
- });
- // ln=25: no-op
- bn.set(25,()=>{});
- // dn=26: no-op
- bn.set(26,()=>{});
- // hn=27: subtract/remove
- bn.set(27,(n,e)=>{const v=bn.get(n);if(Array.isArray(v)){v.splice(v.indexOf(bn.get(e)),1);}else bn.set(n,v-bn.get(e));});
- // pn=28: no-op
- bn.set(28,()=>{});
- // mn=29: less than
- bn.set(29,(n,e,r)=>bn.set(n,bn.get(e)<bn.get(r)));
- // gn=30: function def
- bn.set(30,(t,n,e,r)=>{
- const isArr=Array.isArray(r);
- const params=isArr?e:[];
- const body=(isArr?r:e)||[];
- bn.set(t,(...args)=>{
- if(resolved)return;
- const saved=[...bn.get(Zt_key)];
- if(isArr)for(let i=0;i<params.length;i++)bn.set(params[i],args[i]);
- bn.set(Zt_key,[...body]);
- return executeVM().then(()=>bn.get(n)).catch(e=>''+e).finally(()=>bn.set(Zt_key,saved));
- });
- });
- // wn=33: multiply
- bn.set(33,(n,e,r)=>bn.set(n,Number(bn.get(e))*Number(bn.get(r))));
- // yn=34: divide
- bn.set(34,(n,e,r)=>{const d=Number(bn.get(r));bn.set(n,d===0?0:Number(bn.get(e))/d);});
- // vn=35: (not common, maybe modulo)
- bn.set(35,(n,e,r)=>bn.set(n,Number(bn.get(e))%Number(bn.get(r))));
- // Load program
- bn.set(Zt_key,instructions);
- // VM executor
- async function executeVM(){
- let steps=0;
- const ip=bn.get(Zt_key);
- while(ip&&ip.length>0&&steps<200000&&!resolved){
- steps++;
- const [op,...args]=ip.shift();
- const h=bn.get(op);
- if(typeof h==='function'){
- try{const r=h(...args);if(r&&typeof r.then==='function')await r;}
- catch(e){/* silently continue */}
- }
- }
- }
- const timeout=setTimeout(()=>{if(!resolved){resolved=true;resolvedValue='';}},8000);
- executeVM().then(()=>{
- clearTimeout(timeout);
- process.stdout.write(resolvedValue||'');
- process.exit(0);
- }).catch(()=>{
- clearTimeout(timeout);
- process.stdout.write('');
- process.exit(0);
- });
|