-
-
Save robo-corg/6dbe481985b1d21e9699 to your computer and use it in GitHub Desktop.
This file contains 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 | |
# Parameters | |
socket="$1" | |
dump="/tmp/capture.pcap" | |
# Extract repetition | |
port=9876 | |
source_socket="$(dirname "${socket}")/$(basename "${socket}").orig" | |
# Move socket files | |
mv "${socket}" "${source_socket}" | |
trap "{ rm '${socket}'; mv '${source_socket}' '${socket}'; }" EXIT | |
# Setup pipe over TCP that we can tap into | |
socat -t100 "TCP-LISTEN:${port},reuseaddr,fork" "UNIX-CONNECT:${source_socket}" & | |
socat -t100 "UNIX-LISTEN:${socket},mode=777,reuseaddr,fork" "TCP:localhost:${port}" & | |
# Record traffic | |
tshark -i lo -w "${dump}" "dst port ${port} or src port ${port}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment