GithubHelp home page GithubHelp logo

lcvvvv / go-mitmproxy Goto Github PK

View Code? Open in Web Editor NEW

This project forked from lqqyt2423/go-mitmproxy

0.0 1.0 0.0 5.37 MB

mitmproxy implemented with golang. 用 Golang 实现的中间人攻击(Man-in-the-middle),解析、监测、篡改 HTTP/HTTPS 流量。

License: MIT License

JavaScript 10.32% Go 58.39% TypeScript 28.70% CSS 1.21% Makefile 0.17% HTML 1.20%

go-mitmproxy's Introduction

go-mitmproxy

简体中文

go-mitmproxy is a Golang implementation of mitmproxy that supports man-in-the-middle attacks and parsing, monitoring, and tampering with HTTP/HTTPS traffic.

Key features

  • Parses HTTP/HTTPS traffic and displays traffic details via a web interface.
  • Supports a plugin mechanism for easily extending functionality. Various event hooks can be found in the examples directory.
  • HTTPS certificate handling is compatible with mitmproxy and stored in the ~/.mitmproxy folder. If the root certificate is already trusted from a previous use of mitmproxy, go-mitmproxy can use it directly.
  • Map Remote and Map Local support.
  • HTTP/2 support.
  • Refer to the configuration documentation for more features.

Unsupported features

  • Only supports setting the proxy manually in the client, not transparent proxy mode.
  • Currently does not support WebSocket protocol parsing.

For more information on the difference between manually setting a proxy and transparent proxy mode, please refer to the mitmproxy documentation for the Python version: How mitmproxy works. go-mitmproxy currently supports "Explicit HTTP" and "Explicit HTTPS" as mentioned in the article.

Command Line Tool

Installation

go install github.com/lqqyt2423/go-mitmproxy/cmd/go-mitmproxy@latest

Usage

Use the following command to start the go-mitmproxy proxy server:

go-mitmproxy

After starting, the HTTP proxy address is set to port 9080 by default, and the web interface is set to port 9081 by default.

The certificate needs to be installed after the first startup to parse HTTPS traffic. The certificate will be automatically generated after the first startup command and stored in ~/.mitmproxy/mitmproxy-ca-cert.pem. Installation steps can be found in the Python mitmproxy documentation: About Certificates.

Additional Parameters

ou can use the following command to view more parameters of go-mitmproxy:

go-mitmproxy -h
Usage of go-mitmproxy:
  -addr string
    	proxy listen addr (default ":9080")
  -allow_hosts value
    	a list of allow hosts
  -cert_path string
    	path of generate cert files
  -debug int
    	debug mode: 1 - print debug log, 2 - show debug from
  -f string
    	Read configuration from file by passing in the file path of a JSON configuration file.
  -ignore_hosts value
    	a list of ignore hosts
  -map_local string
    	map local config filename
  -map_remote string
    	map remote config filename
  -ssl_insecure
    	not verify upstream server SSL/TLS certificates.
  -upstream string
    	upstream proxy
  -upstream_cert
    	connect to upstream server to look up certificate details (default true)
  -version
    	show go-mitmproxy version
  -web_addr string
    	web interface listen addr (default ":9081")

Importing as a package for developing functionalities

Simple Example

package main

import (
	"log"

	"github.com/lqqyt2423/go-mitmproxy/proxy"
)

func main() {
	opts := &proxy.Options{
		Addr:              ":9080",
		StreamLargeBodies: 1024 * 1024 * 5,
	}

	p, err := proxy.NewProxy(opts)
	if err != nil {
		log.Fatal(err)
	}

	log.Fatal(p.Start())
}

Adding Functionality by Developing Plugins

Refer to the examples for adding your own plugins by implementing the AddAddon method.

The following are the currently supported event nodes:

type Addon interface {
	// A client has connected to mitmproxy. Note that a connection can correspond to multiple HTTP requests.
	ClientConnected(*ClientConn)

	// A client connection has been closed (either by us or the client).
	ClientDisconnected(*ClientConn)

	// Mitmproxy has connected to a server.
	ServerConnected(*ConnContext)

	// A server connection has been closed (either by us or the server).
	ServerDisconnected(*ConnContext)

	// The TLS handshake with the server has been completed successfully.
	TlsEstablishedServer(*ConnContext)

	// HTTP request headers were successfully read. At this point, the body is empty.
	Requestheaders(*Flow)

	// The full HTTP request has been read.
	Request(*Flow)

	// HTTP response headers were successfully read. At this point, the body is empty.
	Responseheaders(*Flow)

	// The full HTTP response has been read.
	Response(*Flow)

	// Stream request body modifier
	StreamRequestModifier(*Flow, io.Reader) io.Reader

	// Stream response body modifier
	StreamResponseModifier(*Flow, io.Reader) io.Reader
}

WEB Interface

You can access the web interface at http://localhost:9081/ using a web browser.

Features

  • View detailed information of HTTP/HTTPS requests
  • Supports formatted preview of JSON requests/responses
  • Supports binary mode to view response body
  • Supports advanced filtering rules
  • Supports request breakpoint function

Screenshot Examples

Sponsor Me

If you find this project helpful, consider buying me a cup of coffee.

When sponsoring, you can add a note stating the source as "go-mitmproxy," and I will add you to the sponsorship list below.

sponsorme

Thank you to the following sponsors:

None at the moment.

License

MIT License

go-mitmproxy's People

Contributors

dna2github avatar lewage59 avatar lqqyt2423 avatar pepesi avatar t1nky avatar wangborong12345 avatar zhouyixun avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.