Created
February 2, 2021 09:09
-
-
Save ohac/bd7c9a065c31d9adbdf2737f63b5cc81 to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
tmpfile=$(tempfile) | |
stun -v stun.l.google.com:19302 2> $tmpfile > /dev/null | |
port1=$(grep Opened.port $tmpfile | head -1 | cut -d ' ' -f 3) | |
port2=$(grep Opened.port $tmpfile | tail -1 | cut -d ' ' -f 3) | |
hostport1=$(grep MappedAddre $tmpfile | head -1 | cut -d ' ' -f 3) | |
hostport2=$(grep MappedAddre $tmpfile | tail -1 | cut -d ' ' -f 3) | |
rm -f $tmpfile | |
globalipv4=$(echo $hostport1 | cut -d : -f 1) | |
globalport1=$(echo $hostport1 | cut -d : -f 2) | |
globalport2=$(echo $hostport2 | cut -d : -f 2) | |
echo $port1 | |
echo $port2 | |
echo $globalipv4 | |
echo $globalport1 | |
echo $globalport2 | |
targetipv4=54.218.114.62 | |
set -x | |
nc -u -p $port1 $targetipv4 $port1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment