diff --git a/examples/README b/examples/README index f24c4de71..4a5c268dd 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 000000000..dc241046c --- /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