From 4ffaadd4355e943d7fa46f3050a1fb780f4d261d Mon Sep 17 00:00:00 2001 From: Henrik Nordstrom Date: Tue, 8 Feb 2011 16:58:38 +0100 Subject: [PATCH] Allow specifying the accepted ciphersuites --- libmproxy/proxy.py | 4 +++- mitmdump | 8 +++++++- mitmplayback | 9 ++++++++- mitmproxy | 9 ++++++++- mitmrecord | 9 ++++++++- 5 files changed, 34 insertions(+), 5 deletions(-) diff --git a/libmproxy/proxy.py b/libmproxy/proxy.py index 631e24707..f3ea2ed29 100644 --- a/libmproxy/proxy.py +++ b/libmproxy/proxy.py @@ -22,8 +22,9 @@ class ProxyError(Exception): class Config: - def __init__(self, pemfile): + def __init__(self, pemfile, ciphers = None): self.pemfile = pemfile + self.ciphers = ciphers def read_chunked(fp): @@ -520,6 +521,7 @@ class ProxyHandler(SocketServer.StreamRequestHandler): keyfile = config.pemfile, server_side = True, ssl_version = ssl.PROTOCOL_SSLv23, + ciphers = config.ciphers, do_handshake_on_connect = False ) self.rfile = FileLike(self.connection) diff --git a/mitmdump b/mitmdump index f3e8ae0a3..26686afd0 100755 --- a/mitmdump +++ b/mitmdump @@ -31,6 +31,11 @@ if __name__ == '__main__': type = "str", dest="cert", default="~/.mitmproxy/cert.pem", help = "SSL certificate file." ) + parser.add_option( + "--ciphers", action="store", + type = "str", dest="ciphers", default=None, + help = "SSL ciphers." + ) parser.add_option( "-p", "--port", action="store", type = "int", dest="port", default=8080, @@ -54,7 +59,8 @@ if __name__ == '__main__': utils.make_bogus_cert(certpath) proxy.config = proxy.Config( - certpath + certpath, + ciphers = options.ciphers ) server = proxy.ProxyServer(options.port) m = dump.DumpMaster(server, options.verbose) diff --git a/mitmplayback b/mitmplayback index ea8020945..eb147cd93 100755 --- a/mitmplayback +++ b/mitmplayback @@ -36,6 +36,12 @@ if __name__ == '__main__': help = "SSL certificate file." ) + parser.add_option( + "--ciphers", action="store", + type = "str", dest="ciphers", default=None, + help = "SSL ciphers." + ) + parser.add_option( "-p", "--port", action="store", type = "int", dest="port", default=8080, @@ -68,7 +74,8 @@ if __name__ == '__main__': utils.make_bogus_cert(certpath) proxy.config = proxy.Config( - certpath + certpath, + ciphers = options.ciphers ) server = proxy.ProxyServer(options.port) m = playback.PlaybackMaster(server, options) diff --git a/mitmproxy b/mitmproxy index 074a439c6..e3ec9d9eb 100755 --- a/mitmproxy +++ b/mitmproxy @@ -39,6 +39,12 @@ if __name__ == '__main__': help = "SSL certificate file." ) + parser.add_option( + "--ciphers", action="store", + type = "str", dest="ciphers", default=None, + help = "SSL ciphers." + ) + parser.add_option( "-p", "--port", action="store", type = "int", dest="port", default=8080, @@ -97,7 +103,8 @@ if __name__ == '__main__': utils.make_bogus_cert(certpath) proxy.config = proxy.Config( - certpath + certpath, + ciphers = options.ciphers ) if options.cache is not None: utils.mkdir_p(options.cache) diff --git a/mitmrecord b/mitmrecord index 1fcfde4a3..11c7b6ca3 100755 --- a/mitmrecord +++ b/mitmrecord @@ -35,6 +35,12 @@ if __name__ == '__main__': help = "SSL certificate file." ) + parser.add_option( + "--ciphers", action="store", + type = "str", dest="ciphers", default=None, + help = "SSL ciphers." + ) + parser.add_option( "-p", "--port", action="store", type = "int", dest="port", default=8080, @@ -73,7 +79,8 @@ if __name__ == '__main__': utils.make_bogus_cert(certpath) proxy.config = proxy.Config( - certpath + certpath, + ciphers = options.ciphers ) server = proxy.ProxyServer(options.port) utils.mkdir_p(options.cache)