Update server.py

This commit is contained in:
Namhyeon Go 2024-02-17 14:23:51 +09:00 committed by GitHub
parent ce23bd341e
commit df42b8dc6e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -137,6 +137,24 @@ def proxy_server(webserver, port, scheme, method, url, conn, addr, data):
except Exception as e: except Exception as e:
raise Exception("SSL negotiation failed. %s" % (str(e))) raise Exception("SSL negotiation failed. %s" % (str(e)))
if server_url == "localhost":
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
context = ssl.create_default_context()
context.check_hostname = False
context.verify_mode = ssl.CERT_NONE
ssl_sock = context.wrap_socket(sock, server_hostname=webserver)
ssl_sock.connect((webserver, port))
ssl_sock.sendall(data)
while True:
data = ssl_sock.recv(1024)
if not data:
break
conn.send(data)
print("[*] Request and received. Done. %s" % (str(addr[0])))
else:
proxy_data = { proxy_data = {
'headers': { 'headers': {
"User-Agent": "php-httpproxy/0.1.3 (Client; Python " + python_version() + "; abuse@catswords.net)", "User-Agent": "php-httpproxy/0.1.3 (Client; Python " + python_version() + "; abuse@catswords.net)",