mitm

package module
v0.0.0-...-9f6f65b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 15, 2019 License: MIT Imports: 15 Imported by: 0

README

mitm - mitm is a SSL-capable man-in-the-middle proxy for use with golang net/http.

It is heavily inspired by the mitmproxy project (https://mitmproxy.org/).

Install

go get github.com/maaydin/mitm

Docs

http://godoc.org/github.com/maaydin/mitm

Create CA Root Cert

mkdir ~/.mitm
cd ~/.mitm
case `uname -s` in                                                                                                            
    Linux*)     sslConfig=/etc/ssl/openssl.cnf;;
    Darwin*)    sslConfig=/System/Library/OpenSSL/openssl.cnf;;
esac

openssl ecparam -genkey -name prime256v1 -noout -out ca-key.pem

openssl req \
    -new \
    -x509 \
    -key ca-key.pem \
    -new \
    -out ca-cert.pem \
    -subj /CN=$HOST \
    -reqexts SAN \
    -extensions SAN \
    -extensions v3_ca \
    -config <(cat $sslConfig \
        <(printf '[SAN]\nsubjectAltName=DNS:localhost\n\n[v3_ca]\nbasicConstraints = critical,CA:TRUE\nsubjectKeyIdentifier=hash\nauthorityKeyIdentifier=keyid:always,issuer:always')) \
    -sha256 \
    -days 3650

Contributors

  • Keith Rarick (@kr)
  • Blake Mizerany (@bmizerany)
  • Mehmet Ali Aydin (@maaydin)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Proxy

type Proxy struct {
	Analyze func(RequestStat)
	// CA specifies the root CA for generating leaf certs for each incoming
	// TLS request.
	CA *tls.Certificate

	// TLSServerConfig specifies the tls.Config to use when generating leaf
	// cert using CA.
	TLSServerConfig *tls.Config

	// TLSClientConfig specifies the tls.Config to use when establishing
	// an upstream connection for proxying.
	TLSClientConfig *tls.Config

	// FlushInterval specifies the flush interval
	// to flush to the client while copying the
	// response body.
	// If zero, no periodic flushing is done.
	FlushInterval time.Duration
}

Proxy is a forward proxy that substitutes its own certificate for incoming TLS connections in place of the upstream server's certificate.

func (*Proxy) ServeHTTP

func (p *Proxy) ServeHTTP(w http.ResponseWriter, r *http.Request)

type RequestStat

type RequestStat struct {
	Method      string
	Scheme      string
	Host        string
	Path        string
	StatusCode  int
	StartTime   time.Time
	EndTime     time.Time
	ElapsedTime int64
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL