Last active
December 20, 2015 13:58
-
-
Save calston/6142310 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from twisted.internet import ssl, protocol | |
from twisted.protocols.tls import TLSMemoryBIOFactory | |
from txeap import proto_utils | |
class EAPTLSProtocol(protocol.Protocol): | |
def dataReceived(self, bytes): | |
print "Received:", repr(bytes) | |
serverFactory = protocol.ServerFactory() | |
serverFactory.protocol = EAPTLSProtocol | |
cert="/etc/ssl/certs/ssl-cert-snakeoil.pem" | |
key="/etc/ssl/private/ssl-cert-snakeoil.key" | |
contextFactory = ssl.DefaultOpenSSLContextFactory(key, cert) | |
wrapperFactory = TLSMemoryBIOFactory(contextFactory, False, serverFactory) | |
tlsProtocol = wrapperFactory.buildProtocol(None) | |
transport = proto_utils.StringTransport() | |
tlsProtocol.makeConnection(transport) | |
testclientinit = '\x80\x00\x00\x00\xdd\x16\x03\x01\x00\xd8\x01\x00\x00\xd4\x03\x01Q\xfb\xfc\n\xd3c\xb55,\t\x1f\xe2\x88\x8e%\xd5\xc2Sf/A\xc7y\x87\x01d\xcd\xa9]J\x1b\xab\x00\x00f\xc0\x14\xc0\n\xc0"\xc0!\x009\x008\x00\x88\x00\x87\xc0\x0f\xc0\x05\x005\x00\x84\xc0\x12\xc0\x08\xc0\x1c\xc0\x1b\x00\x16\x00\x13\xc0\r\xc0\x03\x00\n\xc0\x13\xc0\t\xc0\x1f\xc0\x1e\x003\x002\x00\x9a\x00\x99\x00E\x00D\xc0\x0e\xc0\x04\x00/\x00\x96\x00A\xc0\x11\xc0\x07\xc0\x0c\xc0\x02\x00\x05\x00\x04\x00\x15\x00\x12\x00\t\x00\x14\x00\x11\x00\x08\x00\x06\x00\x03\x00\xff\x01\x00\x00E\x00\x0b\x00\x04\x03\x00\x01\x02\x00\n\x004\x002\x00\x0e\x00\r\x00\x19\x00\x0b\x00\x0c\x00\x18\x00\t\x00\n\x00\x16\x00\x17\x00\x08\x00\x06\x00\x07\x00\x14\x00\x15\x00\x04\x00\x05\x00\x12\x00\x13\x00\x01\x00\x02\x00\x03\x00\x0f\x00\x10\x00\x11\x00\x0f\x00\x01\x01' | |
tlsProtocol.dataReceived(testclientinit) | |
print repr(tlsProtocol.transport.value()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment