network-core 0.2.0__tar.gz → 0.2.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.
- {network_core-0.2.0 → network_core-0.2.1}/PKG-INFO +1 -1
- {network_core-0.2.0 → network_core-0.2.1}/network_core/dataModels.py +2 -2
- {network_core-0.2.0 → network_core-0.2.1}/network_core/http/httpExtract/helpers.py +19 -18
- {network_core-0.2.0 → network_core-0.2.1}/network_core.egg-info/PKG-INFO +1 -1
- {network_core-0.2.0 → network_core-0.2.1}/pyproject.toml +1 -1
- {network_core-0.2.0 → network_core-0.2.1}/network_core/__init__.py +0 -0
- {network_core-0.2.0 → network_core-0.2.1}/network_core/conn.py +0 -0
- {network_core-0.2.0 → network_core-0.2.1}/network_core/connOps.py +0 -0
- {network_core-0.2.0 → network_core-0.2.1}/network_core/http/__init__.py +0 -0
- {network_core-0.2.0 → network_core-0.2.1}/network_core/http/httpExtract/__init__.py +0 -0
- {network_core-0.2.0 → network_core-0.2.1}/network_core/http/httpExtract/parser.py +0 -0
- {network_core-0.2.0 → network_core-0.2.1}/network_core/http/httpExtract/pdh.py +0 -0
- {network_core-0.2.0 → network_core-0.2.1}/network_core/http/httpIO.py +0 -0
- {network_core-0.2.0 → network_core-0.2.1}/network_core/sni/__init__.py +0 -0
- {network_core-0.2.0 → network_core-0.2.1}/network_core/sni/clientHello.py +0 -0
- {network_core-0.2.0 → network_core-0.2.1}/network_core/sni/constants.py +0 -0
- {network_core-0.2.0 → network_core-0.2.1}/network_core/sni/crypto.py +0 -0
- {network_core-0.2.0 → network_core-0.2.1}/network_core/sni/helpers.py +0 -0
- {network_core-0.2.0 → network_core-0.2.1}/network_core/sni/parsers.py +0 -0
- {network_core-0.2.0 → network_core-0.2.1}/network_core/utils/__init__.py +0 -0
- {network_core-0.2.0 → network_core-0.2.1}/network_core/utils/csvIO.py +0 -0
- {network_core-0.2.0 → network_core-0.2.1}/network_core/utils/dt.py +0 -0
- {network_core-0.2.0 → network_core-0.2.1}/network_core/utils/jsonIO.py +0 -0
- {network_core-0.2.0 → network_core-0.2.1}/network_core/utils/pcapIO.py +0 -0
- {network_core-0.2.0 → network_core-0.2.1}/network_core.egg-info/SOURCES.txt +0 -0
- {network_core-0.2.0 → network_core-0.2.1}/network_core.egg-info/dependency_links.txt +0 -0
- {network_core-0.2.0 → network_core-0.2.1}/network_core.egg-info/requires.txt +0 -0
- {network_core-0.2.0 → network_core-0.2.1}/network_core.egg-info/top_level.txt +0 -0
- {network_core-0.2.0 → network_core-0.2.1}/setup.cfg +0 -0
|
@@ -6,6 +6,7 @@ import brotli
|
|
|
6
6
|
import json
|
|
7
7
|
import blackboxprotobuf
|
|
8
8
|
import zlib
|
|
9
|
+
import base64
|
|
9
10
|
|
|
10
11
|
|
|
11
12
|
def decompress_gzip_resilient(data):
|
|
@@ -54,7 +55,7 @@ def get_ft_from_layers(layers: dict):
|
|
|
54
55
|
)
|
|
55
56
|
|
|
56
57
|
|
|
57
|
-
def parse_hex(raw_bytes: bytes, encoding: str, content_type: str) -> dict |
|
|
58
|
+
def parse_hex(raw_bytes: bytes, encoding: str, content_type: str) -> dict | str:
|
|
58
59
|
# 1. Decompress (Existing logic)
|
|
59
60
|
encoding = str(encoding).lower() # in case I have arrays like ["application/json"]
|
|
60
61
|
content_type = str(content_type).lower()
|
|
@@ -75,14 +76,12 @@ def parse_hex(raw_bytes: bytes, encoding: str, content_type: str) -> dict | byte
|
|
|
75
76
|
print(
|
|
76
77
|
f"Decompression failed: {e}, with encoding {encoding} and content-type {content_type}"
|
|
77
78
|
)
|
|
78
|
-
print(raw_bytes[:100])
|
|
79
|
-
print("=" * 100)
|
|
80
79
|
decompressed = raw_bytes
|
|
81
80
|
|
|
82
81
|
# 2. Handle Binary types
|
|
83
82
|
binary_types = ["image/", "video/", "audio/", "application/octet-stream"]
|
|
84
83
|
if any(bt in content_type for bt in binary_types):
|
|
85
|
-
return decompressed
|
|
84
|
+
return base64.b64encode(decompressed).decode("ascii") # JSON-safe string
|
|
86
85
|
|
|
87
86
|
# 3. Handle Protobuf explicitly if the content type suggests it
|
|
88
87
|
# Google often uses "application/json+protobuf" or "application/x-protobuf"
|
|
@@ -113,29 +112,31 @@ def parse_hex(raw_bytes: bytes, encoding: str, content_type: str) -> dict | byte
|
|
|
113
112
|
|
|
114
113
|
return text_output
|
|
115
114
|
except:
|
|
116
|
-
return decompressed
|
|
115
|
+
return base64.b64encode(decompressed).decode("ascii") # JSON-safe string
|
|
117
116
|
|
|
118
117
|
|
|
119
118
|
def parse_http_unit_data(http_unit: HttpUnit):
|
|
120
119
|
try:
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
120
|
+
if isinstance(http_unit.response_data, str):
|
|
121
|
+
raw_bytes = bytes.fromhex(http_unit.response_data)
|
|
122
|
+
encoding = http_unit.response_headers.get("content-encoding", "").lower()
|
|
123
|
+
content_type = http_unit.response_headers.get("content-type", "").lower()
|
|
124
|
+
|
|
125
|
+
http_unit.response_data = parse_hex(
|
|
126
|
+
raw_bytes=raw_bytes, encoding=encoding, content_type=content_type
|
|
127
|
+
)
|
|
128
128
|
except:
|
|
129
129
|
pass
|
|
130
130
|
|
|
131
131
|
try:
|
|
132
|
-
|
|
132
|
+
if isinstance(http_unit.request_data, str):
|
|
133
|
+
raw_bytes = bytes.fromhex(http_unit.request_data)
|
|
133
134
|
|
|
134
|
-
|
|
135
|
-
|
|
135
|
+
encoding = http_unit.request_headers.get("content-encoding", "").lower()
|
|
136
|
+
content_type = http_unit.request_headers.get("content-type", "").lower()
|
|
136
137
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
138
|
+
http_unit.request_data = parse_hex( # type: ignore
|
|
139
|
+
raw_bytes=raw_bytes, encoding=encoding, content_type=content_type
|
|
140
|
+
)
|
|
140
141
|
except:
|
|
141
142
|
pass
|
|
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
|