hyper-sdk 3.0.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.
Files changed (40) hide show
  1. {hyper_sdk-3.0.0 → hyper_sdk-4.0.0}/PKG-INFO +71 -20
  2. {hyper_sdk-3.0.0 → hyper_sdk-4.0.0}/README.md +70 -19
  3. {hyper_sdk-3.0.0 → hyper_sdk-4.0.0}/hyper_sdk/__init__.py +2 -0
  4. hyper_sdk-4.0.0/hyper_sdk/akamai_input.py +66 -0
  5. hyper_sdk-4.0.0/hyper_sdk/kasada/__init__.py +2 -0
  6. hyper_sdk-4.0.0/hyper_sdk/kasada/user_agent.py +24 -0
  7. {hyper_sdk-3.0.0 → hyper_sdk-4.0.0}/hyper_sdk/kasada_input.py +75 -66
  8. hyper_sdk-4.0.0/hyper_sdk/payloads.py +94 -0
  9. hyper_sdk-4.0.0/hyper_sdk/results.py +153 -0
  10. hyper_sdk-4.0.0/hyper_sdk/session.py +364 -0
  11. hyper_sdk-4.0.0/hyper_sdk/session_async.py +373 -0
  12. {hyper_sdk-3.0.0 → hyper_sdk-4.0.0}/hyper_sdk.egg-info/PKG-INFO +71 -20
  13. {hyper_sdk-3.0.0 → hyper_sdk-4.0.0}/hyper_sdk.egg-info/SOURCES.txt +6 -1
  14. {hyper_sdk-3.0.0 → hyper_sdk-4.0.0}/pyproject.toml +1 -1
  15. hyper_sdk-4.0.0/tests/test_results.py +177 -0
  16. hyper_sdk-4.0.0/tests/test_user_agent.py +13 -0
  17. hyper_sdk-3.0.0/hyper_sdk/akamai_input.py +0 -38
  18. hyper_sdk-3.0.0/hyper_sdk/kasada/__init__.py +0 -1
  19. hyper_sdk-3.0.0/hyper_sdk/session.py +0 -506
  20. hyper_sdk-3.0.0/hyper_sdk/session_async.py +0 -523
  21. {hyper_sdk-3.0.0 → hyper_sdk-4.0.0}/LICENSE +0 -0
  22. {hyper_sdk-3.0.0 → hyper_sdk-4.0.0}/hyper_sdk/akamai/__init__.py +0 -0
  23. {hyper_sdk-3.0.0 → hyper_sdk-4.0.0}/hyper_sdk/akamai/pixel.py +0 -0
  24. {hyper_sdk-3.0.0 → hyper_sdk-4.0.0}/hyper_sdk/akamai/script_path.py +0 -0
  25. {hyper_sdk-3.0.0 → hyper_sdk-4.0.0}/hyper_sdk/akamai/sec_cpt.py +0 -0
  26. {hyper_sdk-3.0.0 → hyper_sdk-4.0.0}/hyper_sdk/akamai/stop_signal.py +0 -0
  27. {hyper_sdk-3.0.0 → hyper_sdk-4.0.0}/hyper_sdk/datadome/__init__.py +0 -0
  28. {hyper_sdk-3.0.0 → hyper_sdk-4.0.0}/hyper_sdk/datadome/parse.py +0 -0
  29. {hyper_sdk-3.0.0 → hyper_sdk-4.0.0}/hyper_sdk/datadome_input.py +0 -0
  30. {hyper_sdk-3.0.0 → hyper_sdk-4.0.0}/hyper_sdk/incapsula/__init__.py +0 -0
  31. {hyper_sdk-3.0.0 → hyper_sdk-4.0.0}/hyper_sdk/incapsula/dynamic.py +0 -0
  32. {hyper_sdk-3.0.0 → hyper_sdk-4.0.0}/hyper_sdk/incapsula/utmvc.py +0 -0
  33. {hyper_sdk-3.0.0 → hyper_sdk-4.0.0}/hyper_sdk/incapsula_input.py +0 -0
  34. {hyper_sdk-3.0.0 → hyper_sdk-4.0.0}/hyper_sdk/kasada/parse.py +0 -0
  35. {hyper_sdk-3.0.0 → hyper_sdk-4.0.0}/hyper_sdk/shared.py +0 -0
  36. {hyper_sdk-3.0.0 → hyper_sdk-4.0.0}/hyper_sdk/trustdecision_input.py +0 -0
  37. {hyper_sdk-3.0.0 → hyper_sdk-4.0.0}/hyper_sdk.egg-info/dependency_links.txt +0 -0
  38. {hyper_sdk-3.0.0 → hyper_sdk-4.0.0}/hyper_sdk.egg-info/requires.txt +0 -0
  39. {hyper_sdk-3.0.0 → hyper_sdk-4.0.0}/hyper_sdk.egg-info/top_level.txt +0 -0
  40. {hyper_sdk-3.0.0 → hyper_sdk-4.0.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hyper_sdk
3
- Version: 3.0.0
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
- sensor_data, sensor_context = session.generate_sensor_data(SensorInput(
76
+ result = session.generate_sensor_data(SensorInput(
77
77
  # sensor input fields
78
78
  ))
79
79
 
80
- print(f"Generated sensor data: {sensor_data}")
81
- print(f"Sensor context: {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
- sensor_data, context = await session.generate_sensor_data({
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
- pixel_data = session.generate_pixel_data(PixelInput(
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
- sensor_data = session.generate_reese84_sensor("example.com", ReeseInput(
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
- utmvc_cookie, swhanedl = session.generate_utmvc_cookie(UtmvcInput(
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
- payload, headers = session.generate_kasada_payload(KasadaPayloadInput(
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
- pow_payload = session.generate_kasada_pow(KasadaPowInput(
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
- header = session.generate_botid_header(BotIDHeaderInput(
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": header,
340
+ "x-is-human": result.payload,
304
341
  # ... other headers
305
342
  }
306
343
  ```
@@ -316,6 +353,21 @@ script_path = parse_kasada_script_path(blocked_page_html)
316
353
  # Returns: /ips.js?timestamp=...
317
354
  ```
318
355
 
356
+ ### Mobile User-Agent Generation
357
+
358
+ Generate the **Kasada mobile `user-agent`** value sent on the native app flow. The mobile SDK derives it as the lowercase hex MD5 of `"<os_version> / <bundle_id> <app_version>"`:
359
+
360
+ ```python
361
+ from hyper_sdk import generate_kasada_user_agent
362
+
363
+ user_agent = generate_kasada_user_agent("18.0.1", "com.example.app", "9.15.0")
364
+ # iOS: os_version = UIDevice.systemVersion, bundle_id = CFBundleIdentifier
365
+ # Android: os_version = Build.VERSION.SDK_INT, bundle_id = package name
366
+ # Returns: 7016adc4ba8d433533954ebad33be424
367
+ ```
368
+
369
+ Available in `hyper_sdk` 3.1.0 and later.
370
+
319
371
  ## 🎯 DataDome Solutions
320
372
 
321
373
  Solve **DataDome captchas** including slider challenges and interstitial pages.
@@ -331,9 +383,8 @@ result = session.generate_interstitial_payload(DataDomeInterstitialInput(
331
383
  # interstitial input fields
332
384
  ))
333
385
 
334
- payload = result["payload"]
335
- headers = result["headers"]
336
- # 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
337
388
  ```
338
389
 
339
390
  ### Slider Captcha Solving
@@ -347,9 +398,8 @@ result = session.generate_slider_payload(DataDomeSliderInput(
347
398
  # slider input fields
348
399
  ))
349
400
 
350
- check_url = result["payload"]
351
- headers = result["headers"]
352
- # 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
353
403
  ```
354
404
 
355
405
  ### Tags Payload Generation
@@ -359,9 +409,10 @@ Generate **DataDome tags payload**:
359
409
  ```python
360
410
  from hyper_sdk import DataDomeTagsInput
361
411
 
362
- tags_payload = session.generate_tags_payload(DataDomeTagsInput(
412
+ result = session.generate_tags_payload(DataDomeTagsInput(
363
413
  # tags input fields
364
414
  ))
415
+ # result.payload is the tags payload
365
416
  ```
366
417
 
367
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
- sensor_data, sensor_context = session.generate_sensor_data(SensorInput(
33
+ result = session.generate_sensor_data(SensorInput(
34
34
  # sensor input fields
35
35
  ))
36
36
 
37
- print(f"Generated sensor data: {sensor_data}")
38
- print(f"Sensor context: {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
- sensor_data, context = await session.generate_sensor_data({
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
- pixel_data = session.generate_pixel_data(PixelInput(
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
- sensor_data = session.generate_reese84_sensor("example.com", ReeseInput(
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
- utmvc_cookie, swhanedl = session.generate_utmvc_cookie(UtmvcInput(
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
- payload, headers = session.generate_kasada_payload(KasadaPayloadInput(
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
- pow_payload = session.generate_kasada_pow(KasadaPowInput(
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
- header = session.generate_botid_header(BotIDHeaderInput(
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": header,
297
+ "x-is-human": result.payload,
261
298
  # ... other headers
262
299
  }
263
300
  ```
@@ -273,6 +310,21 @@ script_path = parse_kasada_script_path(blocked_page_html)
273
310
  # Returns: /ips.js?timestamp=...
274
311
  ```
275
312
 
313
+ ### Mobile User-Agent Generation
314
+
315
+ Generate the **Kasada mobile `user-agent`** value sent on the native app flow. The mobile SDK derives it as the lowercase hex MD5 of `"<os_version> / <bundle_id> <app_version>"`:
316
+
317
+ ```python
318
+ from hyper_sdk import generate_kasada_user_agent
319
+
320
+ user_agent = generate_kasada_user_agent("18.0.1", "com.example.app", "9.15.0")
321
+ # iOS: os_version = UIDevice.systemVersion, bundle_id = CFBundleIdentifier
322
+ # Android: os_version = Build.VERSION.SDK_INT, bundle_id = package name
323
+ # Returns: 7016adc4ba8d433533954ebad33be424
324
+ ```
325
+
326
+ Available in `hyper_sdk` 3.1.0 and later.
327
+
276
328
  ## 🎯 DataDome Solutions
277
329
 
278
330
  Solve **DataDome captchas** including slider challenges and interstitial pages.
@@ -288,9 +340,8 @@ result = session.generate_interstitial_payload(DataDomeInterstitialInput(
288
340
  # interstitial input fields
289
341
  ))
290
342
 
291
- payload = result["payload"]
292
- headers = result["headers"]
293
- # 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
294
345
  ```
295
346
 
296
347
  ### Slider Captcha Solving
@@ -304,9 +355,8 @@ result = session.generate_slider_payload(DataDomeSliderInput(
304
355
  # slider input fields
305
356
  ))
306
357
 
307
- check_url = result["payload"]
308
- headers = result["headers"]
309
- # 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
310
360
  ```
311
361
 
312
362
  ### Tags Payload Generation
@@ -316,9 +366,10 @@ Generate **DataDome tags payload**:
316
366
  ```python
317
367
  from hyper_sdk import DataDomeTagsInput
318
368
 
319
- tags_payload = session.generate_tags_payload(DataDomeTagsInput(
369
+ result = session.generate_tags_payload(DataDomeTagsInput(
320
370
  # tags input fields
321
371
  ))
372
+ # result.payload is the tags payload
322
373
  ```
323
374
 
324
375
  ### DeviceLink URL Parsing
@@ -4,7 +4,9 @@ from .akamai.sec_cpt import *
4
4
  from .akamai.stop_signal import *
5
5
  from .incapsula.utmvc import *
6
6
  from .incapsula.dynamic import *
7
+ from .results import *
7
8
  from .session import *
8
9
  from .session_async import *
9
10
  from .kasada.parse import *
11
+ from .kasada.user_agent import *
10
12
  from .datadome.parse import *
@@ -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
@@ -0,0 +1,2 @@
1
+ from .parse import *
2
+ from .user_agent import *
@@ -0,0 +1,24 @@
1
+ import hashlib
2
+
3
+ __all__ = ["generate_kasada_user_agent"]
4
+
5
+
6
+ def generate_kasada_user_agent(os_version: str, bundle_id: str, app_version: str) -> str:
7
+ """
8
+ Generates the Kasada mobile user-agent value.
9
+
10
+ The Kasada 2.x mobile SDK derives the user-agent header as the lowercase hex MD5 of
11
+ "<os_version> / <bundle_id> <app_version>". On iOS os_version is UIDevice.systemVersion
12
+ (e.g. "18.0.1") and bundle_id is the app bundle id (e.g. "com.example.app"); on
13
+ Android os_version is Build.VERSION.SDK_INT (e.g. "34") and bundle_id is the package name.
14
+
15
+ Args:
16
+ os_version (str): The device OS version string.
17
+ bundle_id (str): The app bundle id (iOS) or package name (Android).
18
+ app_version (str): The app version (e.g. "9.15.0").
19
+
20
+ Returns:
21
+ str: The lowercase hex MD5 user-agent value.
22
+ """
23
+ raw = f"{os_version} / {bundle_id} {app_version}"
24
+ return hashlib.md5(raw.encode("utf-8")).hexdigest()
@@ -1,67 +1,76 @@
1
- class KasadaPowInput:
2
- def __init__(self, st: int, ct: str, domain: str, fc: str = "", work_time: int = None):
3
- # St is the x-kpsdk-st value returned by the /tl POST request
4
- self.st = st
5
- # Ct is the x-kpsdk-ct value returned by the /tl POST request
6
- self.ct = ct
7
- # fc is the x-kpsdk-fc value returned by the /mfc GET request, if used by the site
8
- self.fc = fc
9
- # WorkTime can be used to pre-generate POW strings
10
- self.work_time = work_time
11
- self.domain = domain
12
-
13
- def to_dict(self):
14
- result = {"st": self.st, "ct": self.ct, "domain": self.domain}
15
- if self.fc: # Only include fc if it's not empty
16
- result["fc"] = self.fc
17
- if self.work_time is not None:
18
- result["workTime"] = self.work_time
19
- return result
20
-
21
-
22
- class KasadaPayloadInput:
23
- def __init__(self, user_agent: str, ips_link: str, script: str, accept_language: str, ip: str):
24
- # UserAgent must be a Chrome Windows User-Agent.
25
- self.user_agent = user_agent
26
-
27
- # IpsLink is the ips.js script link, parsed from the block page (429 status code)
28
- self.ips_link = ips_link
29
-
30
- # Script is the ips.js script retrieved using the IpsLink url
31
- self.script = script
32
-
33
- # Your accept-language header
34
- self.accept_language = accept_language
35
- self.ip = ip
36
-
37
- def to_dict(self):
38
- result = {
39
- "userAgent": self.user_agent,
40
- "ipsLink": self.ips_link,
41
- "script": self.script,
42
- "acceptLanguage": self.accept_language,
43
- "ip": self.ip,
44
- }
45
- return result
46
-
47
- class BotIDHeaderInput:
48
- def __init__(self, script: str, user_agent: str, ip: str, accept_language: str):
49
- # Script is the c.js script retrieved from the BotID script endpoint
50
- self.script = script
51
-
52
- # UserAgent must be a Chrome Windows User-Agent.
53
- self.user_agent = user_agent
54
-
55
- # IP is the IPV4 address of your network or proxy
56
- self.ip = ip
57
-
58
- # Your accept-language header
59
- self.accept_language = accept_language
60
-
61
- def to_dict(self):
62
- return {
63
- "script": self.script,
64
- "userAgent": self.user_agent,
65
- "ip": self.ip,
66
- "acceptLanguage": self.accept_language,
1
+ class KasadaPowInput:
2
+ def __init__(self, st: int, ct: str, domain: str, fc: str = "", work_time: int = None):
3
+ # St is the x-kpsdk-st value returned by the /tl POST request
4
+ self.st = st
5
+ # Ct is the x-kpsdk-ct value returned by the /tl POST request
6
+ self.ct = ct
7
+ # fc is the x-kpsdk-fc value returned by the /mfc GET request, if used by the site
8
+ self.fc = fc
9
+ # WorkTime can be used to pre-generate POW strings
10
+ self.work_time = work_time
11
+ self.domain = domain
12
+
13
+ def to_dict(self):
14
+ result = {"st": self.st, "ct": self.ct, "domain": self.domain}
15
+ if self.fc: # Only include fc if it's not empty
16
+ result["fc"] = self.fc
17
+ if self.work_time is not None:
18
+ result["workTime"] = self.work_time
19
+ return result
20
+
21
+
22
+ class KasadaPayloadInput:
23
+ def __init__(self, user_agent: str, ips_link: str, script: str, accept_language: str, ip: str,
24
+ strict: bool = False):
25
+ # UserAgent must be a Chrome Windows User-Agent.
26
+ self.user_agent = user_agent
27
+
28
+ # IpsLink is the ips.js script link, parsed from the block page (429 status code)
29
+ self.ips_link = ips_link
30
+
31
+ # Script is the ips.js script retrieved using the IpsLink url
32
+ self.script = script
33
+
34
+ # Your accept-language header
35
+ self.accept_language = accept_language
36
+ self.ip = ip
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
+
44
+ def to_dict(self):
45
+ result = {
46
+ "userAgent": self.user_agent,
47
+ "ipsLink": self.ips_link,
48
+ "script": self.script,
49
+ "acceptLanguage": self.accept_language,
50
+ "ip": self.ip,
51
+ }
52
+ if self.strict:
53
+ result["strict"] = True
54
+ return result
55
+
56
+ class BotIDHeaderInput:
57
+ def __init__(self, script: str, user_agent: str, ip: str, accept_language: str):
58
+ # Script is the c.js script retrieved from the BotID script endpoint
59
+ self.script = script
60
+
61
+ # UserAgent must be a Chrome Windows User-Agent.
62
+ self.user_agent = user_agent
63
+
64
+ # IP is the IPV4 address of your network or proxy
65
+ self.ip = ip
66
+
67
+ # Your accept-language header
68
+ self.accept_language = accept_language
69
+
70
+ def to_dict(self):
71
+ return {
72
+ "script": self.script,
73
+ "userAgent": self.user_agent,
74
+ "ip": self.ip,
75
+ "acceptLanguage": self.accept_language,
67
76
  }