python-tls-client 1.0.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,187 @@
1
+ Metadata-Version: 2.4
2
+ Name: python-tls-client
3
+ Version: 1.0.2
4
+ Summary: Advanced Python HTTP Client with TLS fingerprint spoofing (fork with binary-response fix and certificate pinning)
5
+ Author: Emanuele Scarlata
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/Fenix46/Python-Tls-Client
8
+ Project-URL: Source, https://github.com/Fenix46/Python-Tls-Client
9
+ Project-URL: Original, https://github.com/FlorianREGAZ/Python-Tls-Client
10
+ Classifier: Environment :: Web Environment
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Natural Language :: English
13
+ Classifier: Operating System :: Unix
14
+ Classifier: Operating System :: MacOS :: MacOS X
15
+ Classifier: Operating System :: Microsoft :: Windows
16
+ Classifier: Programming Language :: Python
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.8
19
+ Classifier: Programming Language :: Python :: 3.9
20
+ Classifier: Programming Language :: Python :: 3.10
21
+ Classifier: Programming Language :: Python :: 3.11
22
+ Classifier: Programming Language :: Python :: 3.12
23
+ Classifier: Programming Language :: Python :: 3 :: Only
24
+ Classifier: Topic :: Internet :: WWW/HTTP
25
+ Classifier: Topic :: Software Development :: Libraries
26
+ Requires-Python: >=3.8
27
+ Description-Content-Type: text/markdown
28
+ License-File: LICENSE
29
+ Requires-Dist: typing-extensions
30
+ Dynamic: license-file
31
+
32
+ # Python-TLS-Client
33
+
34
+ > **Nota:** questo è un fork di [Python-Tls-Client](https://github.com/FlorianREGAZ/Python-Tls-Client)
35
+ > di Florian Zager, pubblicato su PyPI con nome diverso (`python-tls-client`) perché
36
+ > il nome originale `tls-client` è già occupato dal progetto upstream.
37
+ > Il modulo importabile resta invariato: `import tls_client`.
38
+ >
39
+ > Modifiche rispetto all'originale:
40
+ > - Fix corruzione risposte binarie (protobuf, immagini, ...) — vedi Changelog 1.0.2
41
+ > - Certificate pinning (vedi Changelog 1.0.1)
42
+
43
+ Python-TLS-Client is an advanced HTTP library based on requests and tls-client.
44
+
45
+ # Installation
46
+ ```
47
+ pip install python-tls-client
48
+ ```
49
+
50
+ # Examples
51
+ The syntax is inspired by [requests](https://github.com/psf/requests), so its very similar and there are only very few things that are different.
52
+
53
+ Example 1 - Preset:
54
+ ```python
55
+ import tls_client
56
+
57
+ # You can also use the following as `client_identifier`:
58
+ # Chrome --> chrome_103, chrome_104, chrome_105, chrome_106, chrome_107, chrome_108, chrome109, Chrome110,
59
+ # chrome111, chrome112, chrome_116_PSK, chrome_116_PSK_PQ, chrome_117, chrome_120
60
+ # Firefox --> firefox_102, firefox_104, firefox108, Firefox110, firefox_117, firefox_120
61
+ # Opera --> opera_89, opera_90
62
+ # Safari --> safari_15_3, safari_15_6_1, safari_16_0
63
+ # iOS --> safari_ios_15_5, safari_ios_15_6, safari_ios_16_0
64
+ # iPadOS --> safari_ios_15_6
65
+ # Android --> okhttp4_android_7, okhttp4_android_8, okhttp4_android_9, okhttp4_android_10, okhttp4_android_11,
66
+ # okhttp4_android_12, okhttp4_android_13
67
+ #
68
+ # more client identifiers can be found in settings.py
69
+
70
+ session = tls_client.Session(
71
+ client_identifier="chrome112",
72
+ random_tls_extension_order=True
73
+ )
74
+
75
+ res = session.get(
76
+ "https://www.example.com/",
77
+ headers={
78
+ "key1": "value1",
79
+ },
80
+ proxy="http://user:password@host:port"
81
+ )
82
+ ```
83
+
84
+ Example 2 - Custom:
85
+ ```python
86
+ import tls_client
87
+
88
+ session = tls_client.Session(
89
+ ja3_string="771,4865-4866-4867-49195-49199-49196-49200-52393-52392-49171-49172-156-157-47-53,0-23-65281-10-11-35-16-5-13-18-51-45-43-27-17513,29-23-24,0",
90
+ h2_settings={
91
+ "HEADER_TABLE_SIZE": 65536,
92
+ "MAX_CONCURRENT_STREAMS": 1000,
93
+ "INITIAL_WINDOW_SIZE": 6291456,
94
+ "MAX_HEADER_LIST_SIZE": 262144
95
+ },
96
+ h2_settings_order=[
97
+ "HEADER_TABLE_SIZE",
98
+ "MAX_CONCURRENT_STREAMS",
99
+ "INITIAL_WINDOW_SIZE",
100
+ "MAX_HEADER_LIST_SIZE"
101
+ ],
102
+ supported_signature_algorithms=[
103
+ "ECDSAWithP256AndSHA256",
104
+ "PSSWithSHA256",
105
+ "PKCS1WithSHA256",
106
+ "ECDSAWithP384AndSHA384",
107
+ "PSSWithSHA384",
108
+ "PKCS1WithSHA384",
109
+ "PSSWithSHA512",
110
+ "PKCS1WithSHA512",
111
+ ],
112
+ supported_versions=["GREASE", "1.3", "1.2"],
113
+ key_share_curves=["GREASE", "X25519"],
114
+ cert_compression_algo="brotli",
115
+ pseudo_header_order=[
116
+ ":method",
117
+ ":authority",
118
+ ":scheme",
119
+ ":path"
120
+ ],
121
+ connection_flow=15663105,
122
+ header_order=[
123
+ "accept",
124
+ "user-agent",
125
+ "accept-encoding",
126
+ "accept-language"
127
+ ]
128
+ )
129
+
130
+ res = session.post(
131
+ "https://www.example.com/",
132
+ headers={
133
+ "key1": "value1",
134
+ },
135
+ json={
136
+ "key1": "key2"
137
+ }
138
+ )
139
+ ```
140
+
141
+ # Pyinstaller / Pyarmor
142
+ **If you want to pack the library with Pyinstaller or Pyarmor, make sure to add this to your command:**
143
+
144
+ Linux - Ubuntu / x86:
145
+ ```
146
+ --add-binary '{path_to_library}/tls_client/dependencies/tls-client-x86.so:tls_client/dependencies'
147
+ ```
148
+
149
+ Linux Alpine / AMD64:
150
+ ```
151
+ --add-binary '{path_to_library}/tls_client/dependencies/tls-client-amd64.so:tls_client/dependencies'
152
+ ```
153
+
154
+ MacOS M1 and older:
155
+ ```
156
+ --add-binary '{path_to_library}/tls_client/dependencies/tls-client-x86.dylib:tls_client/dependencies'
157
+ ```
158
+
159
+ MacOS M2:
160
+ ```
161
+ --add-binary '{path_to_library}/tls_client/dependencies/tls-client-arm64.dylib:tls_client/dependencies'
162
+ ```
163
+
164
+ Windows:
165
+ ```
166
+ --add-binary '{path_to_library}/tls_client/dependencies/tls-client-64.dll;tls_client/dependencies'
167
+ ```
168
+
169
+ # Acknowledgements
170
+ Big shout out to [Bogdanfinn](https://github.com/bogdanfinn) for open sourcing his [tls-client](https://github.com/bogdanfinn/tls-client) in Golang.
171
+ Also I wanted to keep the syntax as similar as possible to [requests](https://github.com/psf/requests), as most people use it and are familiar with it!
172
+
173
+ # Changelog
174
+
175
+ ## 1.0.2
176
+ - **Fix**: binary response bodies (protobuf, images, ...) were corrupted by a
177
+ UTF-8 `byteReplacer` (U+FFFD) inside the Go C library. Every byte > 127 that
178
+ did not form a valid UTF-8 sequence was replaced by `EF BF BD`.
179
+ - `sessions.py`: now sends `isByteResponse: True` in the request payload so
180
+ the backend returns the body as a base64 data-URI.
181
+ - `response.py`: `build_response` decodes the data-URI back to raw bytes for
182
+ `Response.content`; `Response.text` is a UTF-8 view (with replacement
183
+ chars for invalid sequences).
184
+ - Added `tests/test_binary_response.py` (regression suite, needs network).
185
+
186
+ ## 1.0.1
187
+ - Certificate pinning
@@ -0,0 +1,22 @@
1
+ python_tls_client-1.0.2.dist-info/licenses/LICENSE,sha256=issbIg7ujiqhtvXsx5mmKhdeZ6zd39ew_nEzvvwImfw,1123
2
+ tls_client/__init__.py,sha256=ORP-QdcnLxOEs42G3yPr6txUxryz7jUOA_AtHMafpf8,655
3
+ tls_client/__version__.py,sha256=s_NN5vH9smBr16spQclEogL4BdMY_9QO__dMbufzvSk,445
4
+ tls_client/cffi.py,sha256=RPuw_n-18YP__umggHbv4i4XcEa8ge-spGmt40Yf4sQ,995
5
+ tls_client/cookies.py,sha256=5ujSFL6V8bDMCH8Mow6qoj5dP5GjfMJTd8_jWottvpM,15153
6
+ tls_client/exceptions.py,sha256=edxP4P0NVOK-1r0zNRAMt4yh97LArXz8i6SU9oTSYQY,78
7
+ tls_client/response.py,sha256=5Ji09s3fnrSst3N5n61fJ7motHNF3Jjsk6WBmsZ6iOk,3126
8
+ tls_client/sessions.py,sha256=Uwx4YlhwmUkJonuqu6t0rtINiEpxbwPHbuJ4R2fc3Jw,18651
9
+ tls_client/settings.py,sha256=sknNBPsNOujgIDO5Jo4L8RZFaY6gtGuWUvpJkJ0rBog,1289
10
+ tls_client/structures.py,sha256=zb1wflxxWoKFqe8NMT2qEvIh7RA-kN459ZcNhW8p_Uo,2443
11
+ tls_client/dependencies/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
+ tls_client/dependencies/tls-client-32.dll,sha256=RYiPCa-Df2FRn1E5A-hqFs-vgkKNq-HyI5BrBZjgj7Q,16512055
13
+ tls_client/dependencies/tls-client-64.dll,sha256=sXd3hlZFX2uEghVCONMjo95NdPKot6Yr2XMlGiWe24c,18685673
14
+ tls_client/dependencies/tls-client-amd64.so,sha256=atLDjHTHV_REcR4XfmtzjeffRnObntzoPzV2GudSJCg,12091312
15
+ tls_client/dependencies/tls-client-arm64.dylib,sha256=9aKdKT0X97KOrXIyi2ilnGDpyi1iIBE8QFaWqxHf8to,10778130
16
+ tls_client/dependencies/tls-client-arm64.so,sha256=MCwijkBgGDvxs9KPpSU53zou73NxzXjmUiZMZwUTpFE,11116584
17
+ tls_client/dependencies/tls-client-x86.dylib,sha256=dEzNbwEuzbc_CWkBW3NyqhBOQY4IJJSMUT_2h5z8LBk,11687888
18
+ tls_client/dependencies/tls-client-x86.so,sha256=xY-FoLKXMRxEJHyb9W1TKXVmuARnSeQw4T8w6cbuHLI,12045392
19
+ python_tls_client-1.0.2.dist-info/METADATA,sha256=gaTJ6dwlCG1EEkWVq54IySqI766Uxn7SriTA94aS4_Y,6329
20
+ python_tls_client-1.0.2.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
21
+ python_tls_client-1.0.2.dist-info/top_level.txt,sha256=yLrfQtbTRfECzPN62knWdGNmbhcPRev1grCAMuEsEz0,11
22
+ python_tls_client-1.0.2.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.0.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Florian Zager
4
+ Copyright (c) 2026 Emanuele Scarlata (modifications)
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ tls_client
tls_client/__init__.py ADDED
@@ -0,0 +1,15 @@
1
+ # _____ __ __ ___ _ _ _
2
+ # /__ \/ / / _\ / __\ (_) ___ _ __ | |_
3
+ # / /\/ / \ \ _____ / / | | |/ _ \ '_ \| __|
4
+ # / / / /____\ \_____/ /___| | | __/ | | | |_
5
+ # \/ \____/\__/ \____/|_|_|\___|_| |_|\__|
6
+
7
+ # Disclaimer:
8
+ # Big shout out to Bogdanfinn for open sourcing his tls-client in Golang.
9
+ # Also to requests, as most of the cookie handling is copied from it. :'D
10
+ # I wanted to keep the syntax as similar as possible to requests, as most people use it and are familiar with it!
11
+ # Links:
12
+ # tls-client: https://github.com/bogdanfinn/tls-client
13
+ # requests: https://github.com/psf/requests
14
+
15
+ from .sessions import Session
@@ -0,0 +1,11 @@
1
+ # _____ __ __ ___ _ _ _
2
+ # /__ \/ / / _\ / __\ (_) ___ _ __ | |_
3
+ # / /\/ / \ \ _____ / / | | |/ _ \ '_ \| __|
4
+ # / / / /____\ \_____/ /___| | | __/ | | | |_
5
+ # \/ \____/\__/ \____/|_|_|\___|_| |_|\__|
6
+
7
+ __title__ = "tls_client"
8
+ __description__ = "Advanced Python HTTP Client (fork with binary-response fix and certificate pinning)."
9
+ __version__ = "1.0.2"
10
+ __author__ = "Emanuele Scarlata"
11
+ __license__ = "MIT"
tls_client/cffi.py ADDED
@@ -0,0 +1,33 @@
1
+ from sys import platform
2
+ from platform import machine
3
+ import ctypes
4
+ import os
5
+
6
+
7
+ if platform == 'darwin':
8
+ file_ext = '-arm64.dylib' if machine() == "arm64" else '-x86.dylib'
9
+ elif platform in ('win32', 'cygwin'):
10
+ file_ext = '-64.dll' if 8 == ctypes.sizeof(ctypes.c_voidp) else '-32.dll'
11
+ else:
12
+ if machine() == "aarch64":
13
+ file_ext = '-arm64.so'
14
+ elif "x86" in machine():
15
+ file_ext = '-x86.so'
16
+ else:
17
+ file_ext = '-amd64.so'
18
+
19
+ root_dir = os.path.abspath(os.path.dirname(__file__))
20
+ library = ctypes.cdll.LoadLibrary(f'{root_dir}/dependencies/tls-client{file_ext}')
21
+
22
+ # extract the exposed request function from the shared package
23
+ request = library.request
24
+ request.argtypes = [ctypes.c_char_p]
25
+ request.restype = ctypes.c_char_p
26
+
27
+ freeMemory = library.freeMemory
28
+ freeMemory.argtypes = [ctypes.c_char_p]
29
+ freeMemory.restype = ctypes.c_char_p
30
+
31
+ destroySession = library.destroySession
32
+ destroySession.argtypes = [ctypes.c_char_p]
33
+ destroySession.restype = ctypes.c_char_p