mitmproxy

package module
v0.0.0-...-a103014 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2020 License: MIT Imports: 19 Imported by: 0

README

mitmProxy

SSL-capable man-in-the-middle proxy written on Golang

First, you should create folder for certificates (/app/certificates) Then you should call StartProxyServer func in order to listen for all requests.

Documentation

StartProxyServer

Type: function Signature:

func StartProxyServer(address string, proxyRequestHandler func(*ProxyRequest)) error
  • Address is listen address, e.g.: ":8090", "0.0.0.0:8011"
  • proxyRequestHandler is handler for all incoming connections, ProxyRequest structure is passed
ProxyRequest

Type: struct

Signature:

type ProxyRequest struct {
	IsSSL          bool
	ClientRequest  *http.Request
	ServerResponse *http.Response

	clientConn, serverConn io.ReadWriter
}
func (pr *ProxyRequest) SendRequest() error
func (pr *ProxyRequest) SendResponse() error

Fields:

  • IsSSL is set when incoming connection is http CONNECT request
  • ClientRequest is request sent by proxy client
  • SendRequest establishes connection to the remote server and sends client's request
  • ServerResponse is remote server's response
  • SendResponse sends ProxyRequest.ServerResponse to the client.

Example

package main

import (
	"fmt"

	"mitmProxy"
)

func main() {
	mitmproxy.StartProxyServer(":4444", func(req *mitmproxy.ProxyRequest) {
		fmt.Println(req.ClientRequest)
		req.SendRequest()
		fmt.Println(req.ServerResponse)
		req.SendResponse()
	})
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CertPath = "./certificates/"

CertPath is path where all created certificates will be stored. Should be an existing directory

Functions

func GenCert

func GenCert(names []string) (*tls.Certificate, error)

GenCert creates new certifice for host signed using specified CA certificate

func GenerateCA

func GenerateCA(CN string)

GenerateCA generates CA cert with defined CN

func StartProxyServer

func StartProxyServer(address string, proxyRequestHandler func(*ProxyRequest)) (chan bool, error)

StartProxyServer listens for all the connections to the proxy server and handles requests. Address is listen address, e.g.: ":8090", "0.0.0.0:8011"

Types

type ProxyRequest

type ProxyRequest struct {
	IsSSL          bool
	ClientRequest  *http.Request
	ServerResponse *http.Response
	// contains filtered or unexported fields
}

ProxyRequest is request sent by client to the proxy server ProxyRequest provides functions for mitm attack, e.g. modifying client requests and changing server responses

func (*ProxyRequest) SendRequest

func (pr *ProxyRequest) SendRequest() error

SendRequest sends request to the server and reads corresponding response

func (*ProxyRequest) SendResponse

func (pr *ProxyRequest) SendResponse() error

SendResponse sends modified response to the client

Jump to

Keyboard shortcuts

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