Skip to content

Commit

Permalink
fixed safari ios17 profile and added safari ios18;
Browse files Browse the repository at this point in the history
  • Loading branch information
bogdanfinn committed Aug 21, 2024
1 parent 0e2706b commit 0fb80a4
Show file tree
Hide file tree
Showing 5 changed files with 239 additions and 3 deletions.
3 changes: 3 additions & 0 deletions mapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ var H2SettingsMap = map[string]http2.SettingID{
"INITIAL_WINDOW_SIZE": http2.SettingInitialWindowSize,
"MAX_FRAME_SIZE": http2.SettingMaxFrameSize,
"MAX_HEADER_LIST_SIZE": http2.SettingMaxHeaderListSize,
"UNKNOWN_SETTING_7": 0x7,
"UNKNOWN_SETTING_8": 0x8,
"UNKNOWN_SETTING_9": 0x9,
}

var tlsVersions = map[string]uint16{
Expand Down
199 changes: 198 additions & 1 deletion profiles/internal_browser_profiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,93 @@ var Safari_Ipad_15_6 = ClientProfile{
}

var Safari_IOS_17_0 = ClientProfile{
clientHelloId: tls.HelloIOS_16_0,
clientHelloId: tls.ClientHelloID{
Client: "iOS",
RandomExtensionOrder: false,
Version: "17.0",
Seed: nil,
SpecFactory: func() (tls.ClientHelloSpec, error) {
return tls.ClientHelloSpec{
CipherSuites: []uint16{
tls.GREASE_PLACEHOLDER,
tls.TLS_AES_128_GCM_SHA256,
tls.TLS_AES_256_GCM_SHA384,
tls.TLS_CHACHA20_POLY1305_SHA256,
tls.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,
tls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
tls.TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256,
tls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,
tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
tls.TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256,
tls.TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA,
tls.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA,
tls.TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA,
tls.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,
tls.TLS_RSA_WITH_AES_256_GCM_SHA384,
tls.TLS_RSA_WITH_AES_128_GCM_SHA256,
tls.TLS_RSA_WITH_AES_256_CBC_SHA,
tls.TLS_RSA_WITH_AES_128_CBC_SHA,
tls.TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA,
tls.TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA,
tls.TLS_RSA_WITH_3DES_EDE_CBC_SHA,
},
CompressionMethods: []uint8{
tls.CompressionNone,
},
Extensions: []tls.TLSExtension{
&tls.UtlsGREASEExtension{},
&tls.SNIExtension{},
&tls.ExtendedMasterSecretExtension{},
&tls.RenegotiationInfoExtension{Renegotiation: tls.RenegotiateOnceAsClient},
&tls.SupportedCurvesExtension{[]tls.CurveID{
tls.GREASE_PLACEHOLDER,
tls.X25519,
tls.CurveP256,
tls.CurveP384,
tls.CurveP521,
}},
&tls.SupportedPointsExtension{SupportedPoints: []byte{
tls.PointFormatUncompressed,
}},
&tls.ALPNExtension{AlpnProtocols: []string{"h2", "http/1.1"}},
&tls.StatusRequestExtension{},
&tls.SignatureAlgorithmsExtension{SupportedSignatureAlgorithms: []tls.SignatureScheme{
tls.ECDSAWithP256AndSHA256,
tls.PSSWithSHA256,
tls.PKCS1WithSHA256,
tls.ECDSAWithP384AndSHA384,
tls.ECDSAWithSHA1,
tls.PSSWithSHA384,
tls.PSSWithSHA384,
tls.PKCS1WithSHA384,
tls.PSSWithSHA512,
tls.PKCS1WithSHA512,
tls.PKCS1WithSHA1,
}},
&tls.SCTExtension{},
&tls.KeyShareExtension{[]tls.KeyShare{
{Group: tls.CurveID(tls.GREASE_PLACEHOLDER), Data: []byte{0}},
{Group: tls.X25519},
}},
&tls.PSKKeyExchangeModesExtension{[]uint8{
tls.PskModeDHE,
}},
&tls.SupportedVersionsExtension{[]uint16{
tls.GREASE_PLACEHOLDER,
tls.VersionTLS13,
tls.VersionTLS12,
tls.VersionTLS11,
tls.VersionTLS10,
}},
&tls.UtlsCompressCertExtension{[]tls.CertCompressionAlgo{
tls.CertCompressionZlib,
}},
&tls.UtlsGREASEExtension{},
&tls.UtlsPaddingExtension{GetPaddingLen: tls.BoringPaddingStyle},
},
}, nil
},
},
settings: map[http2.SettingID]uint32{
http2.SettingEnablePush: 0,
http2.SettingInitialWindowSize: 2097152,
Expand All @@ -679,6 +765,117 @@ var Safari_IOS_17_0 = ClientProfile{
connectionFlow: 10485760,
}

var Safari_IOS_18_0 = ClientProfile{
clientHelloId: tls.ClientHelloID{
Client: "iOS",
RandomExtensionOrder: false,
Version: "18.0",
Seed: nil,
SpecFactory: func() (tls.ClientHelloSpec, error) {
return tls.ClientHelloSpec{
CipherSuites: []uint16{
tls.GREASE_PLACEHOLDER,
tls.TLS_AES_128_GCM_SHA256,
tls.TLS_AES_256_GCM_SHA384,
tls.TLS_CHACHA20_POLY1305_SHA256,
tls.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,
tls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
tls.TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256,
tls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,
tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
tls.TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256,
tls.TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA,
tls.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA,
tls.TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA,
tls.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,
tls.TLS_RSA_WITH_AES_256_GCM_SHA384,
tls.TLS_RSA_WITH_AES_128_GCM_SHA256,
tls.TLS_RSA_WITH_AES_256_CBC_SHA,
tls.TLS_RSA_WITH_AES_128_CBC_SHA,
tls.TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA,
tls.TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA,
tls.TLS_RSA_WITH_3DES_EDE_CBC_SHA,
},
CompressionMethods: []uint8{
tls.CompressionNone,
},
Extensions: []tls.TLSExtension{
&tls.UtlsGREASEExtension{},
&tls.SNIExtension{},
&tls.ExtendedMasterSecretExtension{},
&tls.RenegotiationInfoExtension{Renegotiation: tls.RenegotiateOnceAsClient},
&tls.SupportedCurvesExtension{[]tls.CurveID{
tls.GREASE_PLACEHOLDER,
tls.X25519,
tls.CurveP256,
tls.CurveP384,
tls.CurveP521,
}},
&tls.SupportedPointsExtension{SupportedPoints: []byte{
tls.PointFormatUncompressed,
}},
&tls.ALPNExtension{AlpnProtocols: []string{"h2", "http/1.1"}},
&tls.StatusRequestExtension{},
&tls.SignatureAlgorithmsExtension{SupportedSignatureAlgorithms: []tls.SignatureScheme{
tls.ECDSAWithP256AndSHA256,
tls.PSSWithSHA256,
tls.PKCS1WithSHA256,
tls.ECDSAWithP384AndSHA384,
tls.ECDSAWithSHA1,
tls.PSSWithSHA384,
tls.PSSWithSHA384,
tls.PKCS1WithSHA384,
tls.PSSWithSHA512,
tls.PKCS1WithSHA512,
tls.PKCS1WithSHA1,
}},
&tls.SCTExtension{},
&tls.KeyShareExtension{[]tls.KeyShare{
{Group: tls.CurveID(tls.GREASE_PLACEHOLDER), Data: []byte{0}},
{Group: tls.X25519},
}},
&tls.PSKKeyExchangeModesExtension{[]uint8{
tls.PskModeDHE,
}},
&tls.SupportedVersionsExtension{[]uint16{
tls.GREASE_PLACEHOLDER,
tls.VersionTLS13,
tls.VersionTLS12,
tls.VersionTLS11,
tls.VersionTLS10,
}},
&tls.UtlsCompressCertExtension{[]tls.CertCompressionAlgo{
tls.CertCompressionZlib,
}},
&tls.UtlsGREASEExtension{},
&tls.UtlsPaddingExtension{GetPaddingLen: tls.BoringPaddingStyle},
},
}, nil
},
},
settings: map[http2.SettingID]uint32{
http2.SettingEnablePush: 0,
http2.SettingMaxConcurrentStreams: 100,
http2.SettingInitialWindowSize: 2097152,
0x8: 1,
0x9: 1,
},
settingsOrder: []http2.SettingID{
http2.SettingEnablePush,
http2.SettingMaxConcurrentStreams,
http2.SettingInitialWindowSize,
0x8,
0x9,
},
pseudoHeaderOrder: []string{
":method",
":scheme",
":authority",
":path",
},
connectionFlow: 10420225,
}

var Safari_IOS_16_0 = ClientProfile{
clientHelloId: tls.HelloIOS_16_0,
settings: map[http2.SettingID]uint32{
Expand Down
1 change: 1 addition & 0 deletions profiles/profiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ var MappedTLSClients = map[string]ClientProfile{
"safari_ios_15_6": Safari_IOS_15_6,
"safari_ios_16_0": Safari_IOS_16_0,
"safari_ios_17_0": Safari_IOS_17_0,
"safari_ios_18_0": Safari_IOS_18_0,
"firefox_102": Firefox_102,
"firefox_104": Firefox_104,
"firefox_105": Firefox_105,
Expand Down
33 changes: 31 additions & 2 deletions tests/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ func TestClients(t *testing.T) {
t.Log("testing safari ios 16")
safari_iOS_16_0(t)
time.Sleep(2 * time.Second)
t.Log("testing safari ios 17")
safariIos17(t)
time.Sleep(2 * time.Second)
t.Log("testing safari ios 18")
safari_iOS_18_0(t)
time.Sleep(2 * time.Second)
t.Log("testing firefox 105")
firefox_105(t)
time.Sleep(2 * time.Second)
Expand All @@ -74,8 +80,6 @@ func TestClients(t *testing.T) {
time.Sleep(2 * time.Second)
t.Log("testing opera 91")
opera_91(t)
t.Log("testing safari ios 17")
safariIos17(t)
}

func TestCustomClients(t *testing.T) {
Expand Down Expand Up @@ -438,6 +442,31 @@ func safari_iOS_16_0(t *testing.T) {
compareResponse(t, "safari ios", clientFingerprints[safariIos][tls.HelloIOS_16_0.Str()], resp)
}

func safari_iOS_18_0(t *testing.T) {
options := []tls_client.HttpClientOption{
tls_client.WithClientProfile(profiles.Safari_IOS_18_0),
}

client, err := tls_client.NewHttpClient(nil, options...)
if err != nil {
t.Fatal(err)
}

req, err := http.NewRequest(http.MethodGet, peetApiEndpoint, nil)
if err != nil {
t.Fatal(err)
}

req.Header = defaultHeader

resp, err := client.Do(req)
if err != nil {
t.Fatal(err)
}

compareResponse(t, "safari ios", clientFingerprints[safariIos][profiles.Safari_IOS_18_0.GetClientHelloStr()], resp)
}

func firefox_105(t *testing.T) {
options := []tls_client.HttpClientOption{
tls_client.WithClientProfile(profiles.Firefox_105),
Expand Down
6 changes: 6 additions & 0 deletions tests/client_test_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,12 @@ var clientFingerprints = map[string]map[string]map[string]string{
akamaiFingerprint: "2:0,4:2097152,3:100|10485760|0|m,s,p,a",
akamaiFingerprintHash: "44e2112c513fdb93cd12e6ccd1b9dce5",
},
profiles.Safari_IOS_18_0.GetClientHelloStr(): map[string]string{
ja3String: "771,4865-4866-4867-49196-49195-52393-49200-49199-52392-49162-49161-49172-49171-157-156-53-47-49160-49170-10,0-23-65281-10-11-16-5-13-18-51-45-43-27-21,29-23-24-25,0",
ja3Hash: "773906b0efdefa24a7f2b8eb6985bf37",
akamaiFingerprint: "2:0,3:100,4:2097152,:1,:1|10420225|0|m,s,a,p",
akamaiFingerprintHash: "3899baa52d09f55b52580eb6d755ce5c",
},
},
okhttpAndroid: {
profiles.Okhttp4Android13.GetClientHelloStr(): map[string]string{
Expand Down

0 comments on commit 0fb80a4

Please sign in to comment.