Skip to content

Instantly share code, notes, and snippets.

@hnts
Last active December 20, 2021 10:22
Show Gist options
  • Save hnts/be4fabf653dfa2532d46f0228ca98256 to your computer and use it in GitHub Desktop.
Save hnts/be4fabf653dfa2532d46f0228ca98256 to your computer and use it in GitHub Desktop.
enumerate
#!/bin/bash
echo "[+] Create pods for enumerating host network..."
(
kubectl create ns enumerate
kubectl label ns enumerate istio-injection=enabled
for i in {1..15} ; do
cat << EOS | kubectl apply -f -
apiVersion: v1
kind: Pod
metadata:
name: busybox-$i
namespace: enumerate
spec:
containers:
- image: busybox
name: busybox
args:
- sleep
- "1000"
resources:
requests:
cpu: 10m
memory: 10Mi
imagePullPolicy: IfNotPresent
livenessProbe:
tcpSocket:
host: 192.168.11.$i
port: 22
restartPolicy: Never
EOS
done
kubectl wait --for=condition=Ready pod $(echo {1..15} | xargs -n1 echo busybox- | sed 's/ //g') -n enumerate
sleep 10
) > /dev/null
for i in {1..15} ; do
if ! kubectl describe pod busybox-$i -n enumerate | grep "Liveness probe failed" > /dev/null; then
echo "[!] 192.168.11.$i exists and the ssh port is opened"
fi
done
echo "[+] Clean up..."
kubectl delete ns enumerate > /dev/null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment