Skip to main content

oxy_stealth/
tls.rs

1use serde::{Deserialize, Serialize};
2
3/// HTTP/2 Settings frame parameters to spoof different browsers.
4#[derive(Debug, Clone, Serialize, Deserialize)]
5pub struct Http2Settings {
6    pub header_table_size: Option<u32>,
7    pub enable_push: Option<bool>,
8    pub max_concurrent_streams: Option<u32>,
9    pub initial_window_size: Option<u32>,
10    pub max_frame_size: Option<u32>,
11    pub max_header_list_size: Option<u32>,
12}
13
14/// TLS JA3/JA4 spoofing profile
15#[derive(Debug, Clone, Serialize, Deserialize)]
16pub struct TlsProfile {
17    pub ciphers: Vec<u16>,             // TLS cipher suite IDs
18    pub extensions: Vec<u16>,          // TLS extension IDs
19    pub elliptic_curves: Vec<u16>,     // Supported groups (curves)
20    pub ec_point_formats: Vec<u8>,     // EC Point formats
21    pub alpn: Vec<String>,             // ALPN values (h2, http/1.1)
22    pub h2_settings: Http2Settings,
23}
24
25impl TlsProfile {
26    /// Chrome 131 standard JA3 TLS + HTTP/2 profile
27    pub fn chrome_131() -> Self {
28        Self {
29            ciphers: vec![
30                0x1301, 0x1302, 0x1303, // TLS 1.3
31                0xc02b, 0xc02f, 0xc02c, 0xc030, // TLS 1.2 ECDHE
32                0xcca9, 0xcca8, // ChaCha20
33                0xc013, 0xc014, // Legacy
34                0x009c, 0x009d, 0x002f, 0x0035, // Legacy RSA
35            ],
36            extensions: vec![
37                0, 23, 65281, 10, 11, 35, 16, 5, 13, 18, 51, 45, 43, 27, 17513, 21
38            ],
39            elliptic_curves: vec![0x1d, 0x17, 0x18], // x25519, P-256, P-384
40            ec_point_formats: vec![0], // uncompressed
41            alpn: vec!["h2".to_string(), "http/1.1".to_string()],
42            h2_settings: Http2Settings {
43                header_table_size: Some(65536),
44                enable_push: Some(false),
45                max_concurrent_streams: Some(1000),
46                initial_window_size: Some(6291456),
47                max_frame_size: Some(16384),
48                max_header_list_size: Some(262144),
49            },
50        }
51    }
52
53    /// Firefox 128 JA3 profile
54    pub fn firefox_128() -> Self {
55        Self {
56            ciphers: vec![
57                0x1301, 0x1302, 0x1303, 
58                0xc02b, 0xc02c, 0xcca9, 0xcca8, 0xc02f, 0xc030, 0xc013, 0xc014, 0x009c, 0x009d, 0x002f, 0x0035
59            ],
60            extensions: vec![
61                0, 23, 65281, 10, 11, 35, 16, 5, 34, 51, 43, 13, 45, 28, 21
62            ],
63            elliptic_curves: vec![0x1d, 0x17, 0x18],
64            ec_point_formats: vec![0],
65            alpn: vec!["h2".to_string(), "http/1.1".to_string()],
66            h2_settings: Http2Settings {
67                header_table_size: Some(65536),
68                enable_push: Some(false),
69                max_concurrent_streams: None,
70                initial_window_size: Some(131072),
71                max_frame_size: Some(16384),
72                max_header_list_size: None,
73            },
74        }
75    }
76}