Navigation X
ALERT
Click here to register with a few steps and explore all our cool stuff we have to offer!



 2798

[Tutorial] Building Proxy with Python (CAN BE USED IN VPS TO HOST OWN PROXY)

by sznw - 21 April, 2024 - 01:47 PM
This post is by a banned member (SOXX01) - Unhide
SOXX01  
Registered
159
Posts
0
Threads
#25
(This post was last modified: 12 September, 2024 - 08:25 AM by SOXX01.)
(21 April, 2024 - 01:47 PM)sznw Wrote: Show More
Hi Folks.

[Image: ban2.gif]  (NOT LEECHERS LEAVE A LIKE)  [Image: ban2.gif]
[Image: ?u=https%3A%2F%2Fi.postimg.cc%2FL6W6KRj8...633632.gif]

Ill drop Python Proxy - which can be used at both UNIX and Windows OS'es.

The source would tell more than thousand words.

Check it out below: 



Have insane day  [Image: PepeBlush.png]
[/list]

okay nice

I have edit the skript. Now you can open e.G. 1000 Proxy Server#!/usr/bin/env pythonimport socketimport sysimport multiprocessingimport os def start_proxy_server(port):    # Konfigurationen    max_conn = 5  # Maximale Anzahl an Verbindungen    buffer_size = 8192  # Maximale Puffergröße für Sockets     try:        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)  # Socket initialisieren        s.bind(('', port))  # Socket binden        s.listen(max_conn)  # Auf eingehende Verbindungen warten        print(f"Proxy-Server erfolgreich auf Port {port} gestartet")    except Exception as e:        print(f"Fehler beim Initialisieren des Sockets auf Port {port}: {e}")        sys.exit(1)     while True:        try:            conn, addr = s.accept()  # Verbindung vom Client akzeptieren            data = conn.recv(buffer_size)  # Daten vom Client empfangen            # Verbindung in einem separaten Prozess bearbeiten            multiprocessing.Process(target=conn_string, args=(conn, data, addr)).start()        except KeyboardInterrupt:            s.close()            print(f"Proxy-Server auf Port {port} wird heruntergefahren...")            sys.exit(1) def conn_string(conn, data, addr):    try:        first_line = data.split(b'\n')[0].decode()        url = first_line.split(' ')[1]        http_pos = url.find("://")  # Position von ://        if (http_pos == -1):            temp = url        else:            temp = url[(http_pos + 3):]  # Den Rest der URL bekommen        port_pos = temp.find(":")  # Position des Ports (falls vorhanden)        webserver_pos = temp.find("/")  # Ende des Webservers finden        if webserver_pos == -1:            webserver_pos = len(temp)        webserver = ""        port = -1        if (port_pos == -1 or webserver_pos < port_pos):            port = 80            webserver = temp[:webserver_pos]        else:            port = int((temp[(port_pos + 1):])[:webserver_pos - port_pos - 1])            webserver = temp[:port_pos]         proxy_server(webserver, port, conn, data, addr)    except Exception as e:        print(f"Fehler in conn_string: {e}") def proxy_server(webserver, port, conn, data, addr):    try:        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)        s.connect((webserver, port))        s.send(data)        while True:            reply = s.recv(8192)            if len(reply) > 0:                conn.send(reply)  # Antwort zurück an den Client senden                dar = float(len(reply))                dar = float(dar / 1024)                dar = "%.3s" % (str(dar))                dar = "%s KB" % (dar)                print(f"REQ DONE: {addr[0]} => {dar} <= ")            else:                break        s.close()        conn.close()    except socket.error as e:        print(f"Socket-Fehler: {e}")        s.close()        conn.close()        sys.exit(1) def run_proxy_on_port(start_port, num_proxies):    processes = []    proxy_list = []    for i in range(num_proxies):        port = start_port + i        p = multiprocessing.Process(target=start_proxy_server, args=(port,))        p.start()        processes.append(p)        # IP-Adresse ist leer, da der Proxy auf allen Schnittstellen lauscht        proxy_list.append(f"127.0.0.1:{port}")        print(f"Proxy-Server auf Port {port} gestartet")     # Die Prozesse warten, bis alle beendet sind    for p in processes:        p.join()        # Ermittle das Verzeichnis des Skripts    script_dir = os.path.dirname(os.path.abspath(__file__))    proxies_file_path = os.path.join(script_dir, "proxies.txt")        print(f"Speichere Proxys in '{proxies_file_path}'")    try:        # Schreibe die Proxy-Liste in eine Textdatei im Verzeichnis des Skripts        with open(proxies_file_path, "w") as f:            for proxy in proxy_list:                f.write(f"{proxy}\n")        print(f"Proxy-Server-IPs und Ports wurden in '{proxies_file_path}' gespeichert.")    except Exception as e:        print(f"Fehler beim Schreiben der Datei: {e}")     # Liste die Proxies im Terminal auf    print("\nListe der gestarteten Proxy-Server:")    for proxy in proxy_list:        print(proxy) if __name__ == "__main__":    try:        start_port = 8080  # Startport        num_proxies = int(input("Geben Sie die Anzahl der zu erstellenden Proxy-Server ein: "))        if num_proxies <= 0:            raise ValueError("Die Anzahl der Proxy-Server muss größer als 0 sein.")        run_proxy_on_port(start_port, num_proxies)    except ValueError as e:        print(f"Ungültige Eingabe: {e}")        sys.exit(1)
This post is by a banned member (SOXX01) - Unhide
SOXX01  
Registered
159
Posts
0
Threads
#26
I have edit the skript. Now you can open e.G. 1000 Proxy Server

#!/usr/bin/env pythonimport socketimport sysimport multiprocessingimport os def start_proxy_server(port):    # Konfigurationen    max_conn = 5  # Maximale Anzahl an Verbindungen    buffer_size = 8192  # Maximale Puffergröße für Sockets     try:        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)  # Socket initialisieren        s.bind(('', port))  # Socket binden        s.listen(max_conn)  # Auf eingehende Verbindungen warten        print(f"Proxy-Server erfolgreich auf Port {port} gestartet")    except Exception as e:        print(f"Fehler beim Initialisieren des Sockets auf Port {port}: {e}")        sys.exit(1)     while True:        try:            conn, addr = s.accept()  # Verbindung vom Client akzeptieren            data = conn.recv(buffer_size)  # Daten vom Client empfangen            # Verbindung in einem separaten Prozess bearbeiten            multiprocessing.Process(target=conn_string, args=(conn, data, addr)).start()        except KeyboardInterrupt:            s.close()            print(f"Proxy-Server auf Port {port} wird heruntergefahren...")            sys.exit(1) def conn_string(conn, data, addr):    try:        first_line = data.split(b'\n')[0].decode()        url = first_line.split(' ')[1]        http_pos = url.find("://")  # Position von ://        if (http_pos == -1):            temp = url        else:            temp = url[(http_pos + 3):]  # Den Rest der URL bekommen        port_pos = temp.find(":")  # Position des Ports (falls vorhanden)        webserver_pos = temp.find("/")  # Ende des Webservers finden        if webserver_pos == -1:            webserver_pos = len(temp)        webserver = ""        port = -1        if (port_pos == -1 or webserver_pos < port_pos):            port = 80            webserver = temp[:webserver_pos]        else:            port = int((temp[(port_pos + 1):])[:webserver_pos - port_pos - 1])            webserver = temp[:port_pos]         proxy_server(webserver, port, conn, data, addr)    except Exception as e:        print(f"Fehler in conn_string: {e}") def proxy_server(webserver, port, conn, data, addr):    try:        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)        s.connect((webserver, port))        s.send(data)        while True:            reply = s.recv(8192)            if len(reply) > 0:                conn.send(reply)  # Antwort zurück an den Client senden                dar = float(len(reply))                dar = float(dar / 1024)                dar = "%.3s" % (str(dar))                dar = "%s KB" % (dar)                print(f"REQ DONE: {addr[0]} => {dar} <= ")            else:                break        s.close()        conn.close()    except socket.error as e:        print(f"Socket-Fehler: {e}")        s.close()        conn.close()        sys.exit(1) def run_proxy_on_port(start_port, num_proxies):    processes = []    proxy_list = []    for i in range(num_proxies):        port = start_port + i        p = multiprocessing.Process(target=start_proxy_server, args=(port,))        p.start()        processes.append(p)        # IP-Adresse ist leer, da der Proxy auf allen Schnittstellen lauscht        proxy_list.append(f"127.0.0.1:{port}")        print(f"Proxy-Server auf Port {port} gestartet")     # Die Prozesse warten, bis alle beendet sind    for p in processes:        p.join()        # Ermittle das Verzeichnis des Skripts    script_dir = os.path.dirname(os.path.abspath(__file__))    proxies_file_path = os.path.join(script_dir, "proxies.txt")        print(f"Speichere Proxys in '{proxies_file_path}'")    try:        # Schreibe die Proxy-Liste in eine Textdatei im Verzeichnis des Skripts        with open(proxies_file_path, "w") as f:            for proxy in proxy_list:                f.write(f"{proxy}\n")        print(f"Proxy-Server-IPs und Ports wurden in '{proxies_file_path}' gespeichert.")    except Exception as e:        print(f"Fehler beim Schreiben der Datei: {e}")     # Liste die Proxies im Terminal auf    print("\nListe der gestarteten Proxy-Server:")    for proxy in proxy_list:        print(proxy) if __name__ == "__main__":    try:        start_port = 8080  # Startport        num_proxies = int(input("Geben Sie die Anzahl der zu erstellenden Proxy-Server ein: "))        if num_proxies <= 0:            raise ValueError("Die Anzahl der Proxy-Server muss größer als 0 sein.")        run_proxy_on_port(start_port, num_proxies)    except ValueError as e:        print(f"Ungültige Eingabe: {e}")        sys.exit(1)
This post is by a banned member (Rbxholding1) - Unhide
This post is by a banned member (OzirusDev) - Unhide
OzirusDev  
Registered
235
Posts
0
Threads
1 Year of service
#28
(21 April, 2024 - 01:47 PM)sznw Wrote: Show More
Hi Folks.

[Image: ban2.gif]  (NOT LEECHERS LEAVE A LIKE)  [Image: ban2.gif]
[Image: ?u=https%3A%2F%2Fi.postimg.cc%2FL6W6KRj8...633632.gif]

Ill drop Python Proxy - which can be used at both UNIX and Windows OS'es.

The source would tell more than thousand words.

Check it out below: 



Have insane day  [Image: PepeBlush.png]
[/list]

thanks
This post is by a banned member (zxc4we020) - Unhide
zxc4we020  
Registered
29
Posts
0
Threads
#29
Look very cool lwt me try
This post is by a banned member (ernesmedal0) - Unhide
131
Posts
0
Threads
#30
is this possible?

Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
or
Sign in
Already have an account? Sign in here.


Forum Jump:


Users browsing this thread: 4 Guest(s)