Created
February 11, 2021 07:14
-
-
Save bgbusted/5a2aa4f6fa4fb28ace03ffbf9a68cd59 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 ( | |
"crypto/tls" | |
"fmt" | |
"io/ioutil" | |
"net" | |
"net/http" | |
"net/http/cookiejar" | |
"net/url" | |
//also works for source backups | |
//utls "CUSTOM/uTLS" | |
utls "gitlab.com/yawning/utls.git" //also works for source backups | |
"github.com/magisterquis/connectproxy" | |
"golang.org/x/net/http2" | |
"golang.org/x/net/proxy" | |
) | |
func main() { | |
proxyString := "http://127.0.0.1:8080" | |
//proxyUrl, _ := url.Parse(proxyString) | |
proxyUrl, _ := url.Parse(proxyString) | |
cookieJar, _ := cookiejar.New(nil) | |
tr := &http2.Transport{ | |
AllowHTTP: true, | |
DialTLS: func(network, addr string, cfg *tls.Config) (net.Conn, error) { | |
// Note that hardcoding the address is not necessary here. Only | |
// do that if you want to ignore the DNS lookup that already | |
// happened behind the scenes. | |
proxyDialer, err := connectproxy.New(proxyUrl, proxy.Direct) | |
tcpConn, err := proxyDialer.Dial("tcp", addr) | |
if err != nil { | |
return nil, err | |
} | |
config := utls.Config{ServerName: "discord.com"} | |
tlsConn := utls.UClient(tcpConn, &config, utls.HelloChrome_83) | |
err = tlsConn.Handshake() | |
if err != nil { | |
return nil, fmt.Errorf("uTlsConn.Handshake() error: %w", err) | |
} | |
return tlsConn, nil | |
}, | |
} | |
client := &http.Client{ | |
Jar: cookieJar, | |
Transport: tr, | |
} | |
req, err := http.NewRequest("GET", "https://discord.com", nil) | |
if err != nil { | |
panic(err) | |
} | |
headers := http.Header{ | |
"Lol": []string{""}, | |
} | |
req.Header = headers | |
req.Header.Add("B", "") | |
req.Header.Add("A", "") | |
resp, err := client.Do(req) | |
if err != nil { | |
fmt.Println(err) | |
} else { | |
fmt.Println(resp.StatusCode) | |
body, _ := ioutil.ReadAll(resp.Body) | |
fmt.Println(string(body)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment