diff options
Diffstat (limited to 'examples/complex')
-rw-r--r-- | examples/complex/README.md | 2 | ||||
-rw-r--r-- | examples/complex/dns_spoofing.py | 3 | ||||
-rw-r--r-- | examples/complex/har_dump.py | 43 | ||||
-rw-r--r-- | examples/complex/remote_debug.py | 2 | ||||
-rw-r--r-- | examples/complex/tls_passthrough.py | 14 |
5 files changed, 32 insertions, 32 deletions
diff --git a/examples/complex/README.md b/examples/complex/README.md index 452f2395..77dbe2f5 100644 --- a/examples/complex/README.md +++ b/examples/complex/README.md @@ -5,7 +5,6 @@ | 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. | -| flowbasic.py | Basic use of mitmproxy's FlowMaster directly. | | full_transparency_shim.c | Setuid wrapper that can be used to run mitmproxy in full transparency mode, as a normal user. | | har_dump.py | Dump flows as HAR files. | | mitmproxywrapper.py | Bracket mitmproxy run with proxy enable/disable on OS X | @@ -16,3 +15,4 @@ | stream_modify.py | Modify a streamed response body. | | tcp_message.py | Modify a raw TCP connection | | tls_passthrough.py | Use conditional TLS interception based on a user-defined strategy. | +| xss_scanner.py | Scan all visited webpages. | diff --git a/examples/complex/dns_spoofing.py b/examples/complex/dns_spoofing.py index ca2bcd35..632783a7 100644 --- a/examples/complex/dns_spoofing.py +++ b/examples/complex/dns_spoofing.py @@ -54,5 +54,4 @@ class Rerouter: flow.request.port = port -def start(opts): - return Rerouter() +addons = [Rerouter()] diff --git a/examples/complex/har_dump.py b/examples/complex/har_dump.py index 9a86e45e..21bcc341 100644 --- a/examples/complex/har_dump.py +++ b/examples/complex/har_dump.py @@ -4,7 +4,6 @@ This inline script can be used to dump flows as HAR files. import json -import sys import base64 import zlib import os @@ -15,6 +14,7 @@ from datetime import timezone import mitmproxy from mitmproxy import version +from mitmproxy import ctx from mitmproxy.utils import strutils from mitmproxy.net.http import cookies @@ -25,17 +25,13 @@ HAR = {} SERVERS_SEEN = set() -def start(opts): - """ - Called once on script startup before any other events. - """ - if len(sys.argv) != 2: - raise ValueError( - 'Usage: -s "har_dump.py filename" ' - '(- will output to stdout, filenames ending with .zhar ' - 'will result in compressed har)' - ) +def load(l): + l.add_option( + "hardump", str, "", "HAR dump path.", + ) + +def configure(updated): HAR.update({ "log": { "version": "1.2", @@ -156,21 +152,20 @@ def done(): """ Called once on script shutdown, after any other events. """ - dump_file = sys.argv[1] + if ctx.options.hardump: + json_dump = json.dumps(HAR, indent=2) # type: str - json_dump = json.dumps(HAR, indent=2) # type: str - - if dump_file == '-': - mitmproxy.ctx.log(json_dump) - else: - raw = json_dump.encode() # type: bytes - if dump_file.endswith('.zhar'): - raw = zlib.compress(raw, 9) + if ctx.options.hardump == '-': + mitmproxy.ctx.log(json_dump) + else: + raw = json_dump.encode() # type: bytes + if ctx.options.hardump.endswith('.zhar'): + raw = zlib.compress(raw, 9) - with open(os.path.expanduser(dump_file), "wb") as f: - f.write(raw) + with open(os.path.expanduser(ctx.options.hardump), "wb") as f: + f.write(raw) - mitmproxy.ctx.log("HAR dump finished (wrote %s bytes to file)" % len(json_dump)) + mitmproxy.ctx.log("HAR dump finished (wrote %s bytes to file)" % len(json_dump)) def format_cookies(cookie_list): @@ -206,7 +201,7 @@ def format_request_cookies(fields): def format_response_cookies(fields): - return format_cookies((c[0], c[1].value, c[1].attrs) for c in fields) + return format_cookies((c[0], c[1][0], c[1][1]) for c in fields) def name_value(obj): diff --git a/examples/complex/remote_debug.py b/examples/complex/remote_debug.py index ae0dffc1..fa6f3d33 100644 --- a/examples/complex/remote_debug.py +++ b/examples/complex/remote_debug.py @@ -14,6 +14,6 @@ Usage: """ -def start(opts): +def load(l): import pydevd pydevd.settrace("localhost", port=5678, stdoutToServer=True, stderrToServer=True) diff --git a/examples/complex/tls_passthrough.py b/examples/complex/tls_passthrough.py index 6dba7ca1..9bb27d25 100644 --- a/examples/complex/tls_passthrough.py +++ b/examples/complex/tls_passthrough.py @@ -23,10 +23,10 @@ Authors: Maximilian Hils, Matthew Tuusberg import collections import random -import sys from enum import Enum import mitmproxy +from mitmproxy import ctx from mitmproxy.exceptions import TlsProtocolException from mitmproxy.proxy.protocol import TlsLayer, RawTCPLayer @@ -112,10 +112,16 @@ class TlsFeedback(TlsLayer): tls_strategy = None -def start(opts): +def load(l): + l.add_option( + "tlsstrat", int, 0, "TLS passthrough strategy (0-100)", + ) + + +def configure(updated): global tls_strategy - if len(sys.argv) == 2: - tls_strategy = ProbabilisticStrategy(float(sys.argv[1])) + if ctx.options.tlsstrat > 0: + tls_strategy = ProbabilisticStrategy(float(ctx.options.tlsstrat) / 100.0) else: tls_strategy = ConservativeStrategy() |