Created
January 4, 2019 17:20
-
-
Save cbowdon/a07c56693d07c97286715a81e572ec1d to your computer and use it in GitHub Desktop.
Poor man's intercepting proxy
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
#!/usr/bin/env bash | |
# Thanks to https://blog.hawkhost.com/2009/12/12/using-netcat-as-an-intercepting-proxy/ | |
server=${1:-localhost} | |
localport=${2:-8080} | |
remoteport=${3:-$localport} | |
pipe=intercepting-proxy.pipe | |
# shellcheck disable=SC2094 | |
rm -f "$pipe" && | |
mkfifo "$pipe" && | |
echo "listening for localhost:${localport} to proxy to ${server}:${remoteport}..." && | |
nc -k -l -p "$localport" < "$pipe" | tee proxy-requests.log | nc "$server" "$remoteport" | tee "$pipe" proxy-responses.log |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment