Skip to content

Instantly share code, notes, and snippets.

@ismaild
Created June 13, 2012 17:49
Show Gist options
  • Save ismaild/2925473 to your computer and use it in GitHub Desktop.
Save ismaild/2925473 to your computer and use it in GitHub Desktop.
testing mitmproxy
#!/usr/bin/env python
"""
Testing
"""
from libmproxy import controller, proxy
import os
class ModifyMaster(controller.Master):
def __init__(self, server):
controller.Master.__init__(self, server)
self.modifyhosts = {}
def run(self):
try:
return controller.Master.run(self)
except KeyboardInterrupt:
self.shutdown()
def handle_request(self, msg):
hid = (msg.host, msg.port)
#'acked', 'anticache', 'anticomp', 'client_conn', 'close', 'constrain_encoding', 'content', 'copy', 'decode', 'encode', 'get_form_urlencoded', 'get_query', 'get_url', 'headers', 'host', 'is_replay', 'method', 'path', 'port', 'q', 'replace', 'scheme', 'set_form_urlencoded', 'set_query', 'set_url', 'modifyauth', 'modifycookie', 'timestamp'
print "-"*20
print msg.content
print msg.headers, msg.host
msg._ack()
config = proxy.ProxyConfig(
cacert = os.path.expanduser("~/.mitmproxy/mitmproxy-ca.pem")
)
server = proxy.ProxyServer(config,9001, address='127.0.0.1')
m = ModifyMaster(server)
m.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment