Last active
August 29, 2015 14:07
-
-
Save mjg123/e51551c65dad6cea7c70 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"github.com/elazarl/goproxy" | |
"io/ioutil" | |
"log" | |
"net/http" | |
) | |
func main() { | |
proxy := goproxy.NewProxyHttpServer() | |
proxy.OnRequest().HandleConnect(goproxy.AlwaysMitm) | |
proxy.OnRequest(goproxy.DstHostIs("review.openstack.org:443")).DoFunc( | |
func(r *http.Request, ctx *goproxy.ProxyCtx) (*http.Request, *http.Response) { | |
log.Println(r.URL.Path) | |
if r.URL.Path == "/projects/openstack-infra/config/config" { // workaround for | |
r.URL.Path = "/projects/openstack-infra%2Fconfig/config" // https://github.com/elazarl/goproxy/issues/61 | |
} | |
if r.URL.Path == "/static/hideci.js" { | |
log.Println("Hijacked!") | |
hideci, _ := ioutil.ReadFile("/home/mjg/hideci.js") // Change as appropriate | |
return r, goproxy.NewResponse(r, | |
goproxy.ContentTypeText, http.StatusOK, | |
string(hideci)) | |
} | |
return r, nil | |
}) | |
log.Fatal(http.ListenAndServe(":8080", proxy)) | |
} |
Author
mjg123
commented
Oct 2, 2014
- run this with "go run main.go"
- point browser's http proxy setting to localhost:8080
- accept warnings about certificates (you are MITM-ing yourself, after all)
Also have to run go get github.com/elazarl/goproxy
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment