main
boya 7 years ago
parent af79be2183
commit 5e163aad16
  1. 5
      build.sh
  2. 0
      doc/goproxy.png
  3. 0
      doc/proxy.png
  4. 20
      gomitmproxy-ca-cert.pem
  5. 7
      src/main/main.go
  6. 5
      src/vendor/mitm/gomitmproxy.go
  7. 3
      src/vendor/mitm/mitm.go

@ -1,2 +1,5 @@
os=$1
arch=$2
export GOPATH=`pwd` export GOPATH=`pwd`
go build -o bin/gomitmproxy src/main/*.go GOOS=$os GOARCH=$arch go build -o bin/gomitmproxy$os$arch src/main/*.go

Before

Width:  |  Height:  |  Size: 1.5 MiB

After

Width:  |  Height:  |  Size: 1.5 MiB

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

@ -1,8 +1,8 @@
-----BEGIN CERTIFICATE----- -----BEGIN CERTIFICATE-----
MIIDIjCCAgqgAwIBAgIIFFyG4pw+r+kwDQYJKoZIhvcNAQELBQAwLzEXMBUGA1UE MIIDIjCCAgqgAwIBAgIIFNKdPYoAW+YwDQYJKoZIhvcNAQELBQAwLzEXMBUGA1UE
ChMOZ29taXRtcHJveHkxLjAxFDASBgNVBAMTC2dvbWl0bXByb3h5MB4XDTE2MDUy ChMOZ29taXRtcHJveHkxLjExFDASBgNVBAMTC2dvbWl0bXByb3h5MB4XDTE3MDYx
OTEwMjQ0NloXDTE3MDYyOTEwMjQ0NlowLzEXMBUGA1UEChMOZ29taXRtcHJveHkx OTAzMjE1M1oXDTE4MDcxOTAzMjE1M1owLzEXMBUGA1UEChMOZ29taXRtcHJveHkx
LjAxFDASBgNVBAMTC2dvbWl0bXByb3h5MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A LjExFDASBgNVBAMTC2dvbWl0bXByb3h5MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A
MIIBCgKCAQEA5i5e0Ioniij/zx4uP+pEwIfCPuqRHpmtxnylXtDJNS7Mibsl57cC MIIBCgKCAQEA5i5e0Ioniij/zx4uP+pEwIfCPuqRH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ntQzpOW U8sAyjiJP/fnAcPI5TxCc/wc+VexMZC445ojldukQKxoxbLrpzmUuvgnAw/tfVir
Gl9ydNYWbd0ad5k+kQhBp2nsq1NByg3fwEd1jgvSnxKB+P76OK01pSxRczLpCp0F y4THt50xnhCLl86cH9mJVtv18GxtJDQZBgnuUT7P9DdcfHSu1mN9wCEYwS1+/zPj
+1gpD6ukiPIC1RZCUiHk4UeY8jmpBNgNW4OJmxgA+LFclB3hytkxN2qbnk5xfA33 MBgDAugKzD273sePhPwl+j+PXpa+RyaUgYyj3MRmJMN/XXeqFEz4Z1tx3KXzQWac
1JciXh8y0ZD1wXB7y14PAB1TB53Rgjvk38OrPpBf3nETxlqP5zQ= gbbKrmA6TDPXZh0jeM5WU5vWJIP4NDNMSjg9qZrkiCPP3Dbntts=
-----END CERTIFICATE----- -----END CERTIFICATE-----

@ -20,22 +20,25 @@ func main() {
conf.Log = flag.String("logFile", "", "log file path") conf.Log = flag.String("logFile", "", "log file path")
conf.Monitor = flag.Bool("m", false, "monitor mode") conf.Monitor = flag.Bool("m", false, "monitor mode")
conf.Tls = flag.Bool("tls", false, "tls connect") conf.Tls = flag.Bool("tls", false, "tls connect")
flag.Parse() flag.Parse()
// init log // init log
if *conf.Log != "" { if *conf.Log != "" {
log, err = os.Create(*conf.Log) log, err = os.Create(*conf.Log)
if err != nil { if err != nil {
mylog.Fatalln("fail to create log file!") mylog.Fatalln("fail to create log file " + err.Error())
} }
} else { } else {
log = os.Stderr log = os.Stderr
} }
mylog.SetLog(log) mylog.SetLog(log)
// init tls config
tlsConfig := config.NewTlsConfig("gomitmproxy-ca-pk.pem", "gomitmproxy-ca-cert.pem", "", "")
// start mitm proxy // start mitm proxy
wg := new(sync.WaitGroup) wg := new(sync.WaitGroup)
wg.Add(1) wg.Add(1)
mitm.Gomitmproxy(conf, wg) mitm.Gomitmproxy(conf, tlsConfig, wg)
wg.Wait() wg.Wait()
} }

@ -11,9 +11,7 @@ import (
"time" "time"
) )
func Gomitmproxy(conf *config.Cfg, wg *sync.WaitGroup) { func Gomitmproxy(conf *config.Cfg, tlsConfig *config.TlsConfig, wg *sync.WaitGroup) {
tlsConfig := config.NewTlsConfig("gomitmproxy-ca-pk.pem", "gomitmproxy-ca-cert.pem", "", "")
handler, err := InitConfig(conf, tlsConfig) handler, err := InitConfig(conf, tlsConfig)
if err != nil { if err != nil {
mylog.Fatalf("InitConfig error: %s", err) mylog.Fatalf("InitConfig error: %s", err)
@ -40,7 +38,6 @@ func Gomitmproxy(conf *config.Cfg, wg *sync.WaitGroup) {
} }
wg.Done() wg.Done()
mylog.Printf("Gomitmproxy Stop!!!!") mylog.Printf("Gomitmproxy Stop!!!!")
}() }()

@ -139,13 +139,11 @@ func (hw *HandlerWrapper) DumpHTTPAndHTTPs(resp http.ResponseWriter, req *http.R
connOut, err := net.DialTimeout("tcp", host, time.Second*30) connOut, err := net.DialTimeout("tcp", host, time.Second*30)
if err != nil { if err != nil {
mylog.Println("dial to", host, "error:", err) mylog.Println("dial to", host, "error:", err)
return return
} }
if err = req.Write(connOut); err != nil { if err = req.Write(connOut); err != nil {
mylog.Println("send to server error", err) mylog.Println("send to server error", err)
return return
} }
@ -204,7 +202,6 @@ func (hw *HandlerWrapper) DumpHTTPAndHTTPs(resp http.ResponseWriter, req *http.R
} }
func (hw *HandlerWrapper) ServeHTTP(resp http.ResponseWriter, req *http.Request) { func (hw *HandlerWrapper) ServeHTTP(resp http.ResponseWriter, req *http.Request) {
raddr := *hw.MyConfig.Raddr raddr := *hw.MyConfig.Raddr
if len(raddr) != 0 { if len(raddr) != 0 {
hw.Forward(resp, req, raddr) hw.Forward(resp, req, raddr)

Loading…
Cancel
Save