Mutable.ai logoAuto Wiki by Mutable.ai

mitmproxy

Auto-generated from mitmproxy/mitmproxy by Mutable.ai Auto WikiRevise

mitmproxy
GitHub Repository
Developermitmproxy
Written inPython
Stars34k
Watchers616
Created02/16/2010
Last updated04/06/2024
LicenseMIT
Homepagemitmproxy.org
Repositorymitmproxy/mitmproxy
Auto Wiki
Revision
Software Version0.0.8Basic
Generated fromCommit 1b4469
Generated at04/06/2024

mitmproxy is a powerful, open-source, interactive HTTPS proxy that allows users to intercept, inspect, and modify network traffic. It provides a comprehensive set of tools and features for web development, security testing, and network analysis.

The core functionality of mitmproxy is implemented in the mitmproxy directory, which contains over 100 files and 10 subdirectories. The most important components include:

  • The Proxy Server: The …/server.py file defines the ConnectionHandler and LiveConnectionHandler classes, which are responsible for handling client and server connections, processing events and commands, and managing the lifecycle of network flows.
  • The Protocol Layers: The …/layers directory contains the implementation of various protocol layers, such as HttpLayer, WebsocketLayer, QuicLayer, TCPLayer, UDPLayer, and DNSLayer. These layers handle the specifics of each network protocol and provide a flexible and extensible architecture for processing requests, responses, and events.
  • The Network Utilities: The …/net directory provides a collection of networking-related utilities and functionality, including modules for working with DNS, HTTP, SSL/TLS, and other network protocols and concepts.
  • The Core Types and Serialization: The …/coretypes directory contains utility classes and functions used throughout the mitmproxy codebase, such as BiDi for bi-directional mappings, MultiDict for dictionary-like data structures, and Serializable for object serialization and deserialization.

In addition to the core proxy functionality, mitmproxy also provides several user interfaces, including a Console Interface, a Web Interface, and a Command-Line Interface. These interfaces allow users to interact with the proxy, view and manipulate network traffic, and customize the behavior of the tool.

The mitmproxy project also supports a powerful Content Views system, which is responsible for formatting, decoding, and highlighting data for various protocols and data formats. This system includes built-in views for HTTP, WebSocket, QUIC, TCP, UDP, DNS, and a variety of other data formats.

Finally, mitmproxy provides an Addons and Scripting system that allows users to extend the functionality of the tool and customize its behavior. Addons can be used to intercept, modify, and analyze HTTP and WebSocket traffic, as well as handle other network protocols and events.

Core Functionality
Revise

The core functionality of the mitmproxy application is centered around the implementation of the network proxy server and the various protocol layers it supports. The key components and design choices in this area are:

Read more

Proxy Server
Revise

The core implementation of the mitmproxy network proxy is handled by the mitmproxy/mitmproxy/proxy/server.py file. This file defines several key components that work together to provide the core functionality of the proxy server:

Read more

Protocol Layers
Revise

The implementation of the various protocol layers used by the mitmproxy proxy, such as HTTP, WebSocket, QUIC, TCP, UDP, and DNS, is primarily handled in the …/layers directory.

Read more

Network Utilities
Revise

The …/net directory contains a collection of Python modules that provide various networking-related utilities and functionality for the mitmproxy project. This includes modules for working with DNS, HTTP, SSL/TLS, and other network protocols and concepts.

Read more

Core Types and Serialization
Revise

The …/coretypes directory contains several important utility classes and functions that are used throughout the mitmproxy codebase. The main components in this directory are:

Read more

Proxy Modes
Revise

The mitmproxy/mitmproxy/proxy/layers/modes.py file defines several classes that handle different proxy modes in the mitmproxy application. These classes are responsible for managing the connection between the client and the server, and for handling the various protocols and authentication methods that may be used.

Read more

Flow Management
Revise

References: mitmproxy/io

The …/io directory contains the core functionality for reading, writing, and managing HTTP flow data in the mitmproxy project. The main components are:

Read more

User Interfaces
Revise

References: mitmproxy/tools

The mitmproxy project provides several user interfaces for interacting with the proxy, including a console-based interface, a web-based interface, and a command-line interface.

Read more

Console Interface
Revise

The console-based user interface for mitmproxy is implemented in the …/console directory. This interface provides a comprehensive set of tools and features for interacting with the mitmproxy application, including:

Read more

Web Interface
Revise

The web-based user interface for mitmproxy is implemented in the …/web directory. This directory contains the main HTML template, CSS and JavaScript files for the web application, as well as the request handlers and WebSocket functionality that power the interactive features of the web UI.

Read more

Command-Line Interface
Revise

The command-line interface for mitmproxy is implemented in the …/cmdline.py file. This file defines several functions that set up the argument parsers for the different mitmproxy commands: mitmproxy, mitmdump, and mitmweb.

Read more

Content Views
Revise

The mitmproxy/mitmproxy/contentviews directory contains a collection of content views that can be used to format, decode, and highlight data in the mitmproxy tool. These content views support various protocols, such as HTTP, WebSocket, TCP, and UDP.

Read more

Content Views
Revise

The …/contentviews directory contains a collection of content views that can be used to format, decode, and highlight data in the mitmproxy tool. These content views support various protocols, such as HTTP, WebSocket, TCP, and UDP.

Read more

Content View API
Revise

The View class is the core abstraction for content views in mitmproxy. It defines the API for content views, which are responsible for formatting, decoding, and highlighting data for various protocols and data formats.

Read more

Automatic Content View Selection
Revise

The ViewAuto class is responsible for automatically selecting the most appropriate content view for the given data. It is a subclass of the base.View class.

Read more

Base Content View Implementation
Revise

The mitmproxy/mitmproxy/contentviews/base.py file defines the base functionality for content views in the mitmproxy project. Content views are responsible for transforming raw data into human-readable output.

Read more

CSS Content View
Revise

The ViewCSS class provides a custom CSS prettifier implementation in the mitmproxy project. This class is responsible for formatting and displaying CSS data within the mitmproxy user interface.

Read more

DNS Content View
Revise

The ViewDns class in the …/dns.py file is responsible for rendering DNS-over-HTTPS (DoH) traffic in the mitmproxy tool. This class inherits from the base.View class and provides a custom content view for displaying the contents of DNS messages in a user-friendly format.

Read more

GraphQL Content View
Revise

The ViewGraphQL class is responsible for handling the display of GraphQL queries and responses within the mitmproxy tool. This class is a subclass of base.View and provides specialized functionality for formatting and rendering GraphQL data.

Read more

gRPC and Protobuf Content View
Revise

The ViewGrpcProtobuf class is responsible for parsing and displaying Protocol Buffer (Protobuf) and gRPC messages in the mitmproxy application. This class inherits from the base.View class and provides a human-friendly view of Protobuf and gRPC messages.

Read more

Hexadecimal Content Views
Revise

The ViewHexDump and ViewHexStream classes in the …/hex.py file provide different views for displaying hexadecimal data in the mitmproxy application.

Read more

HTTP/3 Content View
Revise

The ViewHttp3 class is responsible for parsing and displaying HTTP/3 frames in the mitmproxy tool. It is the main entry point for processing HTTP/3 data and is implemented in the …/http3.py file.

Read more

JavaScript Content View
Revise

The ViewJavaScript class in …/javascript.py provides a custom implementation for rendering JavaScript content in the mitmproxy tool. This class is responsible for formatting and displaying JavaScript code in a more readable and user-friendly way.

Read more

JSON Content View
Revise

The ViewJSON class is responsible for parsing and formatting JSON data within the mitmproxy content viewing system. It is a subclass of the base.View class, which provides the core functionality for content viewers in mitmproxy.

Read more

MQTT Content View
Revise

The ViewMQTT class in the mitmproxy/mitmproxy/contentviews/mqtt.py file is responsible for handling the display of MQTT (Message Queuing Telemetry Transport) protocol packets within the mitmproxy tool.

Read more

MessagePack Content View
Revise

The ViewMsgPack class in the mitmproxy/mitmproxy/contentviews/msgpack.py file provides a view for rendering MessagePack data within the mitmproxy application. This class is responsible for parsing and formatting MessagePack data, allowing users to inspect and understand the contents of MessagePack-encoded messages.

Read more

Multipart Content View
Revise

The ViewMultipart class is responsible for parsing and displaying multipart form data in the mitmproxy application. This class is part of the mitmproxy/mitmproxy/contentviews/multipart.py module.

Read more

Protobuf Content View
Revise

The ViewProtobuf class provides a human-friendly view for displaying Protocol Buffer (Protobuf) data within the mitmproxy application. This class is responsible for parsing and formatting Protobuf data in a way that is easy for users to understand.

Read more

Query Parameter Content View
Revise

The ViewQuery class in the mitmproxy/mitmproxy/contentviews/query.py file is responsible for rendering the query parameters of an HTTP message. This class inherits from the base.View class and provides two main methods:

Read more

Raw Content View
Revise

The ViewRaw class provides a simple "Raw" view for displaying the raw content of a request or response in the mitmproxy tool. This class is defined in the …/raw.py file.

Read more

URL-Encoded Content View
Revise

The ViewURLEncoded class in the …/urlencoded.py file is responsible for handling the parsing and rendering of URL-encoded form data within the mitmproxy tool.

Read more

WBXML Content View
Revise

The ViewWBXML class in the …/wbxml.py file is responsible for parsing and displaying WBXML (Wireless Binary XML) content within the mitmproxy tool.

Read more

XML/HTML Content View
Revise

The ViewXmlHtml class provides a custom XML/HTML prettifier implementation in the mitmproxy project. This class is responsible for rendering the formatted XML/HTML content within the mitmproxy application.

Read more

Image Content View
Revise

The …/image directory provides functionality for parsing and displaying image data within the mitmproxy application. The main component in this directory is the ViewImage class, which is responsible for rendering and displaying image content.

Read more

Addons and Scripting
Revise

The mitmproxy project provides a powerful addon and scripting system that allows users to extend the functionality of the tool and customize its behavior. The core of this system is the …/addons directory, which contains a collection of addons that provide a wide range of features.

Read more

Addon Anatomy and Structure
Revise

The mitmproxy/examples/addons/anatomy.py file provides a basic example of a mitmproxy addon. The addon is a simple Counter class that logs the number of flows it has seen.

Read more

Handling Flows and Commands
Revise

The commands-flows.py file demonstrates how to handle HTTP flows as command arguments in mitmproxy addons. The main component is the MyAddon class, which defines a custom command called myaddon.addheader.

Read more

Handling Streaming and Trailers
Revise

The http-stream-simple.py and http-stream-modify.py addons demonstrate how to work with streaming HTTP responses in mitmproxy, while the http-trailers.py addon shows how to handle HTTP trailers.

Read more

Customizing Content Views
Revise

The ViewGrpcWithRules class in …/contentview-custom-grpc.py provides a custom version of the gRPC/protobuf content view in the mitmproxy library. This custom view allows parsing of protobuf messages based on a user-defined set of rules.

Read more

WebSocket and TCP Handling
Revise

The websocket-simple.py and websocket-inject-message.py files in the …/addons directory demonstrate how to process and manipulate WebSocket connections using the mitmproxy library.

Read more

Community-Contributed Addons
Revise

References: examples/contrib

The …/contrib directory contains a collection of community-contributed addons and examples for the mitmproxy tool. These addons provide a wide range of functionality, including:

Read more

Utilities and Helpers
Revise

References: mitmproxy/utils

The …/ directory contains a collection of utility functions and classes that provide various functionality to support the mitmproxy application. The utilities cover a wide range of tasks, including:

Read more

Argument Handling and Deprecation
Revise

The mitmproxy/mitmproxy/utils/arg_check.py file is responsible for validating and handling command-line arguments used in the mitmproxy application. It provides the following key functionality:

Read more

Asyncio Utilities
Revise

The mitmproxy/mitmproxy/utils/asyncio_utils.py file provides a set of utility functions and context managers for working with asyncio in the mitmproxy codebase.

Read more

Bit Manipulation
Revise

The setbit() and getbit() functions in the …/bits.py file provide a way to set and retrieve individual bits within a byte.

Read more

Package Data Access
Revise

The Data class, defined in …/data.py, provides a way to access package data files relative to a module's location. This is useful for accessing configuration files, assets, or other resources that are distributed alongside the mitmproxy application.

Read more

Debugging and Inspection
Revise

The mitmproxy/mitmproxy/utils/debug.py file provides a set of utility functions that can be used to debug and inspect the state of the mitmproxy application. These functions offer valuable insights into the running process, including information about threads, file descriptors, memory usage, open files, network connections, and running tasks.

Read more

Emoji and Symbol Utilities
Revise

The emoji dictionary in the …/emoji.py file provides a mapping of emoji and character names to their corresponding Unicode representations. This dictionary contains a wide range of emojis and symbols across various categories, such as:

Read more

Human-Readable Formatting
Revise

The mitmproxy/mitmproxy/utils/human.py file provides a set of utility functions for formatting data in a human-readable way. These functions handle common data types such as file sizes, durations, and timestamps, ensuring that the output is concise and easy to understand.

Read more

Magisk Module Generation
Revise

The mitmproxy/utils/magisk.py file provides the functionality for packaging the MITMProxy certificate as a Magisk module for Android devices. Magisk is a popular Android root solution that allows for system-level modifications, and this module enables users to easily install the MITMProxy certificate on their Android devices.

Read more

Signals and Event Dispatching
Revise

The mitmproxy/mitmproxy/utils/signals.py file provides a simple dispatching system for subscribing to and notifying events in the mitmproxy project. It supports both synchronous and asynchronous receivers, and uses weak references to avoid keeping receivers alive unnecessarily.

Read more

Sliding Window Iterator
Revise

The window() function in …/sliding_window.py creates a sliding window over an input iterator. This function takes an Iterable[T] and two optional integer parameters, behind and ahead, and returns an Iterator[tuple[T | None, ...]].

Read more

String and Byte Utilities
Revise

The mitmproxy/mitmproxy/utils/strutils.py file provides a set of utility functions for working with strings and bytes in the mitmproxy project. The main functionalities include:

Read more

Type Checking
Revise

The mitmproxy/mitmproxy/utils/typecheck.py file provides utility functions for type checking, specifically for handling options in the mitmproxy application.

Read more

Virtual Terminal Escape Codes
Revise

The mitmproxy/mitmproxy/utils/vt_codes.py file provides a utility function ensure_supported() that detects if a given file object supports virtual terminal escape codes. This is an important functionality for implementing terminal-specific features, such as colored output, in a cross-platform manner.

Read more

PyInstaller Configuration
Revise

The PyInstaller Configuration subsection discusses the configuration files and utility functions related to the PyInstaller tool, which is used to create standalone executable files from the mitmproxy application.

Read more

Web Application
Revise

References: web/src

The mitmproxy web application is implemented in the …/src directory, which contains the core functionality of the application, including the user interface, state management, network flow handling, and utility functions.

Read more

User Interface
Revise

The …/components directory contains the core React components that make up the user interface of the mitmproxy web application. These components handle various functionalities, such as rendering the flow table, displaying the details of a selected flow, managing the application header and footer, and providing a command-line interface.

Read more

State Management
Revise

References: web/src/js/ducks

The Redux-based state management system used in the mitmproxy web application covers the management of user interface state, network flows, options, backend connection, and event logging.

Read more

Network Flow Handling
Revise

The WebsocketBackend class in the …/websocket.tsx file is responsible for managing the WebSocket connection to the server and updating the application's state based on the data received through the WebSocket. It fetches initial data from the REST API and then listens for updates from the WebSocket connection, dispatching actions to the Redux store to update the application state accordingly.

Read more

Utilities and Helpers
Revise

References: web/src/js/contrib

The …/contrib directory contains two important files that provide utility functions and helper components used throughout the mitmproxy web application:

Read more