Skip to content

Instantly share code, notes, and snippets.

@ohac
Created February 2, 2021 09:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ohac/bd7c9a065c31d9adbdf2737f63b5cc81 to your computer and use it in GitHub Desktop.
Save ohac/bd7c9a065c31d9adbdf2737f63b5cc81 to your computer and use it in GitHub Desktop.
#!/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