tls-client-python 1.16.0.1__py3-none-win32.whl → 1.16.0.2__py3-none-win32.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.
- tls_client/__init__.py +1 -2
- tls_client/bin/tls-client-windows-386.dll +0 -0
- tls_client/fingerprints/__init__.py +43 -0
- tls_client/fingerprints/chrome.py +158 -0
- tls_client/fingerprints/chrome_full.py +7369 -0
- tls_client/fingerprints/firefox.py +113 -0
- tls_client/fingerprints/registry.py +166 -0
- tls_client/py.typed +0 -0
- {tls_client_python-1.16.0.1.dist-info → tls_client_python-1.16.0.2.dist-info}/METADATA +1 -1
- {tls_client_python-1.16.0.1.dist-info → tls_client_python-1.16.0.2.dist-info}/RECORD +13 -7
- {tls_client_python-1.16.0.1.dist-info → tls_client_python-1.16.0.2.dist-info}/WHEEL +0 -0
- {tls_client_python-1.16.0.1.dist-info → tls_client_python-1.16.0.2.dist-info}/licenses/LICENSE +0 -0
- {tls_client_python-1.16.0.1.dist-info → tls_client_python-1.16.0.2.dist-info}/top_level.txt +0 -0
tls_client/__init__.py
CHANGED
|
@@ -36,7 +36,6 @@ from tls_client.requests_compat import (
|
|
|
36
36
|
from tls_client import adapters, auth, cookies, exceptions, models, status_codes, structures
|
|
37
37
|
from tls_client import context as request_context
|
|
38
38
|
from tls_client import ech, fingerprints
|
|
39
|
-
from tls_client import fingerprints
|
|
40
39
|
from tls_client._multipart_boundary import blink_boundary, boundary, gecko_boundary
|
|
41
40
|
from tls_client.context import RequestContext
|
|
42
41
|
from tls_client.status_codes import codes
|
|
@@ -78,4 +77,4 @@ __all__ = [
|
|
|
78
77
|
"status_codes",
|
|
79
78
|
"structures",
|
|
80
79
|
]
|
|
81
|
-
__version__ = "1.16.0.
|
|
80
|
+
__version__ = "1.16.0.2"
|
|
Binary file
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"""Browser fingerprint presets.
|
|
2
|
+
|
|
3
|
+
One-stop entry point for coherent browser fingerprints:
|
|
4
|
+
|
|
5
|
+
from tls_client.fingerprints import apply, list_presets
|
|
6
|
+
|
|
7
|
+
session = Session()
|
|
8
|
+
apply(session, "chrome_152_windows") # identifier + headers + ordering
|
|
9
|
+
|
|
10
|
+
A preset bundles the engine client profile (``client_identifier``), the
|
|
11
|
+
per-OS coherent header block (``default_headers``), HTTP/2 & HTTP/3
|
|
12
|
+
pseudo-header ordering, and header templates for the request-context
|
|
13
|
+
layer. Custom user presets are plain JSON/dict files with optional
|
|
14
|
+
``based_on`` inheritance (see ``registry``).
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
from tls_client.fingerprints import registry as _registry
|
|
18
|
+
from tls_client.fingerprints import chrome as _chrome
|
|
19
|
+
from tls_client.fingerprints import chrome_full as _chrome_full
|
|
20
|
+
from tls_client.fingerprints import firefox as _firefox
|
|
21
|
+
from tls_client.fingerprints.chrome_full import header_order_for_dest # noqa: F401
|
|
22
|
+
from tls_client.fingerprints.registry import ( # noqa: F401
|
|
23
|
+
apply,
|
|
24
|
+
list_presets,
|
|
25
|
+
register,
|
|
26
|
+
resolve,
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
_chrome._register(_registry)
|
|
30
|
+
_chrome_full._register(_registry)
|
|
31
|
+
_firefox._register(_registry)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def load_preset_file(path, *, strict: bool = False) -> str:
|
|
35
|
+
"""Register a user preset from a JSON file and return its name."""
|
|
36
|
+
import json
|
|
37
|
+
|
|
38
|
+
with open(path, "r", encoding="utf-8") as handle:
|
|
39
|
+
preset = json.load(handle)
|
|
40
|
+
if "name" not in preset:
|
|
41
|
+
raise ValueError("preset file %r lacks a 'name' field" % str(path))
|
|
42
|
+
register(preset, strict=strict)
|
|
43
|
+
return preset["name"]
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
"""Chrome fingerprint presets.
|
|
2
|
+
|
|
3
|
+
Header templates and HTTP/2/HTTP/3 wire traits follow captures of recent
|
|
4
|
+
Chrome releases (per-OS UA / platform strings rotate with the release;
|
|
5
|
+
brand lists keep the GREASE token verbatim). The TLS/HTTP2 wire profile
|
|
6
|
+
itself comes from the engine's ``chrome_152`` client profile; presets only
|
|
7
|
+
layer OS-coherent headers and pseudo-header ordering on top.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from typing import Any, Dict
|
|
11
|
+
|
|
12
|
+
# Chrome 152 captured brand list — the middle "Not?A_Brand" entry is the
|
|
13
|
+
# GREASE brand and rotates every release; keep it verbatim per version.
|
|
14
|
+
_SEC_CH_UA_152 = '"Chromium";v="152", "Not?A_Brand";v="24", "Google Chrome";v="152"'
|
|
15
|
+
_SEC_CH_UA_133 = '"Chromium";v="133", "Not(A:Brand";v="24", "Google Chrome";v="133"'
|
|
16
|
+
|
|
17
|
+
_CHROME_NAV_ORDER = [
|
|
18
|
+
"sec-ch-ua",
|
|
19
|
+
"sec-ch-ua-mobile",
|
|
20
|
+
"sec-ch-ua-platform",
|
|
21
|
+
"upgrade-insecure-requests",
|
|
22
|
+
"user-agent",
|
|
23
|
+
"accept",
|
|
24
|
+
"sec-fetch-site",
|
|
25
|
+
"sec-fetch-mode",
|
|
26
|
+
"sec-fetch-user",
|
|
27
|
+
"sec-fetch-dest",
|
|
28
|
+
"accept-encoding",
|
|
29
|
+
"accept-language",
|
|
30
|
+
"priority",
|
|
31
|
+
"cookie",
|
|
32
|
+
]
|
|
33
|
+
|
|
34
|
+
_CHROME_XHR_ORDER = [
|
|
35
|
+
"sec-ch-ua",
|
|
36
|
+
"sec-ch-ua-mobile",
|
|
37
|
+
"sec-ch-ua-platform",
|
|
38
|
+
"user-agent",
|
|
39
|
+
"accept",
|
|
40
|
+
"sec-fetch-site",
|
|
41
|
+
"sec-fetch-mode",
|
|
42
|
+
"sec-fetch-dest",
|
|
43
|
+
"referer",
|
|
44
|
+
"accept-encoding",
|
|
45
|
+
"accept-language",
|
|
46
|
+
"priority",
|
|
47
|
+
"cookie",
|
|
48
|
+
]
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def _desktop_headers(version: str, ua_platform: str, platform_hint: str,
|
|
52
|
+
sec_ch_ua: str) -> Dict[str, str]:
|
|
53
|
+
return {
|
|
54
|
+
"User-Agent": (
|
|
55
|
+
"Mozilla/5.0 (%s) AppleWebKit/537.36 (KHTML, like Gecko)"
|
|
56
|
+
" Chrome/%s.0.0.0 Safari/537.36" % (ua_platform, version)
|
|
57
|
+
),
|
|
58
|
+
"sec-ch-ua": sec_ch_ua,
|
|
59
|
+
"sec-ch-ua-mobile": "?0",
|
|
60
|
+
"sec-ch-ua-platform": platform_hint,
|
|
61
|
+
"Accept": (
|
|
62
|
+
"text/html,application/xhtml+xml,application/xml;q=0.9,"
|
|
63
|
+
"image/avif,image/webp,image/apng,*/*;q=0.8,"
|
|
64
|
+
"application/signed-exchange;v=b3;q=0.7"
|
|
65
|
+
),
|
|
66
|
+
"Accept-Encoding": "gzip, deflate, br, zstd",
|
|
67
|
+
"Accept-Language": "en-US,en;q=0.9",
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def _mobile_headers(version: str, ua_platform: str, platform_hint: str,
|
|
72
|
+
sec_ch_ua: str) -> Dict[str, str]:
|
|
73
|
+
headers = _desktop_headers(version, ua_platform, platform_hint, sec_ch_ua)
|
|
74
|
+
headers["sec-ch-ua-mobile"] = "?1"
|
|
75
|
+
headers["User-Agent"] = (
|
|
76
|
+
"Mozilla/5.0 (%s) AppleWebKit/537.36 (KHTML, like Gecko)"
|
|
77
|
+
" Chrome/%s.0.0.0 Mobile Safari/537.36" % (ua_platform, version)
|
|
78
|
+
)
|
|
79
|
+
return headers
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
_CHROME_152_BASE: Dict[str, Any] = {
|
|
83
|
+
"name": "chrome_152_base",
|
|
84
|
+
"browser": "chrome",
|
|
85
|
+
"client_identifier": "chrome_152",
|
|
86
|
+
"pseudo_header_order": [":method", ":authority", ":scheme", ":path"],
|
|
87
|
+
"h3_pseudo_header_order": [":method", ":authority", ":scheme", ":path"],
|
|
88
|
+
"header_order": list(_CHROME_NAV_ORDER),
|
|
89
|
+
"header_order_xhr": list(_CHROME_XHR_ORDER),
|
|
90
|
+
"with_random_tls_extension_order": True,
|
|
91
|
+
"custom_tls_client": None,
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def _register(registry) -> None:
|
|
96
|
+
registry.register(dict(_CHROME_152_BASE))
|
|
97
|
+
|
|
98
|
+
def win(name):
|
|
99
|
+
return {
|
|
100
|
+
"name": name,
|
|
101
|
+
"based_on": "chrome_152_base",
|
|
102
|
+
"default_headers": _desktop_headers("152", "Windows NT 10.0; Win64; x64",
|
|
103
|
+
'"Windows"', _SEC_CH_UA_152),
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
registry.register(win("chrome_152_windows"))
|
|
107
|
+
registry.register({
|
|
108
|
+
"name": "chrome_152",
|
|
109
|
+
"based_on": "chrome_152_windows",
|
|
110
|
+
})
|
|
111
|
+
registry.register({
|
|
112
|
+
"name": "chrome_152_macos",
|
|
113
|
+
"based_on": "chrome_152_base",
|
|
114
|
+
"default_headers": _desktop_headers("152", "Macintosh; Intel Mac OS X 10_15_7",
|
|
115
|
+
'"macOS"', _SEC_CH_UA_152),
|
|
116
|
+
})
|
|
117
|
+
registry.register({
|
|
118
|
+
"name": "chrome_152_linux",
|
|
119
|
+
"based_on": "chrome_152_base",
|
|
120
|
+
"default_headers": _desktop_headers("152", "X11; Linux x86_64",
|
|
121
|
+
'"Linux"', _SEC_CH_UA_152),
|
|
122
|
+
})
|
|
123
|
+
registry.register({
|
|
124
|
+
"name": "chrome_152_android",
|
|
125
|
+
"based_on": "chrome_152_base",
|
|
126
|
+
"default_headers": _mobile_headers("152", "Linux; Android 10; K",
|
|
127
|
+
'"Android"', _SEC_CH_UA_152),
|
|
128
|
+
})
|
|
129
|
+
registry.register({
|
|
130
|
+
"name": "chrome_152_ios",
|
|
131
|
+
"based_on": "chrome_152_base",
|
|
132
|
+
"default_headers": {
|
|
133
|
+
"User-Agent": (
|
|
134
|
+
"Mozilla/5.0 (iPhone; CPU iPhone OS 17_5 like Mac OS X)"
|
|
135
|
+
" AppleWebKit/605.1.15 (KHTML, like Gecko)"
|
|
136
|
+
" CriOS/152.0.0.0 Mobile/15E148 Safari/604.1"
|
|
137
|
+
),
|
|
138
|
+
"sec-ch-ua": _SEC_CH_UA_152,
|
|
139
|
+
"sec-ch-ua-mobile": "?1",
|
|
140
|
+
"sec-ch-ua-platform": '"iOS"',
|
|
141
|
+
"Accept": (
|
|
142
|
+
"text/html,application/xhtml+xml,application/xml;q=0.9,"
|
|
143
|
+
"image/avif,image/webp,image/apng,*/*;q=0.8,"
|
|
144
|
+
"application/signed-exchange;v=b3;q=0.7"
|
|
145
|
+
),
|
|
146
|
+
"Accept-Encoding": "gzip, deflate, br, zstd",
|
|
147
|
+
"Accept-Language": "en-US,en;q=0.9",
|
|
148
|
+
},
|
|
149
|
+
})
|
|
150
|
+
|
|
151
|
+
# A shipped-identifier preset (works with pre-152 bundled binaries).
|
|
152
|
+
registry.register({
|
|
153
|
+
"name": "chrome_133_windows",
|
|
154
|
+
"based_on": "chrome_152_base",
|
|
155
|
+
"client_identifier": "chrome_133",
|
|
156
|
+
"default_headers": _desktop_headers("133", "Windows NT 10.0; Win64; x64",
|
|
157
|
+
'"Windows"', _SEC_CH_UA_133),
|
|
158
|
+
})
|