pyhubblenetwork 0.10.0__tar.gz → 0.10.1__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.
- {pyhubblenetwork-0.10.0 → pyhubblenetwork-0.10.1}/PKG-INFO +1 -1
- {pyhubblenetwork-0.10.0 → pyhubblenetwork-0.10.1}/pyproject.toml +1 -1
- {pyhubblenetwork-0.10.0 → pyhubblenetwork-0.10.1}/src/hubblenetwork/cli.py +70 -23
- {pyhubblenetwork-0.10.0 → pyhubblenetwork-0.10.1}/.gitignore +0 -0
- {pyhubblenetwork-0.10.0 → pyhubblenetwork-0.10.1}/LICENSE +0 -0
- {pyhubblenetwork-0.10.0 → pyhubblenetwork-0.10.1}/README.md +0 -0
- {pyhubblenetwork-0.10.0 → pyhubblenetwork-0.10.1}/plugins/pyhubblenetwork/skills/hubble-ready-test/README.md +0 -0
- {pyhubblenetwork-0.10.0 → pyhubblenetwork-0.10.1}/src/hubblenetwork/__init__.py +0 -0
- {pyhubblenetwork-0.10.0 → pyhubblenetwork-0.10.1}/src/hubblenetwork/ble.py +0 -0
- {pyhubblenetwork-0.10.0 → pyhubblenetwork-0.10.1}/src/hubblenetwork/cloud.py +0 -0
- {pyhubblenetwork-0.10.0 → pyhubblenetwork-0.10.1}/src/hubblenetwork/crypto.py +0 -0
- {pyhubblenetwork-0.10.0 → pyhubblenetwork-0.10.1}/src/hubblenetwork/device.py +0 -0
- {pyhubblenetwork-0.10.0 → pyhubblenetwork-0.10.1}/src/hubblenetwork/errors.py +0 -0
- {pyhubblenetwork-0.10.0 → pyhubblenetwork-0.10.1}/src/hubblenetwork/org.py +0 -0
- {pyhubblenetwork-0.10.0 → pyhubblenetwork-0.10.1}/src/hubblenetwork/packets.py +0 -0
- {pyhubblenetwork-0.10.0 → pyhubblenetwork-0.10.1}/src/hubblenetwork/ready.py +0 -0
- {pyhubblenetwork-0.10.0 → pyhubblenetwork-0.10.1}/src/hubblenetwork/sat.py +0 -0
- {pyhubblenetwork-0.10.0 → pyhubblenetwork-0.10.1}/tests/__init__.py +0 -0
- {pyhubblenetwork-0.10.0 → pyhubblenetwork-0.10.1}/tests/conftest.py +0 -0
- {pyhubblenetwork-0.10.0 → pyhubblenetwork-0.10.1}/tests/test_aes_eax.py +0 -0
- {pyhubblenetwork-0.10.0 → pyhubblenetwork-0.10.1}/tests/test_ble_validate.py +0 -0
- {pyhubblenetwork-0.10.0 → pyhubblenetwork-0.10.1}/tests/test_cli_ctr_autodetect.py +0 -0
- {pyhubblenetwork-0.10.0 → pyhubblenetwork-0.10.1}/tests/test_cli_payload.py +0 -0
- {pyhubblenetwork-0.10.0 → pyhubblenetwork-0.10.1}/tests/test_cloud_integration.py +0 -0
- {pyhubblenetwork-0.10.0 → pyhubblenetwork-0.10.1}/tests/test_counter_eid.py +0 -0
- {pyhubblenetwork-0.10.0 → pyhubblenetwork-0.10.1}/tests/test_metrics.py +0 -0
- {pyhubblenetwork-0.10.0 → pyhubblenetwork-0.10.1}/tests/test_org_delete_device.py +0 -0
- {pyhubblenetwork-0.10.0 → pyhubblenetwork-0.10.1}/tests/test_register_device_cloud.py +0 -0
- {pyhubblenetwork-0.10.0 → pyhubblenetwork-0.10.1}/tests/test_register_device_validation.py +0 -0
- {pyhubblenetwork-0.10.0 → pyhubblenetwork-0.10.1}/tests/test_sat.py +0 -0
- {pyhubblenetwork-0.10.0 → pyhubblenetwork-0.10.1}/tests/test_sat_integration.py +0 -0
- {pyhubblenetwork-0.10.0 → pyhubblenetwork-0.10.1}/tests/test_unencrypted.py +0 -0
|
@@ -112,6 +112,22 @@ def _detect_eid_type(
|
|
|
112
112
|
return (None, None, None, False)
|
|
113
113
|
|
|
114
114
|
|
|
115
|
+
def _announce_auto_detect(auto_ctr: bool, auto_eax: bool, *, suppress: bool) -> None:
|
|
116
|
+
if suppress or not (auto_ctr or auto_eax):
|
|
117
|
+
return
|
|
118
|
+
parts = []
|
|
119
|
+
if auto_ctr:
|
|
120
|
+
parts.append("AES-CTR counter_source")
|
|
121
|
+
if auto_eax:
|
|
122
|
+
parts.append("AES-EAX period_exponent (0..15)")
|
|
123
|
+
click.secho(
|
|
124
|
+
f"[WARN] No {' / '.join(parts)} provided. Auto-detecting "
|
|
125
|
+
f"decryption configuration from incoming packets...",
|
|
126
|
+
fg="yellow",
|
|
127
|
+
err=True,
|
|
128
|
+
)
|
|
129
|
+
|
|
130
|
+
|
|
115
131
|
def _decrypt_eax_with_detect(
|
|
116
132
|
key: bytes,
|
|
117
133
|
pkt: AesEaxPacket,
|
|
@@ -120,7 +136,7 @@ def _decrypt_eax_with_detect(
|
|
|
120
136
|
fixed_exponent: int,
|
|
121
137
|
cache: dict,
|
|
122
138
|
announced: list[str],
|
|
123
|
-
|
|
139
|
+
suppress_info: bool,
|
|
124
140
|
) -> Optional[DecryptedPacket]:
|
|
125
141
|
if not auto_detect:
|
|
126
142
|
return decrypt_eax(key, pkt, period_exponent=fixed_exponent)
|
|
@@ -136,7 +152,7 @@ def _decrypt_eax_with_detect(
|
|
|
136
152
|
if result is None:
|
|
137
153
|
continue
|
|
138
154
|
cache[pkt.eid] = candidate
|
|
139
|
-
if not announced and not
|
|
155
|
+
if not announced and not suppress_info:
|
|
140
156
|
announced.append("eax")
|
|
141
157
|
click.secho(
|
|
142
158
|
f"[INFO] Detected: AES-128-EAX, counter_source=DEVICE_UPTIME, "
|
|
@@ -157,7 +173,7 @@ def _decrypt_ctr_with_detect(
|
|
|
157
173
|
days: int,
|
|
158
174
|
cache: dict,
|
|
159
175
|
announced: list[str],
|
|
160
|
-
|
|
176
|
+
suppress_info: bool,
|
|
161
177
|
) -> Optional[DecryptedPacket]:
|
|
162
178
|
if not auto_detect:
|
|
163
179
|
return decrypt(key, pkt, days=days, counter_mode=fixed_counter_mode)
|
|
@@ -181,7 +197,7 @@ def _decrypt_ctr_with_detect(
|
|
|
181
197
|
continue
|
|
182
198
|
if pkt.eid is not None:
|
|
183
199
|
cache[pkt.eid] = mode
|
|
184
|
-
if not announced and not
|
|
200
|
+
if not announced and not suppress_info:
|
|
185
201
|
announced.append("ctr")
|
|
186
202
|
variant = "AES-128-CTR" if len(key) == 16 else "AES-256-CTR"
|
|
187
203
|
click.secho(
|
|
@@ -816,7 +832,15 @@ def ble() -> None:
|
|
|
816
832
|
type=click.Choice(["UNIX_TIME", "DEVICE_UPTIME"], case_sensitive=False),
|
|
817
833
|
default="UNIX_TIME",
|
|
818
834
|
show_default=True,
|
|
819
|
-
help="EID counter mode
|
|
835
|
+
help="EID counter mode for AES-CTR packets",
|
|
836
|
+
)
|
|
837
|
+
@click.option(
|
|
838
|
+
"--period-exponent",
|
|
839
|
+
"-e",
|
|
840
|
+
type=int,
|
|
841
|
+
default=0,
|
|
842
|
+
show_default=True,
|
|
843
|
+
help="EID rotation period exponent for AES-EAX packets (0-15). Period = 2^n seconds.",
|
|
820
844
|
)
|
|
821
845
|
@click.option(
|
|
822
846
|
"--format",
|
|
@@ -848,6 +872,7 @@ def ble_detect(
|
|
|
848
872
|
key: str = None,
|
|
849
873
|
days: int = 2,
|
|
850
874
|
counter_mode: str = "UNIX_TIME",
|
|
875
|
+
period_exponent: int = 0,
|
|
851
876
|
output_format: str = "tabular",
|
|
852
877
|
payload_format: str = "base64",
|
|
853
878
|
debug: bool = False,
|
|
@@ -888,6 +913,18 @@ def ble_detect(
|
|
|
888
913
|
_output_error(f"Key decoding failed: {e}")
|
|
889
914
|
return
|
|
890
915
|
|
|
916
|
+
def _explicit(name: str) -> bool:
|
|
917
|
+
return ctx.get_parameter_source(name) == click.core.ParameterSource.COMMANDLINE
|
|
918
|
+
|
|
919
|
+
auto_detect_ctr = not _explicit("counter_mode")
|
|
920
|
+
auto_detect_eax = not _explicit("period_exponent")
|
|
921
|
+
|
|
922
|
+
_announce_auto_detect(auto_detect_ctr, auto_detect_eax, suppress=use_json)
|
|
923
|
+
|
|
924
|
+
detected_ctr_modes: dict = {}
|
|
925
|
+
detected_eax_exponents: dict = {}
|
|
926
|
+
announced: list[str] = []
|
|
927
|
+
|
|
891
928
|
# Set up timeout tracking
|
|
892
929
|
start = time.monotonic()
|
|
893
930
|
deadline = None if timeout is None else start + timeout
|
|
@@ -918,10 +955,29 @@ def ble_detect(
|
|
|
918
955
|
|
|
919
956
|
logger.debug("Packet received, attempting decryption...")
|
|
920
957
|
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
958
|
+
decrypted_pkt = None
|
|
959
|
+
if isinstance(pkt, AesEaxPacket):
|
|
960
|
+
decrypted_pkt = _decrypt_eax_with_detect(
|
|
961
|
+
decoded_key,
|
|
962
|
+
pkt,
|
|
963
|
+
auto_detect=auto_detect_eax,
|
|
964
|
+
fixed_exponent=period_exponent,
|
|
965
|
+
cache=detected_eax_exponents,
|
|
966
|
+
announced=announced,
|
|
967
|
+
suppress_info=use_json,
|
|
968
|
+
)
|
|
969
|
+
elif isinstance(pkt, EncryptedPacket):
|
|
970
|
+
decrypted_pkt = _decrypt_ctr_with_detect(
|
|
971
|
+
decoded_key,
|
|
972
|
+
pkt,
|
|
973
|
+
auto_detect=auto_detect_ctr,
|
|
974
|
+
fixed_counter_mode=counter_mode,
|
|
975
|
+
days=days,
|
|
976
|
+
cache=detected_ctr_modes,
|
|
977
|
+
announced=announced,
|
|
978
|
+
suppress_info=use_json,
|
|
979
|
+
)
|
|
980
|
+
# UnencryptedPacket and UnknownPacket fall through — keep scanning.
|
|
925
981
|
|
|
926
982
|
if decrypted_pkt:
|
|
927
983
|
# If we can decrypt it, output success
|
|
@@ -1112,18 +1168,9 @@ def ble_scan(
|
|
|
1112
1168
|
auto_detect_ctr = decoded_key is not None and not _explicit("counter_mode")
|
|
1113
1169
|
auto_detect_eax = decoded_key is not None and not _explicit("period_exponent")
|
|
1114
1170
|
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
parts.append("AES-CTR counter_source")
|
|
1119
|
-
if auto_detect_eax:
|
|
1120
|
-
parts.append("AES-EAX period_exponent (0..15)")
|
|
1121
|
-
click.secho(
|
|
1122
|
-
f"[WARN] No {' / '.join(parts)} provided. Auto-detecting "
|
|
1123
|
-
f"decryption configuration from incoming packets...",
|
|
1124
|
-
fg="yellow",
|
|
1125
|
-
err=True,
|
|
1126
|
-
)
|
|
1171
|
+
_announce_auto_detect(
|
|
1172
|
+
auto_detect_ctr, auto_detect_eax, suppress=printer.suppress_info_messages
|
|
1173
|
+
)
|
|
1127
1174
|
|
|
1128
1175
|
detected_ctr_modes: dict = {}
|
|
1129
1176
|
detected_eax_exponents: dict = {}
|
|
@@ -1158,7 +1205,7 @@ def ble_scan(
|
|
|
1158
1205
|
fixed_exponent=period_exponent,
|
|
1159
1206
|
cache=detected_eax_exponents,
|
|
1160
1207
|
announced=announced,
|
|
1161
|
-
|
|
1208
|
+
suppress_info=printer.suppress_info_messages,
|
|
1162
1209
|
)
|
|
1163
1210
|
if decrypted_pkt:
|
|
1164
1211
|
printer.print_row(decrypted_pkt, decrypt_status="ok")
|
|
@@ -1176,7 +1223,7 @@ def ble_scan(
|
|
|
1176
1223
|
days=days,
|
|
1177
1224
|
cache=detected_ctr_modes,
|
|
1178
1225
|
announced=announced,
|
|
1179
|
-
|
|
1226
|
+
suppress_info=printer.suppress_info_messages,
|
|
1180
1227
|
)
|
|
1181
1228
|
if decrypted_pkt:
|
|
1182
1229
|
printer.print_row(decrypted_pkt, decrypt_status="ok")
|
|
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
|
|
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
|