I am trying to make a remote shell thing with python. But when i connect the client (running on replit.com) to the target machine (my local machine), This error shows up:
~/SEAshell$ python3 client.py
Enter hostname: 192.168.10.16
[*] Set target to 192.168.10.16 ...
[*] Connecting to server...
Traceback (most recent call last):
File "client.py", line 14, in <module>
server.connect(ADDR)
TimeoutError: [Errno 110] Connection timed out
It takes a lot of time after [*] Connecting to server... and shows the traceback.
Please note the code is incomplete as the command is not sent due to the mentioned error...
Heres the client code (from where the command is sent):
from socket import *
from threading import Thread
from os import system
HOST = input('Enter hostname: ')
print('[*] Set target to ' + HOST + " ...")
PORT = 623
ADDR = (HOST, PORT)
BUFF = 1024 * 128
SEP = "<sep>"
server = socket(AF_INET, SOCK_STREAM)
print('[*] Connecting to server...')
server.connect(ADDR)
print('[*] Server connected successfully!')
def remote():
print('[>] Activation shell for ' + str(addr))
print('[>] Receiving path information...')
info = server.recv(BUFF).decode()
info = info.split(SEP)
while True:
command = input(info[2] + "@" + info[1] + ":" + info[0] + "$ ")
print('Test: ' + command)
remote()
and heres the server code (where the command will be executed):
from socket import *
from threading import Thread
import os
HOST = gethostbyname(gethostname())
PORT = 623
ADDR = (HOST, PORT)
BUFF = 1024 * 128
SEP = "<sep>"
print('[*] Starting server at ' + str(ADDR))
server = socket(AF_INET, SOCK_STREAM)
print('[*] Binding server...')
try:
server.bind(ADDR)
except:
ADDR = (HOST, 624)
server.bind(ADDR)
print('[*] Binded server at ' + str(ADDR))
print('[*] Server binded successfully!')
print('[*] Listening for incoming connections')
server.listen(5)
def remote(conn, addr):
cdir = os.getcwd()
login = os.getlogin()
hostname = gethostname()
firstsend = send()
while True:
print('[*] Queued...')
conn, addr = server.accept()
print('[*] Connection received from ' + str(addr))
t = Thread(target=remote, args=(conn, addr))
t.start()
print('[*] Listening for new connections...')
so please try to help me figure it out and maybe check out the repl: https://replit.com/@dragsdagod/SEAshell
thanks in advance!