utls
utls copied to clipboard
Applypreset is doing something wrong during Handshake, which leads the request getting blocked from anti bots!
package cipher
import (
"bufio"
"github.com/refraction-networking/utls"
"net"
"net/http"
)
func get(addr string) (*http.Response, error) {
req, err := http.NewRequest("GET", addr, nil)
if err != nil {
return nil, err
}
dial, err := net.Dial("tcp", req.URL.Host + ":" + req.URL.Scheme)
if err != nil {
return nil, err
}
cfg := tls.Config{ServerName: req.URL.Host}
client := tls.UClient(dial, &cfg, tls.HelloCustom)
spec := tls.ClientHelloSpec{
CipherSuites: []uint16{
0x1302, // TLS_AES_256_GCM_SHA384
0xC02C ,// TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384
},
Extensions: []tls.TLSExtension{
&tls.SupportedCurvesExtension{
[]tls.CurveID{tls.X25519},
},
&tls.SupportedPointsExtension{
SupportedPoints: []byte{0},
},
},
}
client.ApplyPreset(&spec) <--- Error is here
client.Handshake() <--- Error is here too
req.Write(client)
return http.ReadResponse(bufio.NewReader(client), req)
}
Wireshark:

Error 403 Blocks my request, because of certificate i dont know :/
What is should look like

This Code is working fine, Handshake and everything is fine!!!
func get(addr string) (*http.Response, error) {
req, err := http.NewRequest("GET", addr, nil)
if err != nil {
return nil, err
}
dial, err := net.Dial("tcp", req.URL.Host + ":" + req.URL.Scheme)
if err != nil {
return nil, err
}
cfg := tls.Config{ServerName: req.URL.Host} // Here i can change random chipersuites and there is no error
client := tls.UClient(dial, &cfg, tls.HelloChrome)
req.Write(client)
return http.ReadResponse(bufio.NewReader(client), req)
}