diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2015-04-08 12:00:17 +1200 |
---|---|---|
committer | Aldo Cortesi <aldo@nullcube.com> | 2015-04-08 12:00:17 +1200 |
commit | b1d2da19f952ee677ec9c86d13ac2f28db824275 (patch) | |
tree | a0f918f377226535791fa092631c494f6611642e /examples | |
parent | fb0a5d8f6383e689ccfbb498b0b3501dbdf712e2 (diff) | |
parent | 0aa2fca25aa5511c89653d876a39eec6e812e184 (diff) | |
download | mitmproxy-b1d2da19f952ee677ec9c86d13ac2f28db824275.tar.gz mitmproxy-b1d2da19f952ee677ec9c86d13ac2f28db824275.tar.bz2 mitmproxy-b1d2da19f952ee677ec9c86d13ac2f28db824275.zip |
Merge branch 'master' of ssh.github.com:mitmproxy/mitmproxy
Diffstat (limited to 'examples')
-rw-r--r-- | examples/README | 1 | ||||
-rw-r--r-- | examples/filt.py | 15 | ||||
-rw-r--r-- | examples/ignore_websocket.py | 3 |
3 files changed, 18 insertions, 1 deletions
diff --git a/examples/README b/examples/README index f24c4de7..4a5c268d 100644 --- a/examples/README +++ b/examples/README @@ -3,6 +3,7 @@ add_header.py Simple script that just adds a header to every request change_upstream_proxy.py Dynamically change the upstream proxy dns_spoofing.py Use mitmproxy in a DNS spoofing scenario. dup_and_replay.py Duplicates each request, changes it, and then replays the modified request. +filt.py Use mitmproxy's filter expressions in your script. iframe_injector.py Inject configurable iframe into pages. modify_form.py Modify all form submissions to add a parameter. modify_querystring.py Modify all query strings to add a parameters. diff --git a/examples/filt.py b/examples/filt.py new file mode 100644 index 00000000..dc241046 --- /dev/null +++ b/examples/filt.py @@ -0,0 +1,15 @@ +# This scripts demonstrates how to use mitmproxy's filter pattern in inline scripts. +# Usage: mitmdump -s "filt.py FILTER" + +from libmproxy import filt + +def start(context, argv): + print argv + if len(argv) != 2: + raise ValueError("Usage: -s 'filt.py FILTER'") + context.filter = filt.parse(argv[1]) + +def response(context, flow): + if flow.match(context.filter): + print("Flow matches filter:") + print(flow)
\ No newline at end of file diff --git a/examples/ignore_websocket.py b/examples/ignore_websocket.py index 48093951..f7a94bdf 100644 --- a/examples/ignore_websocket.py +++ b/examples/ignore_websocket.py @@ -26,7 +26,8 @@ def done(context): @concurrent def response(context, flow): - if flow.response.headers.get_first("Connection", None) == "Upgrade": + value = flow.response.headers.get_first("Connection", None) + if value and value.upper() == "UPGRADE": # We need to send the response manually now... flow.client_conn.send(flow.response.assemble()) # ...and then delegate to tcp passthrough. |