• No results found

Proxy Server

In document mitmproxy docs Release 0.18 (Page 125-133)

class mitmproxy.proxy.ProxyServer(config) class mitmproxy.proxy.DummyServer(config)

class mitmproxy.proxy.ProxyConfig(host=’‘, port=8080, cadir=’~/.mitmproxy’, clientcerts=None, no_upstream_cert=False, body_size_limit=None, mode=’regular’, upstream_server=None, up- stream_auth=None, authenticator=None, ig- nore_hosts=(), tcp_hosts=(), http2=True, rawtcp=False, ciphers_client=’ECDHE-RSA-AES128-GCM- SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE- RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256- GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE- DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE- RSA-AES128-SHA256:ECDHE-ECDSA-AES128- SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA- AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE- ECDSA-AES256-SHA384:ECDHE-RSA-AES256- SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128- SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128- SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256- SHA:DHE-RSA-AES256-SHA:ECDHE-RSA-DES-CBC3- SHA:ECDHE-ECDSA-DES-CBC3-SHA:AES128-GCM- SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256- SHA256:AES128-SHA:AES256-SHA:AES:DES-CBC3- SHA:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH- DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3- SHA:!KRB5-DES-CBC3-SHA’, ciphers_server=None, certs=(), ssl_version_client=’secure’, ssl_version_server=’secure’, ssl_verify_upstream_cert=False, ssl_verify_upstream_trusted_cadir=None, ssl_verify_upstream_trusted_ca=None, add_upstream_certs_to_client_chain=False) class mitmproxy.proxy.RootContext(client_conn, config, channel)

The outermost context provided to the root layer. As a consequence, every layer has access to methods and attributes defined here.

client_conn

Theclient connection.

channel

A Channel to communicate with the FlowMaster. Provides .ask() and .tell() methods.

config

Theproxy server’s configuration

next_layer(top_layer)

This function determines the next layer in the protocol stack. Parameters top_layer – the current innermost layer. Returns The next layer

log(msg, level, subs=())

Send a log message to the master.

CHAPTER

42

Exceptions

We try to be very hygienic regarding the exceptions we throw: Every Exception mitmproxy raises shall be a subclass of ProxyException.

See also:http://lucumr.pocoo.org/2014/10/16/on-error-handling/

exception mitmproxy.exceptions.ProxyException(message=None) Bases: exceptions.Exception

Base class for all exceptions thrown by mitmproxy.

exception mitmproxy.exceptions.Kill(message=None) Bases:mitmproxy.exceptions.ProxyException

Signal that both client and server connection(s) should be killed immediately. exception mitmproxy.exceptions.ProtocolException(message=None)

Bases:mitmproxy.exceptions.ProxyException

exception mitmproxy.exceptions.TlsProtocolException(message=None) Bases:mitmproxy.exceptions.ProtocolException

exception mitmproxy.exceptions.ClientHandshakeException(message, server) Bases:mitmproxy.exceptions.TlsProtocolException exception mitmproxy.exceptions.Socks5ProtocolException(message=None) Bases:mitmproxy.exceptions.ProtocolException exception mitmproxy.exceptions.HttpProtocolException(message=None) Bases:mitmproxy.exceptions.ProtocolException exception mitmproxy.exceptions.Http2ProtocolException(message=None) Bases:mitmproxy.exceptions.ProtocolException exception mitmproxy.exceptions.ServerException(message=None) Bases:mitmproxy.exceptions.ProxyException exception mitmproxy.exceptions.ContentViewException(message=None) Bases:mitmproxy.exceptions.ProxyException exception mitmproxy.exceptions.ReplayException(message=None) Bases:mitmproxy.exceptions.ProxyException exception mitmproxy.exceptions.ScriptException(message=None) Bases:mitmproxy.exceptions.ProxyException classmethod from_exception_context(cut_tb=1) Must be called while the current stack handles an exception.

Parameters cut_tb – remove N frames from the stack trace to hide internal calls. exception mitmproxy.exceptions.FlowReadException(message=None) Bases:mitmproxy.exceptions.ProxyException exception mitmproxy.exceptions.ControlException(message=None) Bases:mitmproxy.exceptions.ProxyException 124 Chapter 42. Exceptions

Python Module Index

e

mitmproxy.exceptions,123

m

mitmproxy.models,77

n

netlib.http,78 netlib.multidict,81

p

mitmproxy.protocol,119 mitmproxy.proxy,121 125

Index

Symbols

__call__() (mitmproxy.protocol.Layer method),120 __getattr__() (mitmproxy.protocol.Layer method),120 __init__() (mitmproxy.protocol.Layer method),119 __init__() (netlib.http.Headers method),81

A

add() (netlib.multidict.MultiDictView method),82 add_contentview() (mitmproxy.script.ScriptContext

method),74

address (netlib.multidict.ClientConnection attribute),83 address (netlib.multidict.ServerConnection attribute),82 anticache() (netlib.http.Request method),79

anticomp() (netlib.http.Request method),79

app_registry (mitmproxy.script.ScriptContext attribute), 74

C

cert (netlib.multidict.ServerConnection attribute),83 channel (mitmproxy.proxy.RootContext attribute),121 client_conn (mitmproxy.models.HTTPFlow attribute),77 client_conn (mitmproxy.proxy.RootContext attribute),

121

clientcert (netlib.multidict.ClientConnection attribute),83 clientconnect() (built-in function),72

ClientConnection (class in mitmproxy.models),83 clientdisconnect() (built-in function),72

ClientHandshakeException,123

config (mitmproxy.proxy.RootContext attribute),122 connect() (mitmproxy.protocol.ServerConnectionMixin

method),120

constrain_encoding() (netlib.http.Request method),79 content (netlib.http.Request attribute),78

content (netlib.http.Response attribute),80 ContentViewException,123

ControlException,124

cookies (netlib.http.Request attribute),79 cookies (netlib.http.Response attribute),80 ctx (mitmproxy.protocol.Layer attribute),120

D

decoded (class in netlib.http),81

disconnect() (mitmproxy.protocol.ServerConnectionMixin method),120

done() (built-in function),72

DummyServer (class in mitmproxy.proxy),121

duplicate_flow() (mitmproxy.script.ScriptContext method),74

E

environment variable MITMPROXY_SSLKEYLOGFILE,117 SSLKEYLOGFILE,117

Error (class in mitmproxy.models),82

error (mitmproxy.models.HTTPFlow attribute),77 error() (built-in function),73

F

first_line_format (netlib.http.Request attribute),78 FlowReadException,124

from_exception_context() (mitm- proxy.exceptions.ScriptException class method),123

G

get_all() (netlib.http.Headers method),81

get_all() (netlib.multidict.MultiDictView method),81

H

Headers (class in netlib.http),80

headers (netlib.http.Request attribute),78 headers (netlib.http.Response attribute),80 host (netlib.http.Request attribute),78 Http2ProtocolException,123

http_version (netlib.http.Request attribute),78 http_version (netlib.http.Response attribute),79 HTTPFlow (class in mitmproxy.models),77 HttpProtocolException,123

HTTPRequest (class in mitmproxy.models),77 HTTPResponse (class in mitmproxy.models),78

I

insert() (netlib.multidict.MultiDictView method),82 intercepted (mitmproxy.models.HTTPFlow attribute),77 ip_address (netlib.multidict.ServerConnection attribute),

83

items() (netlib.multidict.MultiDictView method),82

K

keys() (netlib.multidict.MultiDictView method),82 Kill,123

kill_flow() (mitmproxy.script.ScriptContext method),74

L

Layer (class in mitmproxy.protocol),119 layers (mitmproxy.protocol.Layer attribute),120 live (mitmproxy.models.HTTPFlow attribute),77 log() (mitmproxy.proxy.RootContext method),122 log() (mitmproxy.script.ScriptContext method),74

M

match() (mitmproxy.models.HTTPFlow method),77 method (netlib.http.Request attribute),78

mitmproxy.exceptions (module),123 mitmproxy.models (module),77 mitmproxy.protocol (module),119 mitmproxy.proxy (module),121

MITMPROXY_SSLKEYLOGFILE,117 MultiDictView (class in netlib.multidict),81 multipart_form (netlib.http.Request attribute),79

N

netlib.http (module),78 netlib.multidict (module),81

next_layer() (mitmproxy.proxy.RootContext method), 122

P

path (netlib.http.Request attribute),78

path_components (netlib.http.Request attribute),79 port (netlib.http.Request attribute),78

pretty_host (netlib.http.Request attribute),79 pretty_url (netlib.http.Request attribute),79 ProtocolException,123

ProxyConfig (class in mitmproxy.proxy),121 ProxyException,123

ProxyServer (class in mitmproxy.proxy),121

Q

query (netlib.http.Request attribute),79

R

reason (netlib.http.Response attribute),80

remove_contentview() (mitmproxy.script.ScriptContext method),74

replace() (mitmproxy.models.HTTPFlow method),77 replace() (netlib.http.Headers method),81

replay_request() (mitmproxy.script.ScriptContext method),74

ReplayException,123

Request (class in netlib.http),78

request (mitmproxy.models.HTTPFlow attribute),77 request() (built-in function),72

Response (class in netlib.http),79

response (mitmproxy.models.HTTPFlow attribute),77 response() (built-in function),72

responseheaders() (built-in function),72 RootContext (class in mitmproxy.proxy),121

S

scheme (netlib.http.Request attribute),78 ScriptContext (class in mitmproxy.script),74 ScriptException,123

server_conn (mitmproxy.models.HTTPFlow attribute),77 serverconnect() (built-in function),72

ServerConnection (class in mitmproxy.models),82 ServerConnectionMixin (class in mitmproxy.protocol),

120

serverdisconnect() (built-in function),72 ServerException,123

set_all() (netlib.http.Headers method),81

set_all() (netlib.multidict.MultiDictView method),82 set_server() (mitmproxy.protocol.ServerConnectionMixin

method),120

sni (netlib.multidict.ServerConnection attribute),83 Socks5ProtocolException,123

source_address (netlib.multidict.ServerConnection attribute),83

ssl_established (netlib.multidict.ClientConnection at- tribute),83

ssl_established (netlib.multidict.ServerConnection attribute),83

SSLKEYLOGFILE,117 start() (built-in function),71

status_code (netlib.http.Response attribute),79

T

tcp_message() (built-in function),73 text (netlib.http.Request attribute),79 text (netlib.http.Response attribute),80

timestamp_end (netlib.http.Request attribute),78 timestamp_end (netlib.http.Response attribute),80 timestamp_end (netlib.multidict.ClientConnection

attribute),83

timestamp_end (netlib.multidict.ServerConnection attribute),83

mitmproxy docs, Release 0.18

timestamp_ssl_setup (netlib.multidict.ClientConnection attribute),83

timestamp_ssl_setup (netlib.multidict.ServerConnection attribute),83

timestamp_start (netlib.http.Request attribute),78 timestamp_start (netlib.http.Response attribute),80 timestamp_start (netlib.multidict.ClientConnection

attribute),83

timestamp_start (netlib.multidict.ServerConnection at- tribute),83

timestamp_tcp_setup (netlib.multidict.ServerConnection attribute),83

TlsProtocolException,123

to_dict() (netlib.multidict.MultiDictView method),82

U

url (netlib.http.Request attribute),79

urlencoded_form (netlib.http.Request attribute),79

V

values() (netlib.multidict.MultiDictView method),82 via (netlib.multidict.ServerConnection attribute),83

W

wrap() (mitmproxy.models.HTTPRequest class method), 77

wrap() (mitmproxy.models.HTTPResponse class method),78

In document mitmproxy docs Release 0.18 (Page 125-133)

Related documents