无法接收serverHello数据包

时间:2019-03-04 08:26:08

标签: python ssl proxy openssl

我是python编程的新手,我正在尝试编写连接socat openssl服务器和客户端的代理。现在我面临着传送数据包的问题

为了连接我写的客户端

    #client
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.bind((localaddr, localport))
    s.listen(1)

    while(1):
        client, addr = s.accept()
        thread = Thread(target=handleConnection, args=(client,))
        thread.start()
        thread.join()

    s.close()

到服务器端

def handleConnection(client):
    context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
    context.check_hostname = False
    context.verify_mode = ssl.CERT_NONE
    context.set_ciphers("DHE-RSA-AES128-SHA256")

    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
    server = context.wrap_socket(s, server_side=False)

    #connect to server
    server.connect((serveraddr, serverport))

    t1 = Process(target=forwardTLS, args=(client, server, "client",))
    t1.start()
    forwardTLS(server, client, "server")
    t1.join()

最后我的代理人

def forwardTLS(r, w, label):
    print("--new packet from ", label, "---")

    while(1):
        #receive packet
        read = r.recv(5)

        header = [ord(x) for x in read]
        payload_length = 256*header[3] + header[4]

        #receive another packet
        read2 = r.recv(payload_length)

        # deliver to the other side
        w.send(read + read2)

在这里,我从服务器端陷入了recv函数中,是因为我没有成功将clientHello传递到服务器吗?

Info image

有人可以帮我解决这个问题吗?非常重要

0 个答案:

没有答案