Skip to content

Commit fd39a93

Browse files
committed
updates
1 parent 2055619 commit fd39a93

File tree

7 files changed

+93
-19
lines changed

7 files changed

+93
-19
lines changed
97.8 KB
Binary file not shown.
87.6 KB
Binary file not shown.
107 KB
Binary file not shown.
97.7 KB
Binary file not shown.
144 KB
Binary file not shown.

tls_client/response.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ class Response:
1010
"""object, which contains the response to an HTTP request."""
1111

1212
def __init__(self):
13+
14+
# Reference of URL the response is coming from (especially useful with redirects)
15+
self.url = None
16+
1317
# Integer Code of responded HTTP Status, e.g. 404 or 200.
1418
self.status_code = None
1519

@@ -36,6 +40,8 @@ def json(self, **kwargs):
3640
def build_response(res: Union[dict, list], res_cookies: RequestsCookieJar) -> Response:
3741
"""Builds a Response object """
3842
response = Response()
43+
# Add target / url
44+
response.url = res["target"]
3945
# Add status code
4046
response.status_code = res["status"]
4147
# Add headers

tls_client/sessions.py

Lines changed: 87 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,12 @@ def __init__(
1818
self,
1919
client_identifier: Optional[str] = None,
2020
ja3_string: Optional[str] = None,
21-
h2_settings: Optional[dict] = None, # Optional[dict[int, int]]
22-
h2_settings_order: Optional[list] = None, # Optional[list[int]]
21+
h2_settings: Optional[dict] = None, # Optional[dict[str, int]]
22+
h2_settings_order: Optional[list] = None, # Optional[list[str]]
23+
supported_signature_algorithms: Optional[list] = None, # Optional[list[str]]
24+
supported_versions: Optional[list] = None, # Optional[list[str]]
25+
key_share_curves: Optional[list] = None, # Optional[list[str]]
26+
cert_compression_algo: str = None,
2327
pseudo_header_order: Optional[list] = None, # Optional[list[str]
2428
connection_flow: Optional[int] = None,
2529
priority_frames: Optional[list] = None,
@@ -55,7 +59,7 @@ def __init__(
5559
# --- Advanced Settings ----------------------------------------------------------------------------------------
5660

5761
# Examples:
58-
# Chrome --> chrome_103, chrome_104, chrome_105
62+
# Chrome --> chrome_103, chrome_104, chrome_105, chrome_106
5963
# Firefox --> firefox_102, firefox_104
6064
# Opera --> opera_89, opera_90
6165
# Safari --> safari_15_3, safari_15_6_1, safari_16_0
@@ -69,31 +73,95 @@ def __init__(
6973
self.ja3_string = ja3_string
7074

7175
# HTTP2 Header Frame Settings
76+
# Possible Settings:
77+
# HEADER_TABLE_SIZE
78+
# SETTINGS_ENABLE_PUSH
79+
# MAX_CONCURRENT_STREAMS
80+
# INITIAL_WINDOW_SIZE
81+
# MAX_FRAME_SIZE
82+
# MAX_HEADER_LIST_SIZE
83+
#
7284
# Example:
7385
# {
74-
# 1: 65536,
75-
# 3: 1000,
76-
# 4: 6291456,
77-
# 6: 262144
86+
# "HEADER_TABLE_SIZE": 65536,
87+
# "MAX_CONCURRENT_STREAMS": 1000,
88+
# "INITIAL_WINDOW_SIZE": 6291456,
89+
# "MAX_HEADER_LIST_SIZE": 262144
7890
# }
79-
# 1 = HEADER_TABLE_SIZE
80-
# 2 = SETTINGS_ENABLE_PUSH
81-
# 3 = MAX_CONCURRENT_STREAMS
82-
# 4 = INITIAL_WINDOW_SIZE
83-
# 5 = MAX_FRAME_SIZE
84-
# 6 = MAX_HEADER_LIST_SIZE
8591
self.h2_settings = h2_settings
8692

8793
# HTTP2 Header Frame Settings Order
8894
# Example:
8995
# [
90-
# 1,
91-
# 3,
92-
# 4,
93-
# 6
96+
# "HEADER_TABLE_SIZE",
97+
# "MAX_CONCURRENT_STREAMS",
98+
# "INITIAL_WINDOW_SIZE",
99+
# "MAX_HEADER_LIST_SIZE"
94100
# ]
95101
self.h2_settings_order = h2_settings_order
96102

103+
# Supported Signature Algorithms
104+
# Possible Settings:
105+
# PKCS1WithSHA256
106+
# PKCS1WithSHA384
107+
# PKCS1WithSHA512
108+
# PSSWithSHA256
109+
# PSSWithSHA384
110+
# PSSWithSHA512
111+
# ECDSAWithP256AndSHA256
112+
# ECDSAWithP384AndSHA384
113+
# ECDSAWithP521AndSHA512
114+
# PKCS1WithSHA1
115+
# ECDSAWithSHA1
116+
#
117+
# Example:
118+
# [
119+
# "ECDSAWithP256AndSHA256",
120+
# "PSSWithSHA256",
121+
# "PKCS1WithSHA256",
122+
# "ECDSAWithP384AndSHA384",
123+
# "PSSWithSHA384",
124+
# "PKCS1WithSHA384",
125+
# "PSSWithSHA512",
126+
# "PKCS1WithSHA512",
127+
# ]
128+
self.supported_signature_algorithms = supported_signature_algorithms
129+
130+
# Supported Versions
131+
# Possible Settings:
132+
# GREASE
133+
# 1.3
134+
# 1.2
135+
# 1.1
136+
# 1.0
137+
#
138+
# Example:
139+
# [
140+
# "GREASE",
141+
# "1.3",
142+
# "1.2"
143+
# ]
144+
self.supported_versions = supported_versions
145+
146+
# Key Share Curves
147+
# Possible Settings:
148+
# GREASE
149+
# P256
150+
# P384
151+
# P521
152+
# X25519
153+
#
154+
# Example:
155+
# [
156+
# "GREASE",
157+
# "X25519"
158+
# ]
159+
self.key_share_curves = key_share_curves
160+
161+
# Cert Compression Algorithm
162+
# Examples: "zlib", "brotli", "zstd"
163+
self.cert_compression_algo = cert_compression_algo
164+
97165
# Pseudo Header Order (:authority, :method, :path, :scheme)
98166
# Example:
99167
# [
@@ -220,7 +288,7 @@ def execute_request(
220288
"requestUrl": url,
221289
"requestMethod": method,
222290
"requestBody": request_body,
223-
"requestCookies": [] # Empty because its handled in python
291+
"requestCookies": [] # Empty because it's handled in python
224292
}
225293
if self.client_identifier is None:
226294
request_payload["customTlsClient"] = {
@@ -317,4 +385,4 @@ def delete(
317385
**kwargs: Any
318386
):
319387
"""Sends a DELETE request"""
320-
return self.execute_request(method="DELETE", url=url, **kwargs)
388+
return self.execute_request(method="DELETE", url=url, **kwargs)

0 commit comments

Comments
 (0)