Skip to content

Commit

Permalink
documentation: hijack https connection
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivo Bellin Salarin authored and Ivo Bellin Salarin committed Jun 2, 2016
1 parent b485c0b commit ba35961
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion gssapi-proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,36 @@ func main() {
}
os.Exit(0)
}


proxy := goproxy.NewProxyHttpServer()

/*
hijack connect: intercept the request, add the Proxy-Authorization header then send it to the remote host
proxy.OnRequest().HijackConnect(func(req *http.Request, client net.Conn, ctx *goproxy.ProxyCtx) {
defer func() {
if e := recover(); e != nil {
ctx.Logf("error connecting to remote: %v", e)
client.Write([]byte("HTTP/1.1 500 Cannot reach destination\r\n\r\n"))
}
client.Close()
}()
clientBuf := bufio.NewReadWriter(bufio.NewReader(client), bufio.NewWriter(client))
remote, err := net.Dial("tcp", req.URL.Host)
orPanic(err)
remoteBuf := bufio.NewReadWriter(bufio.NewReader(remote), bufio.NewWriter(remote))
for {
req, err := http.ReadRequest(clientBuf.Reader)
orPanic(err)
orPanic(req.Write(remoteBuf))
orPanic(remoteBuf.Flush())
resp, err := http.ReadResponse(remoteBuf.Reader, req)
orPanic(err)
orPanic(resp.Write(clientBuf.Writer))
orPanic(clientBuf.Flush())
}
})
*/

// behave as a MITM
// the client fails with a TrustFailure (Le certificat distant n'est pas valide selon la procédure de validation.)
// probably because the client expects an SSL Hello, but it receives a plain HTTP response
Expand Down

0 comments on commit ba35961

Please sign in to comment.