Skip to content

Instantly share code, notes, and snippets.

@dreness
Created March 15, 2022 06:28
Show Gist options
  • Save dreness/3879922517d6403e7f0e6b76be1a4275 to your computer and use it in GitHub Desktop.
Save dreness/3879922517d6403e7f0e6b76be1a4275 to your computer and use it in GitHub Desktop.
run tcpdump to capture chrome activity
#!/bin/zsh
# This script uses apple-specific features of tcpdump
INT=en0
PIDS=($(pgrep Chrome | tr '\n' ' '))
PID_FILTER=$(echo pid=${(j: or pid=:)PIDS})
FILTER="-Q \"$(echo -n "if=${INT} and ("${PID_FILTER}))\""
OUT=$(mktemp)
CMD="/usr/bin/sudo /usr/sbin/tcpdump -i pktap,${INT} -s0 -w ${OUT} -nk ${FILTER}"
echo "Capturing to ${OUT} with command:\n${CMD}"
eval ${CMD}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment