hyper-sdk 0.9.1__tar.gz → 0.11.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-0.9.1 → hyper_sdk-0.11.0}/PKG-INFO +1 -1
- {hyper_sdk-0.9.1 → hyper_sdk-0.11.0}/hyper_sdk/__init__.py +1 -0
- {hyper_sdk-0.9.1 → hyper_sdk-0.11.0}/hyper_sdk/akamai_input.py +2 -1
- hyper_sdk-0.11.0/hyper_sdk/incapsula/__init__.py +2 -0
- hyper_sdk-0.11.0/hyper_sdk/incapsula/dynamic.py +48 -0
- {hyper_sdk-0.9.1 → hyper_sdk-0.11.0}/hyper_sdk/session.py +51 -8
- {hyper_sdk-0.9.1 → hyper_sdk-0.11.0}/hyper_sdk.egg-info/PKG-INFO +1 -1
- {hyper_sdk-0.9.1 → hyper_sdk-0.11.0}/hyper_sdk.egg-info/SOURCES.txt +1 -0
- {hyper_sdk-0.9.1 → hyper_sdk-0.11.0}/pyproject.toml +1 -1
- hyper_sdk-0.9.1/hyper_sdk/incapsula/__init__.py +0 -1
- {hyper_sdk-0.9.1 → hyper_sdk-0.11.0}/LICENSE +0 -0
- {hyper_sdk-0.9.1 → hyper_sdk-0.11.0}/README.md +0 -0
- {hyper_sdk-0.9.1 → hyper_sdk-0.11.0}/hyper_sdk/akamai/__init__.py +0 -0
- {hyper_sdk-0.9.1 → hyper_sdk-0.11.0}/hyper_sdk/akamai/pixel.py +0 -0
- {hyper_sdk-0.9.1 → hyper_sdk-0.11.0}/hyper_sdk/akamai/script_path.py +0 -0
- {hyper_sdk-0.9.1 → hyper_sdk-0.11.0}/hyper_sdk/akamai/sec_cpt.py +0 -0
- {hyper_sdk-0.9.1 → hyper_sdk-0.11.0}/hyper_sdk/akamai/stop_signal.py +0 -0
- {hyper_sdk-0.9.1 → hyper_sdk-0.11.0}/hyper_sdk/datadome/__init__.py +0 -0
- {hyper_sdk-0.9.1 → hyper_sdk-0.11.0}/hyper_sdk/datadome/parse.py +0 -0
- {hyper_sdk-0.9.1 → hyper_sdk-0.11.0}/hyper_sdk/datadome_input.py +0 -0
- {hyper_sdk-0.9.1 → hyper_sdk-0.11.0}/hyper_sdk/incapsula/utmvc.py +0 -0
- {hyper_sdk-0.9.1 → hyper_sdk-0.11.0}/hyper_sdk/incapsula_input.py +0 -0
- {hyper_sdk-0.9.1 → hyper_sdk-0.11.0}/hyper_sdk/kasada/__init__.py +0 -0
- {hyper_sdk-0.9.1 → hyper_sdk-0.11.0}/hyper_sdk/kasada/parse.py +0 -0
- {hyper_sdk-0.9.1 → hyper_sdk-0.11.0}/hyper_sdk/kasada_input.py +0 -0
- {hyper_sdk-0.9.1 → hyper_sdk-0.11.0}/hyper_sdk.egg-info/dependency_links.txt +0 -0
- {hyper_sdk-0.9.1 → hyper_sdk-0.11.0}/hyper_sdk.egg-info/requires.txt +0 -0
- {hyper_sdk-0.9.1 → hyper_sdk-0.11.0}/hyper_sdk.egg-info/top_level.txt +0 -0
- {hyper_sdk-0.9.1 → hyper_sdk-0.11.0}/setup.cfg +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
class SensorInput:
|
|
2
|
-
def __init__(self, abck: str, bmsz: str, version: str, page_url: str, user_agent: str, ip: str, acceptLanguage: str, script_hash="", dynamic_values=""):
|
|
2
|
+
def __init__(self, abck: str, bmsz: str, version: str, page_url: str, user_agent: str, ip: str, acceptLanguage: str, context: str, script_hash="", dynamic_values=""):
|
|
3
3
|
self.abck = abck
|
|
4
4
|
self.bmsz = bmsz
|
|
5
5
|
self.version = version
|
|
@@ -7,6 +7,7 @@ class SensorInput:
|
|
|
7
7
|
self.user_agent = user_agent
|
|
8
8
|
self.script_hash = script_hash
|
|
9
9
|
self.dynamic_values = dynamic_values
|
|
10
|
+
self.context = context
|
|
10
11
|
self.ip = ip
|
|
11
12
|
self.acceptLanguage = acceptLanguage
|
|
12
13
|
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import re
|
|
2
|
+
from urllib.parse import urlparse
|
|
3
|
+
|
|
4
|
+
# Precompiled regular expressions
|
|
5
|
+
reese_script_regex = re.compile(r'src\s*=\s*"((/[^/]+/\d+)(?:\?.*)?)"')
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def parse_dynamic_reese_script(html_content: str, url_str: str) -> tuple[str, str]:
|
|
9
|
+
"""
|
|
10
|
+
Parses the sensor path and script path from the given HTML content.
|
|
11
|
+
|
|
12
|
+
This function searches the provided HTML for a script element containing a specific pattern
|
|
13
|
+
and extracts both the sensor path (shortened path) and script path (the full path).
|
|
14
|
+
It requires that the HTML contains "Pardon Our Interruption" to confirm it's the correct page type.
|
|
15
|
+
It also takes a URL string, extracts the hostname, and appends it to the sensor path.
|
|
16
|
+
|
|
17
|
+
Args:
|
|
18
|
+
html_content (str): The HTML content to parse.
|
|
19
|
+
url_str (str): The URL string to extract the hostname from.
|
|
20
|
+
|
|
21
|
+
Returns:
|
|
22
|
+
tuple[str, str]: A tuple containing the sensor path (with hostname) and script path.
|
|
23
|
+
|
|
24
|
+
Raises:
|
|
25
|
+
ValueError: If the URL is invalid.
|
|
26
|
+
Exception: If the page is not an interruption page or if the Reese script is not found.
|
|
27
|
+
"""
|
|
28
|
+
# Parse the URL to extract hostname
|
|
29
|
+
try:
|
|
30
|
+
parsed_url = urlparse(url_str)
|
|
31
|
+
hostname = parsed_url.netloc
|
|
32
|
+
except Exception:
|
|
33
|
+
raise ValueError("hyper-sdk: invalid URL")
|
|
34
|
+
|
|
35
|
+
# Verify this is an interruption page
|
|
36
|
+
if "Pardon Our Interruption" not in html_content:
|
|
37
|
+
raise Exception("hyper-sdk: not an interruption page")
|
|
38
|
+
|
|
39
|
+
# Find the Reese script
|
|
40
|
+
match = reese_script_regex.search(html_content)
|
|
41
|
+
if not match or len(match.groups()) < 2:
|
|
42
|
+
raise Exception("hyper-sdk: reese script not found")
|
|
43
|
+
|
|
44
|
+
script_path = match.group(1)
|
|
45
|
+
sensor_path = match.group(2)
|
|
46
|
+
|
|
47
|
+
# Append the hostname to the sensor path
|
|
48
|
+
return f"{sensor_path}?d={hostname}", script_path
|
|
@@ -17,7 +17,7 @@ class Session:
|
|
|
17
17
|
self.jwt_key = jwt_key
|
|
18
18
|
self.client = requests.Session() if client is None else client
|
|
19
19
|
|
|
20
|
-
def generate_sensor_data(self, input_data: SensorInput) -> str:
|
|
20
|
+
def generate_sensor_data(self, input_data: SensorInput) -> tuple[str, str]:
|
|
21
21
|
"""
|
|
22
22
|
Returns the sensor data required to generate valid akamai cookies using the Hyper Solutions API.
|
|
23
23
|
|
|
@@ -26,9 +26,23 @@ class Session:
|
|
|
26
26
|
|
|
27
27
|
Returns:
|
|
28
28
|
str: Sensor data as a string.
|
|
29
|
+
str: Context data as a string.
|
|
29
30
|
"""
|
|
30
|
-
sensor_endpoint = "https://akm.justhyped.dev/sensor"
|
|
31
|
-
|
|
31
|
+
sensor_endpoint = "https://akm.justhyped.dev/v2/sensor"
|
|
32
|
+
if not self.api_key:
|
|
33
|
+
raise ValueError("Missing API key")
|
|
34
|
+
|
|
35
|
+
headers = {
|
|
36
|
+
'Content-Type': 'application/json',
|
|
37
|
+
'Accept-Encoding': 'gzip',
|
|
38
|
+
'X-Api-Key': self.api_key
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if self.jwt_key:
|
|
42
|
+
signature = self.generate_signature()
|
|
43
|
+
headers['X-Signature'] = signature
|
|
44
|
+
|
|
45
|
+
response = self.client.post(sensor_endpoint, headers=headers, json={
|
|
32
46
|
'userAgent': input_data.user_agent,
|
|
33
47
|
'abck': input_data.abck,
|
|
34
48
|
'bmsz': input_data.bmsz,
|
|
@@ -40,6 +54,16 @@ class Session:
|
|
|
40
54
|
'acceptLanguage': input_data.acceptLanguage,
|
|
41
55
|
})
|
|
42
56
|
|
|
57
|
+
response_data = response.json()
|
|
58
|
+
|
|
59
|
+
if "error" in response_data and response_data["error"]:
|
|
60
|
+
raise Exception(f"API returned with error: {response_data['error']}")
|
|
61
|
+
|
|
62
|
+
if response.status_code != 200:
|
|
63
|
+
raise Exception(f"API returned with status code: {response.status_code}")
|
|
64
|
+
|
|
65
|
+
return response_data["payload"], response_data["context"]
|
|
66
|
+
|
|
43
67
|
def generate_sbsd_data(self, input_data: SbsdInput) -> str:
|
|
44
68
|
"""
|
|
45
69
|
Returns the sbsd data required to solve SBSD using the Hyper Solutions API.
|
|
@@ -133,22 +157,41 @@ class Session:
|
|
|
133
157
|
|
|
134
158
|
Returns:
|
|
135
159
|
str: The utmvc cookie as a string.
|
|
160
|
+
str: The swhanedl parameter.
|
|
136
161
|
|
|
137
162
|
Raises:
|
|
138
163
|
ValueError: If the script attribute or session IDs in input_data are empty.
|
|
139
164
|
"""
|
|
140
|
-
if not
|
|
141
|
-
raise ValueError("
|
|
165
|
+
if not self.api_key:
|
|
166
|
+
raise ValueError("Missing API key")
|
|
142
167
|
|
|
143
|
-
|
|
144
|
-
|
|
168
|
+
headers = {
|
|
169
|
+
'Content-Type': 'application/json',
|
|
170
|
+
'Accept-Encoding': 'gzip',
|
|
171
|
+
'X-Api-Key': self.api_key
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
if self.jwt_key:
|
|
175
|
+
signature = self.generate_signature()
|
|
176
|
+
headers['X-Signature'] = signature
|
|
145
177
|
|
|
146
|
-
|
|
178
|
+
response = self.client.post("https://incapsula.justhyped.dev/utmvc", headers=headers, json={
|
|
147
179
|
'userAgent': input_data.user_agent,
|
|
148
180
|
'sessionIds': input_data.session_ids,
|
|
149
181
|
'script': input_data.script,
|
|
150
182
|
})
|
|
151
183
|
|
|
184
|
+
response_data = response.json()
|
|
185
|
+
|
|
186
|
+
if "error" in response_data and response_data["error"]:
|
|
187
|
+
raise Exception(f"API returned with error: {response_data['error']}")
|
|
188
|
+
|
|
189
|
+
if response.status_code != 200:
|
|
190
|
+
raise Exception(f"API returned with status code: {response.status_code}")
|
|
191
|
+
|
|
192
|
+
return response_data["payload"], response_data["swhanedl"]
|
|
193
|
+
|
|
194
|
+
|
|
152
195
|
def generate_kasada_pow(self, input_data: KasadaPowInput) -> str:
|
|
153
196
|
"""
|
|
154
197
|
Returns the x-kpsdk-cd value using the Hyper Solutions API.
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
from .utmvc import *
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|