Last active
May 6, 2022 16:25
-
-
Save whit3rabbit/dfb739a2872e082e30e1d80ea1488ff2 to your computer and use it in GitHub Desktop.
Docker Swarm Packet Capture
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| echo "[+] Getting docker swarm ingress network ID" | |
| INGRESS=`sudo docker network ls | grep ingress | cut -b -10` | |
| echo "[+] Ingress: $INGRESS" | |
| echo "[+] Running netshoot container with tcpdump" | |
| read -p "[?] Filename for packet capture: " OUTPUT_FILE | |
| echo "[+] Output pcap is at: $PWD/$OUTPUT_FILE" | |
| sudo docker run -it --rm \ | |
| -v /var/run/docker/netns:/var/run/docker/netns \ | |
| -v $PWD:/root/ \ | |
| --privileged=true nicolaka/netshoot \ | |
| nsenter --net=/var/run/docker/netns/1-$INGRESS \ | |
| tcpdump -i any -w /root/$OUTPUT_FILE -v |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment