hyper-sdk 3.1.0__tar.gz → 4.0.0__tar.gz
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.
- {hyper_sdk-3.1.0 → hyper_sdk-4.0.0}/PKG-INFO +56 -20
- {hyper_sdk-3.1.0 → hyper_sdk-4.0.0}/README.md +55 -19
- {hyper_sdk-3.1.0 → hyper_sdk-4.0.0}/hyper_sdk/__init__.py +1 -0
- hyper_sdk-4.0.0/hyper_sdk/akamai_input.py +66 -0
- {hyper_sdk-3.1.0 → hyper_sdk-4.0.0}/hyper_sdk/kasada_input.py +10 -1
- hyper_sdk-4.0.0/hyper_sdk/payloads.py +94 -0
- hyper_sdk-4.0.0/hyper_sdk/results.py +153 -0
- hyper_sdk-4.0.0/hyper_sdk/session.py +364 -0
- hyper_sdk-4.0.0/hyper_sdk/session_async.py +373 -0
- {hyper_sdk-3.1.0 → hyper_sdk-4.0.0}/hyper_sdk.egg-info/PKG-INFO +56 -20
- {hyper_sdk-3.1.0 → hyper_sdk-4.0.0}/hyper_sdk.egg-info/SOURCES.txt +3 -0
- {hyper_sdk-3.1.0 → hyper_sdk-4.0.0}/pyproject.toml +1 -1
- hyper_sdk-4.0.0/tests/test_results.py +177 -0
- hyper_sdk-3.1.0/hyper_sdk/akamai_input.py +0 -38
- hyper_sdk-3.1.0/hyper_sdk/session.py +0 -506
- hyper_sdk-3.1.0/hyper_sdk/session_async.py +0 -523
- {hyper_sdk-3.1.0 → hyper_sdk-4.0.0}/LICENSE +0 -0
- {hyper_sdk-3.1.0 → hyper_sdk-4.0.0}/hyper_sdk/akamai/__init__.py +0 -0
- {hyper_sdk-3.1.0 → hyper_sdk-4.0.0}/hyper_sdk/akamai/pixel.py +0 -0
- {hyper_sdk-3.1.0 → hyper_sdk-4.0.0}/hyper_sdk/akamai/script_path.py +0 -0
- {hyper_sdk-3.1.0 → hyper_sdk-4.0.0}/hyper_sdk/akamai/sec_cpt.py +0 -0
- {hyper_sdk-3.1.0 → hyper_sdk-4.0.0}/hyper_sdk/akamai/stop_signal.py +0 -0
- {hyper_sdk-3.1.0 → hyper_sdk-4.0.0}/hyper_sdk/datadome/__init__.py +0 -0
- {hyper_sdk-3.1.0 → hyper_sdk-4.0.0}/hyper_sdk/datadome/parse.py +0 -0
- {hyper_sdk-3.1.0 → hyper_sdk-4.0.0}/hyper_sdk/datadome_input.py +0 -0
- {hyper_sdk-3.1.0 → hyper_sdk-4.0.0}/hyper_sdk/incapsula/__init__.py +0 -0
- {hyper_sdk-3.1.0 → hyper_sdk-4.0.0}/hyper_sdk/incapsula/dynamic.py +0 -0
- {hyper_sdk-3.1.0 → hyper_sdk-4.0.0}/hyper_sdk/incapsula/utmvc.py +0 -0
- {hyper_sdk-3.1.0 → hyper_sdk-4.0.0}/hyper_sdk/incapsula_input.py +0 -0
- {hyper_sdk-3.1.0 → hyper_sdk-4.0.0}/hyper_sdk/kasada/__init__.py +0 -0
- {hyper_sdk-3.1.0 → hyper_sdk-4.0.0}/hyper_sdk/kasada/parse.py +0 -0
- {hyper_sdk-3.1.0 → hyper_sdk-4.0.0}/hyper_sdk/kasada/user_agent.py +0 -0
- {hyper_sdk-3.1.0 → hyper_sdk-4.0.0}/hyper_sdk/shared.py +0 -0
- {hyper_sdk-3.1.0 → hyper_sdk-4.0.0}/hyper_sdk/trustdecision_input.py +0 -0
- {hyper_sdk-3.1.0 → hyper_sdk-4.0.0}/hyper_sdk.egg-info/dependency_links.txt +0 -0
- {hyper_sdk-3.1.0 → hyper_sdk-4.0.0}/hyper_sdk.egg-info/requires.txt +0 -0
- {hyper_sdk-3.1.0 → hyper_sdk-4.0.0}/hyper_sdk.egg-info/top_level.txt +0 -0
- {hyper_sdk-3.1.0 → hyper_sdk-4.0.0}/setup.cfg +0 -0
- {hyper_sdk-3.1.0 → hyper_sdk-4.0.0}/tests/test_user_agent.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: hyper_sdk
|
|
3
|
-
Version:
|
|
3
|
+
Version: 4.0.0
|
|
4
4
|
Summary: Hyper Solutions Python SDK
|
|
5
5
|
License: MIT License
|
|
6
6
|
|
|
@@ -73,14 +73,27 @@ from hyper_sdk import Session, SensorInput
|
|
|
73
73
|
session = Session("your-api-key")
|
|
74
74
|
|
|
75
75
|
# Generate Akamai sensor data
|
|
76
|
-
|
|
76
|
+
result = session.generate_sensor_data(SensorInput(
|
|
77
77
|
# sensor input fields
|
|
78
78
|
))
|
|
79
79
|
|
|
80
|
-
print(f"Generated sensor data: {
|
|
81
|
-
print(f"Sensor context: {
|
|
80
|
+
print(f"Generated sensor data: {result.payload}")
|
|
81
|
+
print(f"Sensor context: {result.context}")
|
|
82
82
|
```
|
|
83
83
|
|
|
84
|
+
Every `generate_*` method returns a result object (`SensorResult`, `SbsdResult`, ...), so fields the API adds later arrive without breaking your code.
|
|
85
|
+
|
|
86
|
+
### Client hints (Accept-CH)
|
|
87
|
+
|
|
88
|
+
Sensor, SBSD, Reese84, Kasada payload and DataDome results carry `client_hints`: the `sec-ch-*`, `device-memory`, `dpr`, `viewport-width`, `ect`, `rtt` and `downlink` headers for the device the payload was generated for, keyed by lowercase header name and ready to send verbatim. Send only the ones the site asked for in its `Accept-CH` response header:
|
|
89
|
+
|
|
90
|
+
```python
|
|
91
|
+
requested = [h.strip().lower() for h in response.headers.get("accept-ch", "").split(",") if h.strip()]
|
|
92
|
+
hints = {name: result.client_hints[name] for name in requested if result.client_hints and name in result.client_hints}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
`client_hints` is `None` when the API returns none (Safari user agents, and payloads built by a remote browser).
|
|
96
|
+
|
|
84
97
|
## ✨ Features
|
|
85
98
|
|
|
86
99
|
- 🛡️ **Akamai Bot Manager**: Generate sensor data, handle pixel challenges, validate cookies
|
|
@@ -142,9 +155,25 @@ Bypass **Akamai Bot Manager** protection with sensor data generation, cookie val
|
|
|
142
155
|
Generate sensor data for valid **Akamai cookies** and bot detection bypass:
|
|
143
156
|
|
|
144
157
|
```python
|
|
145
|
-
|
|
158
|
+
result = await session.generate_sensor_data(SensorInput(
|
|
146
159
|
# Configure sensor parameters
|
|
147
|
-
|
|
160
|
+
))
|
|
161
|
+
# result.payload is the sensor data, result.context goes into the next SensorInput
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### SBSD
|
|
165
|
+
|
|
166
|
+
Generate **SBSD** payloads. The first request of a session sends the script, later ones send the returned context. A hard block (an SBSD POST with a `t` parameter) always sends the script with an empty context, never one from an earlier request:
|
|
167
|
+
|
|
168
|
+
```python
|
|
169
|
+
from hyper_sdk import SbsdInput
|
|
170
|
+
|
|
171
|
+
result = session.generate_sbsd_data(SbsdInput(
|
|
172
|
+
# other sbsd input fields
|
|
173
|
+
script=script,
|
|
174
|
+
script_url=script_url, # optional: absolute src of the SBSD script tag, query included
|
|
175
|
+
))
|
|
176
|
+
# POST result.payload; pass result.context in the next SbsdInput instead of script
|
|
148
177
|
```
|
|
149
178
|
|
|
150
179
|
### Handling Sec-Cpt Challenges
|
|
@@ -195,9 +224,10 @@ script_url, post_url = parse_pixel_script_url(html_content)
|
|
|
195
224
|
script_var = parse_pixel_script_var(script_content)
|
|
196
225
|
|
|
197
226
|
# Generate pixel data
|
|
198
|
-
|
|
227
|
+
result = session.generate_pixel_data(PixelInput(
|
|
199
228
|
# pixel input fields
|
|
200
229
|
))
|
|
230
|
+
# result.payload is the pixel data
|
|
201
231
|
```
|
|
202
232
|
|
|
203
233
|
## 🔒 Incapsula Protection
|
|
@@ -211,9 +241,10 @@ Create **Reese84 sensor data** for Incapsula bypass:
|
|
|
211
241
|
```python
|
|
212
242
|
from hyper_sdk import ReeseInput
|
|
213
243
|
|
|
214
|
-
|
|
244
|
+
result = session.generate_reese84_sensor(ReeseInput(
|
|
215
245
|
# reese input fields
|
|
216
246
|
))
|
|
247
|
+
# result.payload is the sensor, result.client_hints the Accept-CH headers
|
|
217
248
|
```
|
|
218
249
|
|
|
219
250
|
### UTMVC Cookie Generation
|
|
@@ -223,9 +254,10 @@ Generate **UTMVC cookies** for Incapsula protection bypass:
|
|
|
223
254
|
```python
|
|
224
255
|
from hyper_sdk import UtmvcInput
|
|
225
256
|
|
|
226
|
-
|
|
257
|
+
result = session.generate_utmvc_cookie(UtmvcInput(
|
|
227
258
|
# utmvc input fields
|
|
228
259
|
))
|
|
260
|
+
# result.payload is the ___utmvc cookie, result.swhanedl the swhanedl value
|
|
229
261
|
```
|
|
230
262
|
|
|
231
263
|
### Script Path Parsing
|
|
@@ -263,9 +295,13 @@ Create **x-kpsdk-ct tokens** for Kasada bypass:
|
|
|
263
295
|
```python
|
|
264
296
|
from hyper_sdk import KasadaPayloadInput
|
|
265
297
|
|
|
266
|
-
|
|
298
|
+
result = session.generate_kasada_payload(KasadaPayloadInput(
|
|
267
299
|
# kasada payload input fields
|
|
300
|
+
# strict=True refuses a payload built on a signal the API cannot identify
|
|
301
|
+
# yet, instead of returning one built on a guess. Optional, off by default.
|
|
268
302
|
))
|
|
303
|
+
# POST the base64-decoded result.payload to /tl with the x-kpsdk-* values in result.headers.
|
|
304
|
+
# result.client_hints are the Accept-CH headers: send only the ones the site asked for.
|
|
269
305
|
```
|
|
270
306
|
|
|
271
307
|
### Generating POW Data (CD)
|
|
@@ -275,9 +311,10 @@ Solve **Kasada Proof-of-Work** challenges for x-kpsdk-cd tokens:
|
|
|
275
311
|
```python
|
|
276
312
|
from hyper_sdk import KasadaPowInput
|
|
277
313
|
|
|
278
|
-
|
|
314
|
+
result = session.generate_kasada_pow(KasadaPowInput(
|
|
279
315
|
# kasada pow input fields
|
|
280
316
|
))
|
|
317
|
+
# result.payload is the x-kpsdk-cd value
|
|
281
318
|
```
|
|
282
319
|
|
|
283
320
|
## 🤖 Vercel BotID
|
|
@@ -291,7 +328,7 @@ Create the **x-is-human header** for Vercel BotID bypass:
|
|
|
291
328
|
```python
|
|
292
329
|
from hyper_sdk import BotIDHeaderInput
|
|
293
330
|
|
|
294
|
-
|
|
331
|
+
result = session.generate_botid_header(BotIDHeaderInput(
|
|
295
332
|
script=script_body, # The c.js script content
|
|
296
333
|
user_agent="your-user-agent",
|
|
297
334
|
ip="your-proxy-ip",
|
|
@@ -300,7 +337,7 @@ header = session.generate_botid_header(BotIDHeaderInput(
|
|
|
300
337
|
|
|
301
338
|
# Use the header in your requests
|
|
302
339
|
headers = {
|
|
303
|
-
"x-is-human":
|
|
340
|
+
"x-is-human": result.payload,
|
|
304
341
|
# ... other headers
|
|
305
342
|
}
|
|
306
343
|
```
|
|
@@ -346,9 +383,8 @@ result = session.generate_interstitial_payload(DataDomeInterstitialInput(
|
|
|
346
383
|
# interstitial input fields
|
|
347
384
|
))
|
|
348
385
|
|
|
349
|
-
|
|
350
|
-
headers
|
|
351
|
-
# POST payload to https://geo.captcha-delivery.com/interstitial/
|
|
386
|
+
# POST result.payload to https://geo.captcha-delivery.com/interstitial/
|
|
387
|
+
# result.client_hints are the Accept-CH headers for the device
|
|
352
388
|
```
|
|
353
389
|
|
|
354
390
|
### Slider Captcha Solving
|
|
@@ -362,9 +398,8 @@ result = session.generate_slider_payload(DataDomeSliderInput(
|
|
|
362
398
|
# slider input fields
|
|
363
399
|
))
|
|
364
400
|
|
|
365
|
-
|
|
366
|
-
headers
|
|
367
|
-
# GET request to check_url
|
|
401
|
+
# GET request to result.payload (the check URL)
|
|
402
|
+
# result.client_hints are the Accept-CH headers for the device
|
|
368
403
|
```
|
|
369
404
|
|
|
370
405
|
### Tags Payload Generation
|
|
@@ -374,9 +409,10 @@ Generate **DataDome tags payload**:
|
|
|
374
409
|
```python
|
|
375
410
|
from hyper_sdk import DataDomeTagsInput
|
|
376
411
|
|
|
377
|
-
|
|
412
|
+
result = session.generate_tags_payload(DataDomeTagsInput(
|
|
378
413
|
# tags input fields
|
|
379
414
|
))
|
|
415
|
+
# result.payload is the tags payload
|
|
380
416
|
```
|
|
381
417
|
|
|
382
418
|
### DeviceLink URL Parsing
|
|
@@ -30,14 +30,27 @@ from hyper_sdk import Session, SensorInput
|
|
|
30
30
|
session = Session("your-api-key")
|
|
31
31
|
|
|
32
32
|
# Generate Akamai sensor data
|
|
33
|
-
|
|
33
|
+
result = session.generate_sensor_data(SensorInput(
|
|
34
34
|
# sensor input fields
|
|
35
35
|
))
|
|
36
36
|
|
|
37
|
-
print(f"Generated sensor data: {
|
|
38
|
-
print(f"Sensor context: {
|
|
37
|
+
print(f"Generated sensor data: {result.payload}")
|
|
38
|
+
print(f"Sensor context: {result.context}")
|
|
39
39
|
```
|
|
40
40
|
|
|
41
|
+
Every `generate_*` method returns a result object (`SensorResult`, `SbsdResult`, ...), so fields the API adds later arrive without breaking your code.
|
|
42
|
+
|
|
43
|
+
### Client hints (Accept-CH)
|
|
44
|
+
|
|
45
|
+
Sensor, SBSD, Reese84, Kasada payload and DataDome results carry `client_hints`: the `sec-ch-*`, `device-memory`, `dpr`, `viewport-width`, `ect`, `rtt` and `downlink` headers for the device the payload was generated for, keyed by lowercase header name and ready to send verbatim. Send only the ones the site asked for in its `Accept-CH` response header:
|
|
46
|
+
|
|
47
|
+
```python
|
|
48
|
+
requested = [h.strip().lower() for h in response.headers.get("accept-ch", "").split(",") if h.strip()]
|
|
49
|
+
hints = {name: result.client_hints[name] for name in requested if result.client_hints and name in result.client_hints}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
`client_hints` is `None` when the API returns none (Safari user agents, and payloads built by a remote browser).
|
|
53
|
+
|
|
41
54
|
## ✨ Features
|
|
42
55
|
|
|
43
56
|
- 🛡️ **Akamai Bot Manager**: Generate sensor data, handle pixel challenges, validate cookies
|
|
@@ -99,9 +112,25 @@ Bypass **Akamai Bot Manager** protection with sensor data generation, cookie val
|
|
|
99
112
|
Generate sensor data for valid **Akamai cookies** and bot detection bypass:
|
|
100
113
|
|
|
101
114
|
```python
|
|
102
|
-
|
|
115
|
+
result = await session.generate_sensor_data(SensorInput(
|
|
103
116
|
# Configure sensor parameters
|
|
104
|
-
|
|
117
|
+
))
|
|
118
|
+
# result.payload is the sensor data, result.context goes into the next SensorInput
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### SBSD
|
|
122
|
+
|
|
123
|
+
Generate **SBSD** payloads. The first request of a session sends the script, later ones send the returned context. A hard block (an SBSD POST with a `t` parameter) always sends the script with an empty context, never one from an earlier request:
|
|
124
|
+
|
|
125
|
+
```python
|
|
126
|
+
from hyper_sdk import SbsdInput
|
|
127
|
+
|
|
128
|
+
result = session.generate_sbsd_data(SbsdInput(
|
|
129
|
+
# other sbsd input fields
|
|
130
|
+
script=script,
|
|
131
|
+
script_url=script_url, # optional: absolute src of the SBSD script tag, query included
|
|
132
|
+
))
|
|
133
|
+
# POST result.payload; pass result.context in the next SbsdInput instead of script
|
|
105
134
|
```
|
|
106
135
|
|
|
107
136
|
### Handling Sec-Cpt Challenges
|
|
@@ -152,9 +181,10 @@ script_url, post_url = parse_pixel_script_url(html_content)
|
|
|
152
181
|
script_var = parse_pixel_script_var(script_content)
|
|
153
182
|
|
|
154
183
|
# Generate pixel data
|
|
155
|
-
|
|
184
|
+
result = session.generate_pixel_data(PixelInput(
|
|
156
185
|
# pixel input fields
|
|
157
186
|
))
|
|
187
|
+
# result.payload is the pixel data
|
|
158
188
|
```
|
|
159
189
|
|
|
160
190
|
## 🔒 Incapsula Protection
|
|
@@ -168,9 +198,10 @@ Create **Reese84 sensor data** for Incapsula bypass:
|
|
|
168
198
|
```python
|
|
169
199
|
from hyper_sdk import ReeseInput
|
|
170
200
|
|
|
171
|
-
|
|
201
|
+
result = session.generate_reese84_sensor(ReeseInput(
|
|
172
202
|
# reese input fields
|
|
173
203
|
))
|
|
204
|
+
# result.payload is the sensor, result.client_hints the Accept-CH headers
|
|
174
205
|
```
|
|
175
206
|
|
|
176
207
|
### UTMVC Cookie Generation
|
|
@@ -180,9 +211,10 @@ Generate **UTMVC cookies** for Incapsula protection bypass:
|
|
|
180
211
|
```python
|
|
181
212
|
from hyper_sdk import UtmvcInput
|
|
182
213
|
|
|
183
|
-
|
|
214
|
+
result = session.generate_utmvc_cookie(UtmvcInput(
|
|
184
215
|
# utmvc input fields
|
|
185
216
|
))
|
|
217
|
+
# result.payload is the ___utmvc cookie, result.swhanedl the swhanedl value
|
|
186
218
|
```
|
|
187
219
|
|
|
188
220
|
### Script Path Parsing
|
|
@@ -220,9 +252,13 @@ Create **x-kpsdk-ct tokens** for Kasada bypass:
|
|
|
220
252
|
```python
|
|
221
253
|
from hyper_sdk import KasadaPayloadInput
|
|
222
254
|
|
|
223
|
-
|
|
255
|
+
result = session.generate_kasada_payload(KasadaPayloadInput(
|
|
224
256
|
# kasada payload input fields
|
|
257
|
+
# strict=True refuses a payload built on a signal the API cannot identify
|
|
258
|
+
# yet, instead of returning one built on a guess. Optional, off by default.
|
|
225
259
|
))
|
|
260
|
+
# POST the base64-decoded result.payload to /tl with the x-kpsdk-* values in result.headers.
|
|
261
|
+
# result.client_hints are the Accept-CH headers: send only the ones the site asked for.
|
|
226
262
|
```
|
|
227
263
|
|
|
228
264
|
### Generating POW Data (CD)
|
|
@@ -232,9 +268,10 @@ Solve **Kasada Proof-of-Work** challenges for x-kpsdk-cd tokens:
|
|
|
232
268
|
```python
|
|
233
269
|
from hyper_sdk import KasadaPowInput
|
|
234
270
|
|
|
235
|
-
|
|
271
|
+
result = session.generate_kasada_pow(KasadaPowInput(
|
|
236
272
|
# kasada pow input fields
|
|
237
273
|
))
|
|
274
|
+
# result.payload is the x-kpsdk-cd value
|
|
238
275
|
```
|
|
239
276
|
|
|
240
277
|
## 🤖 Vercel BotID
|
|
@@ -248,7 +285,7 @@ Create the **x-is-human header** for Vercel BotID bypass:
|
|
|
248
285
|
```python
|
|
249
286
|
from hyper_sdk import BotIDHeaderInput
|
|
250
287
|
|
|
251
|
-
|
|
288
|
+
result = session.generate_botid_header(BotIDHeaderInput(
|
|
252
289
|
script=script_body, # The c.js script content
|
|
253
290
|
user_agent="your-user-agent",
|
|
254
291
|
ip="your-proxy-ip",
|
|
@@ -257,7 +294,7 @@ header = session.generate_botid_header(BotIDHeaderInput(
|
|
|
257
294
|
|
|
258
295
|
# Use the header in your requests
|
|
259
296
|
headers = {
|
|
260
|
-
"x-is-human":
|
|
297
|
+
"x-is-human": result.payload,
|
|
261
298
|
# ... other headers
|
|
262
299
|
}
|
|
263
300
|
```
|
|
@@ -303,9 +340,8 @@ result = session.generate_interstitial_payload(DataDomeInterstitialInput(
|
|
|
303
340
|
# interstitial input fields
|
|
304
341
|
))
|
|
305
342
|
|
|
306
|
-
|
|
307
|
-
headers
|
|
308
|
-
# POST payload to https://geo.captcha-delivery.com/interstitial/
|
|
343
|
+
# POST result.payload to https://geo.captcha-delivery.com/interstitial/
|
|
344
|
+
# result.client_hints are the Accept-CH headers for the device
|
|
309
345
|
```
|
|
310
346
|
|
|
311
347
|
### Slider Captcha Solving
|
|
@@ -319,9 +355,8 @@ result = session.generate_slider_payload(DataDomeSliderInput(
|
|
|
319
355
|
# slider input fields
|
|
320
356
|
))
|
|
321
357
|
|
|
322
|
-
|
|
323
|
-
headers
|
|
324
|
-
# GET request to check_url
|
|
358
|
+
# GET request to result.payload (the check URL)
|
|
359
|
+
# result.client_hints are the Accept-CH headers for the device
|
|
325
360
|
```
|
|
326
361
|
|
|
327
362
|
### Tags Payload Generation
|
|
@@ -331,9 +366,10 @@ Generate **DataDome tags payload**:
|
|
|
331
366
|
```python
|
|
332
367
|
from hyper_sdk import DataDomeTagsInput
|
|
333
368
|
|
|
334
|
-
|
|
369
|
+
result = session.generate_tags_payload(DataDomeTagsInput(
|
|
335
370
|
# tags input fields
|
|
336
371
|
))
|
|
372
|
+
# result.payload is the tags payload
|
|
337
373
|
```
|
|
338
374
|
|
|
339
375
|
### DeviceLink URL Parsing
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
class SensorInput:
|
|
2
|
+
def __init__(self, abck: str, bmsz: str, version: str, page_url: str, user_agent: str, ip: str, accept_language: str,
|
|
3
|
+
context: str, script: str, script_url: str):
|
|
4
|
+
self.abck = abck
|
|
5
|
+
self.bmsz = bmsz
|
|
6
|
+
self.version = version
|
|
7
|
+
self.page_url = page_url
|
|
8
|
+
self.user_agent = user_agent
|
|
9
|
+
self.script = script
|
|
10
|
+
self.script_url = script_url
|
|
11
|
+
self.context = context
|
|
12
|
+
self.ip = ip
|
|
13
|
+
self.accept_language = accept_language
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class TelemetryInput(SensorInput):
|
|
17
|
+
def __init__(self, abck: str, bmsz: str, page_url: str, user_agent: str, ip: str, accept_language: str,
|
|
18
|
+
context: str, script: str, script_url: str, j: str = ""):
|
|
19
|
+
# A sensor request for a site that sends an Akamai-BM-Telemetry header on
|
|
20
|
+
# its protected API calls instead of posting sensor data. Only v3 dynamic
|
|
21
|
+
# scripts send the header, so there is no version. script and context
|
|
22
|
+
# chain across headers the same way they do across sensor posts.
|
|
23
|
+
super().__init__(abck, bmsz, "", page_url, user_agent, ip, accept_language, context, script, script_url)
|
|
24
|
+
# j is the "j" from the response of the site's get_params request (see
|
|
25
|
+
# get_telemetry_params), sent as it was returned. Leave it empty when the
|
|
26
|
+
# site makes no get_params request.
|
|
27
|
+
self.j = j
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class TelemetryParamsInput:
|
|
31
|
+
def __init__(self, page_url: str, script: str = "", context: str = ""):
|
|
32
|
+
self.page_url = page_url
|
|
33
|
+
# script is mutually exclusive with context, a context returned by an
|
|
34
|
+
# earlier telemetry or telemetry params request.
|
|
35
|
+
self.script = script
|
|
36
|
+
self.context = context
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class PixelInput:
|
|
40
|
+
def __init__(self, user_agent: str, html_var: str, script_var: str, accept_language: str, ip: str):
|
|
41
|
+
self.user_agent = user_agent
|
|
42
|
+
self.html_var = html_var
|
|
43
|
+
self.script_var = script_var
|
|
44
|
+
self.accept_language = accept_language
|
|
45
|
+
self.ip = ip
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
class SbsdInput:
|
|
49
|
+
def __init__(self, user_agent: str, uuid: str, page_url: str, o_cookie: str, script: str,
|
|
50
|
+
accept_language: str, ip: str, context: str = "", script_url: str = ""):
|
|
51
|
+
self.user_agent = user_agent
|
|
52
|
+
self.uuid = uuid
|
|
53
|
+
self.page_url = page_url
|
|
54
|
+
self.o_cookie = o_cookie
|
|
55
|
+
# script is mutually exclusive with context. The first sbsd request should
|
|
56
|
+
# include script; subsequent requests should only include context. A hard
|
|
57
|
+
# block (an sbsd POST with a t parameter) always sends script and an empty
|
|
58
|
+
# context, never the context from an earlier request.
|
|
59
|
+
self.script = script
|
|
60
|
+
self.accept_language = accept_language
|
|
61
|
+
self.ip = ip
|
|
62
|
+
self.context = context
|
|
63
|
+
# script_url is the absolute src of the SBSD script tag, query included.
|
|
64
|
+
# Optional: when set, the fingerprint's resource-timing signal carries the
|
|
65
|
+
# script's own entry the way a browser's does.
|
|
66
|
+
self.script_url = script_url
|
|
@@ -20,7 +20,8 @@ class KasadaPowInput:
|
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
class KasadaPayloadInput:
|
|
23
|
-
def __init__(self, user_agent: str, ips_link: str, script: str, accept_language: str, ip: str
|
|
23
|
+
def __init__(self, user_agent: str, ips_link: str, script: str, accept_language: str, ip: str,
|
|
24
|
+
strict: bool = False):
|
|
24
25
|
# UserAgent must be a Chrome Windows User-Agent.
|
|
25
26
|
self.user_agent = user_agent
|
|
26
27
|
|
|
@@ -34,6 +35,12 @@ class KasadaPayloadInput:
|
|
|
34
35
|
self.accept_language = accept_language
|
|
35
36
|
self.ip = ip
|
|
36
37
|
|
|
38
|
+
# Strict refuses the payload instead of returning one built on a guess when
|
|
39
|
+
# the script has a signal the API cannot identify yet. The request then fails
|
|
40
|
+
# with "Unidentified signals in script; refusing payload because strict was
|
|
41
|
+
# set". Off by default: such a payload usually still works.
|
|
42
|
+
self.strict = strict
|
|
43
|
+
|
|
37
44
|
def to_dict(self):
|
|
38
45
|
result = {
|
|
39
46
|
"userAgent": self.user_agent,
|
|
@@ -42,6 +49,8 @@ class KasadaPayloadInput:
|
|
|
42
49
|
"acceptLanguage": self.accept_language,
|
|
43
50
|
"ip": self.ip,
|
|
44
51
|
}
|
|
52
|
+
if self.strict:
|
|
53
|
+
result["strict"] = True
|
|
45
54
|
return result
|
|
46
55
|
|
|
47
56
|
class BotIDHeaderInput:
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"""Request bodies shared by Session and SessionAsync, so the two cannot drift."""
|
|
2
|
+
|
|
3
|
+
from typing import Any, Dict
|
|
4
|
+
|
|
5
|
+
from .akamai_input import SensorInput, PixelInput, SbsdInput, TelemetryInput, TelemetryParamsInput
|
|
6
|
+
from .incapsula_input import UtmvcInput, ReeseInput
|
|
7
|
+
from .trustdecision_input import PayloadInput
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def sensor_payload(input_data: SensorInput) -> Dict[str, Any]:
|
|
11
|
+
return {
|
|
12
|
+
'userAgent': input_data.user_agent,
|
|
13
|
+
'abck': input_data.abck,
|
|
14
|
+
'bmsz': input_data.bmsz,
|
|
15
|
+
'version': input_data.version,
|
|
16
|
+
'pageUrl': input_data.page_url,
|
|
17
|
+
'script': input_data.script,
|
|
18
|
+
'scriptUrl': input_data.script_url,
|
|
19
|
+
'context': input_data.context,
|
|
20
|
+
'ip': input_data.ip,
|
|
21
|
+
'acceptLanguage': input_data.accept_language,
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def telemetry_payload(input_data: TelemetryInput) -> Dict[str, Any]:
|
|
26
|
+
# the flat sensor request plus "j", as /v1/telemetry binds it
|
|
27
|
+
payload = sensor_payload(input_data)
|
|
28
|
+
payload['j'] = input_data.j
|
|
29
|
+
return payload
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def telemetry_params_payload(input_data: TelemetryParamsInput) -> Dict[str, Any]:
|
|
33
|
+
return {
|
|
34
|
+
'pageUrl': input_data.page_url,
|
|
35
|
+
'script': input_data.script,
|
|
36
|
+
'context': input_data.context,
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def sbsd_payload(input_data: SbsdInput) -> Dict[str, Any]:
|
|
41
|
+
payload = {
|
|
42
|
+
'userAgent': input_data.user_agent,
|
|
43
|
+
'uuid': input_data.uuid,
|
|
44
|
+
'pageUrl': input_data.page_url,
|
|
45
|
+
'o': input_data.o_cookie,
|
|
46
|
+
'script': input_data.script,
|
|
47
|
+
'acceptLanguage': input_data.accept_language,
|
|
48
|
+
'ip': input_data.ip,
|
|
49
|
+
'context': input_data.context,
|
|
50
|
+
}
|
|
51
|
+
if input_data.script_url:
|
|
52
|
+
payload['scriptUrl'] = input_data.script_url
|
|
53
|
+
return payload
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def pixel_payload(input_data: PixelInput) -> Dict[str, Any]:
|
|
57
|
+
return {
|
|
58
|
+
'userAgent': input_data.user_agent,
|
|
59
|
+
'htmlVar': input_data.html_var,
|
|
60
|
+
'scriptVar': input_data.script_var,
|
|
61
|
+
'ip': input_data.ip,
|
|
62
|
+
'acceptLanguage': input_data.accept_language,
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def reese84_payload(input_data: ReeseInput) -> Dict[str, Any]:
|
|
67
|
+
return {
|
|
68
|
+
'userAgent': input_data.user_agent,
|
|
69
|
+
'acceptLanguage': input_data.accept_language,
|
|
70
|
+
'ip': input_data.ip,
|
|
71
|
+
'scriptUrl': input_data.script_url,
|
|
72
|
+
'pageUrl': input_data.pageUrl,
|
|
73
|
+
'pow': input_data.pow,
|
|
74
|
+
'script': input_data.script,
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def utmvc_payload(input_data: UtmvcInput) -> Dict[str, Any]:
|
|
79
|
+
return {
|
|
80
|
+
'userAgent': input_data.user_agent,
|
|
81
|
+
'sessionIds': input_data.session_ids,
|
|
82
|
+
'script': input_data.script,
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def trustdecision_payload(input_data: PayloadInput) -> Dict[str, Any]:
|
|
87
|
+
return {
|
|
88
|
+
'userAgent': input_data.user_agent,
|
|
89
|
+
'pageUrl': input_data.page_url,
|
|
90
|
+
'fpUrl': input_data.fp_url,
|
|
91
|
+
'ip': input_data.ip,
|
|
92
|
+
'acceptLanguage': input_data.accept_language,
|
|
93
|
+
'script': input_data.script,
|
|
94
|
+
}
|