2

Using the following snippet I'm easily able to do HTTP(S) requests which are routed through the proxy (Burp Suite) which I'm using.

proxyURL, _ := url.Parse("http://127.0.0.1:8080")
caCert, _ := ioutil.ReadFile(/path/to/proxycert)
caCertPool, _ := x509.SystemCertPool()
caCertPool.AppendCertsFromPEM(caCert)
tlsConfig := &tls.Config{RootCAs: caCertPool}
tr := &http.Transport{
    Proxy:           http.ProxyURL(proxyURL),
    TLSClientConfig: tlsConfig}
http.DefaultTransport = tr

[...]

req, _ == http.NewRequest("GET", address, nil)
resp _ := http.DefaultClient.Do(req)

Using the following snippet I'm also able to send raw tcp streams and receive the first line of the response

//http
dialer := net.Dialer{Timeout: 15 * time.Second}
conn, _ := dialer.Dial("tcp", address)
defer conn.Close()
fmt.Fprint(conn, "GET / HTTP etc...")
resp, _ = bufio.NewReader(conn).ReadString('\n')
fmt.Print(resp)

//https
connS, _ := tls.Dial("tcp", address, tlsConfig)
defer connS.Close()
fmt.Fprint(connS, "GET / HTTP etc...")
resp, _ = bufio.NewReader(conn).ReadString('\n')
fmt.Print(resp)

I now need to route this TCP stream through the before mentioned proxy. I tried a lot with proxy.FromURL but had no success yet.

dialerP, _ := proxy.FromURL("http://127.0.0.1:8080", proxy.Direct)
conn, _ := dialerP.Dial("tcp", address)
Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
LowkeyFlex
  • 21
  • 1
  • I think it's related to your question. https://stackoverflow.com/a/25098209/12754798 – Baruch Jul 13 '21 at 14:55
  • @Baruch I don't see anything useful there. I want to build a client which sends the requests through an already existing proxy. The linked question is about how to build a proxy. – LowkeyFlex Jul 15 '21 at 08:42

0 Answers0