Created
August 26, 2016 04:02
-
-
Save smj10j/0a216492ce09c4c88fcdc329b7cd205d to your computer and use it in GitHub Desktop.
Redirects local ports on the fly
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
| ROUTER="ncat --sh-exec 'ncat $(sudo route -n get default -interface utun0 | sed -nre 's/.*?gateway: (.*?)$/\1/p') 7200' \ | |
| --wait 30 \ | |
| --output ncat-forward-tcp.dump \ | |
| --verbose \ | |
| --listen 10020 " | |
| pids="" | |
| CMD=$(echo ${ROUTER}{'& ; pids="$pids $!"; ','--udp & ; pids="$pids $!"; '}) | |
| eval "$CMD" | |
| KILLPIDS() { | |
| foreach p in $(echo "( $pids )"); do kill -9 $p; done | |
| } | |
| trap KILLPIDS QUIT INT ERR | |
| wait %2 %2 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment