diff --git a/u_360_profile_test.go b/u_360_profile_test.go new file mode 100644 index 0000000000..2cdc12625d --- /dev/null +++ b/u_360_profile_test.go @@ -0,0 +1,32 @@ +package tls + +import ( + "net" + "reflect" + "testing" +) + +func Test360Chrome23ClientHello(t *testing.T) { + conn := UClient(&net.TCPConn{}, &Config{ServerName: "example.com"}, Hello360_Auto) + if err := conn.BuildHandshakeState(); err != nil { + t.Fatal(err) + } + hello := conn.HandshakeState.Hello + shares := hello.KeyShares + if len(shares) != 3 || !isGREASEUint16(uint16(shares[0].Group)) || + shares[1].Group != X25519MLKEM768 || len(shares[1].Data) != 1216 || + shares[2].Group != X25519 || len(shares[2].Data) != 32 { + t.Fatal("unexpected key shares") + } + wantVersions := []uint16{VersionTLS13, VersionTLS12, VersionTLS11, VersionTLS10} + if len(hello.SupportedVersions) != len(wantVersions)+1 || + !isGREASEUint16(hello.SupportedVersions[0]) || !reflect.DeepEqual(hello.SupportedVersions[1:], wantVersions) { + t.Fatalf("unexpected supported versions: %x", hello.SupportedVersions) + } + for _, ext := range conn.Extensions { + if alps, ok := ext.(*ApplicationSettingsExtension); ok && reflect.DeepEqual(alps.SupportedProtocols, []string{"h2"}) { + return + } + } + t.Fatal("missing old ALPS codepoint for h2") +} diff --git a/u_common.go b/u_common.go index 770507c6a1..1e0b6d1b1a 100644 --- a/u_common.go +++ b/u_common.go @@ -662,9 +662,10 @@ var ( HelloSafari_16_0 = ClientHelloID{helloSafari, "16.0", nil, nil} HelloSafari_26_3 = ClientHelloID{helloSafari, "26.3", nil, nil} - Hello360_Auto = Hello360_7_5 // Hello360_11_0 seems to be incompatible with this library + Hello360_Auto = Hello360_23_0 Hello360_7_5 = ClientHelloID{hello360, "7.5", nil, nil} Hello360_11_0 = ClientHelloID{hello360, "11.0", nil, nil} + Hello360_23_0 = ClientHelloID{hello360, "23.0", nil, nil} HelloQQ_Auto = HelloQQ_11_1 HelloQQ_11_1 = ClientHelloID{helloQQ, "11.1", nil, nil} diff --git a/u_parrots.go b/u_parrots.go index 425ab6ddda..68f1042b40 100644 --- a/u_parrots.go +++ b/u_parrots.go @@ -2349,6 +2349,20 @@ func utlsIdToSpec(id ClientHelloID) (ClientHelloSpec, error) { &UtlsGREASEExtension{}, }, }, nil + case Hello360_23_0: + spec, err := utlsIdToSpec(HelloChrome_133) + if err != nil { + return ClientHelloSpec{}, err + } + for i, ext := range spec.Extensions { + switch e := ext.(type) { + case *ApplicationSettingsExtensionNew: + spec.Extensions[i] = &ApplicationSettingsExtension{SupportedProtocols: e.SupportedProtocols} + case *SupportedVersionsExtension: + e.Versions = append(e.Versions, VersionTLS11, VersionTLS10) + } + } + return spec, nil case Hello360_7_5: return ClientHelloSpec{ CipherSuites: []uint16{