remove stickycookie example

The recommended way to do this is mitmproxy/addons/stickycookie.py
This commit is contained in:
Maximilian Hils
2016-11-21 02:45:31 +01:00
parent 2138be8705
commit c90405253a
2 changed files with 0 additions and 43 deletions

View File

@@ -12,7 +12,6 @@
| nonblocking.py | Demonstrate parallel processing with a blocking script |
| remote_debug.py | This script enables remote debugging of the mitmproxy _UI_ with PyCharm. |
| sslstrip.py | sslstrip-like funtionality implemented with mitmproxy |
| stickycookies | An advanced example of using mitmproxy's FlowMaster directly. |
| stream | Enable streaming for all responses. |
| stream_modify.py | Modify a streamed response body. |
| tcp_message.py | Modify a raw TCP connection |

View File

@@ -1,42 +0,0 @@
#!/usr/bin/env python
"""
This example builds on mitmproxy's base proxying infrastructure to
implement functionality similar to the "sticky cookies" option.
Heads Up: In the majority of cases, you want to use inline scripts.
"""
import os
from mitmproxy import controller, proxy, master
from mitmproxy.proxy.server import ProxyServer
class StickyMaster(master.Master):
def __init__(self, server):
master.Master.__init__(self, server)
self.stickyhosts = {}
def run(self):
try:
return master.Master.run(self)
except KeyboardInterrupt:
self.shutdown()
@controller.handler
def request(self, flow):
hid = (flow.request.host, flow.request.port)
if "cookie" in flow.request.headers:
self.stickyhosts[hid] = flow.request.headers.get_all("cookie")
elif hid in self.stickyhosts:
flow.request.headers.set_all("cookie", self.stickyhosts[hid])
@controller.handler
def response(self, flow):
hid = (flow.request.host, flow.request.port)
if "set-cookie" in flow.response.headers:
self.stickyhosts[hid] = flow.response.headers.get_all("set-cookie")
config = proxy.ProxyConfig(port=8080)
server = ProxyServer(config)
m = StickyMaster(server)
m.run()