Skip to content

Instantly share code, notes, and snippets.

@grahamhelton
Created September 10, 2024 02:54
Show Gist options
  • Save grahamhelton/6cef7df2cc059078ae0702492b6b9f1f to your computer and use it in GitHub Desktop.
Save grahamhelton/6cef7df2cc059078ae0702492b6b9f1f to your computer and use it in GitHub Desktop.
#!/bin/bash
# This script compiles tcpdump as a static binary
# Useful for running in pods or other places you shouldn't be
GREEN=$(tput setaf 2)
NOCOLOR=$(tput sgr0)
TICK="$NOCOLOR[$GREEN+$NOCOLOR] "
spin() {
local pid=$!
local spin='|/-\'
local i=0
while kill -0 $pid 2>/dev/null; do
i=$(((i + 1) % 4))
printf "\r${spin:$i:1}"
sleep .1
done
printf " \r"
}
echo $TICK"Building tcpdump, please wait...."
docker run -v $PWD:/out --rm alpine sh -c '
apk add --update alpine-sdk git libpcap libpcap-dev 1> /dev/null
cd /tmp; git clone https://github.com/eldadru/ksniff 1> /dev/null; cd ksniff
TCPDUMP_VERSION=4.99.4
make static-tcpdump 1> /dev/null
cp static-tcpdump /out
' 1> /dev/null 2> >(cat >/dev/null) &
spin
wait $!
echo $TICK"Done!"
@grahamhelton
Copy link
Author

Picture with pretty colors: image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment