rat-king-parser 4.2.1__tar.gz → 4.2.2__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.
- {rat_king_parser-4.2.1/src/rat_king_parser.egg-info → rat_king_parser-4.2.2}/PKG-INFO +2 -1
- {rat_king_parser-4.2.1 → rat_king_parser-4.2.2}/pyproject.toml +9 -9
- {rat_king_parser-4.2.1 → rat_king_parser-4.2.2}/src/rat_king_parser/_version.py +1 -1
- {rat_king_parser-4.2.1 → rat_king_parser-4.2.2}/src/rat_king_parser/config_parser/rat_config_parser.py +10 -8
- {rat_king_parser-4.2.1 → rat_king_parser-4.2.2}/src/rat_king_parser/config_parser/utils/data_utils.py +6 -6
- {rat_king_parser-4.2.1 → rat_king_parser-4.2.2}/src/rat_king_parser/config_parser/utils/decryptors/config_decryptor_random_hardcoded.py +3 -3
- {rat_king_parser-4.2.1 → rat_king_parser-4.2.2}/src/rat_king_parser/config_parser/utils/decryptors/config_decryptor_rijndael.py +7 -4
- {rat_king_parser-4.2.1 → rat_king_parser-4.2.2}/src/rat_king_parser/config_parser/utils/dotnetpe_payload.py +11 -4
- {rat_king_parser-4.2.1 → rat_king_parser-4.2.2/src/rat_king_parser.egg-info}/PKG-INFO +2 -1
- {rat_king_parser-4.2.1 → rat_king_parser-4.2.2}/src/rat_king_parser.egg-info/SOURCES.txt +2 -1
- {rat_king_parser-4.2.1 → rat_king_parser-4.2.2}/src/rat_king_parser.egg-info/requires.txt +1 -0
- rat_king_parser-4.2.2/tests/test_known_samples.py +115 -0
- {rat_king_parser-4.2.1 → rat_king_parser-4.2.2}/LICENSE +0 -0
- {rat_king_parser-4.2.1 → rat_king_parser-4.2.2}/README.md +0 -0
- {rat_king_parser-4.2.1 → rat_king_parser-4.2.2}/setup.cfg +0 -0
- {rat_king_parser-4.2.1 → rat_king_parser-4.2.2}/src/rat_king_parser/__init__.py +0 -0
- {rat_king_parser-4.2.1 → rat_king_parser-4.2.2}/src/rat_king_parser/config_parser/__init__.py +0 -0
- {rat_king_parser-4.2.1 → rat_king_parser-4.2.2}/src/rat_king_parser/config_parser/config_parser_exception.py +0 -0
- {rat_king_parser-4.2.1 → rat_king_parser-4.2.2}/src/rat_king_parser/config_parser/utils/__init__.py +0 -0
- {rat_king_parser-4.2.1 → rat_king_parser-4.2.2}/src/rat_king_parser/config_parser/utils/config_item.py +0 -0
- {rat_king_parser-4.2.1 → rat_king_parser-4.2.2}/src/rat_king_parser/config_parser/utils/config_normalization.py +0 -0
- {rat_king_parser-4.2.1 → rat_king_parser-4.2.2}/src/rat_king_parser/config_parser/utils/decryptors/__init__.py +0 -0
- {rat_king_parser-4.2.1 → rat_king_parser-4.2.2}/src/rat_king_parser/config_parser/utils/decryptors/config_decryptor.py +0 -0
- {rat_king_parser-4.2.1 → rat_king_parser-4.2.2}/src/rat_king_parser/config_parser/utils/decryptors/config_decryptor_aes_with_iv.py +0 -0
- {rat_king_parser-4.2.1 → rat_king_parser-4.2.2}/src/rat_king_parser/config_parser/utils/decryptors/config_decryptor_aes_with_iv_pbkdf.py +0 -0
- {rat_king_parser-4.2.1 → rat_king_parser-4.2.2}/src/rat_king_parser/config_parser/utils/decryptors/config_decryptor_decrypt_xor.py +0 -0
- {rat_king_parser-4.2.1 → rat_king_parser-4.2.2}/src/rat_king_parser/config_parser/utils/decryptors/config_decryptor_ecb.py +0 -0
- {rat_king_parser-4.2.1 → rat_king_parser-4.2.2}/src/rat_king_parser/config_parser/utils/decryptors/config_decryptor_plaintext.py +0 -0
- {rat_king_parser-4.2.1 → rat_king_parser-4.2.2}/src/rat_king_parser/config_parser/utils/dotnet_constants.py +0 -0
- {rat_king_parser-4.2.1 → rat_king_parser-4.2.2}/src/rat_king_parser/extern/__init__.py +0 -0
- {rat_king_parser-4.2.1 → rat_king_parser-4.2.2}/src/rat_king_parser/extern/maco/__init__.py +0 -0
- {rat_king_parser-4.2.1 → rat_king_parser-4.2.2}/src/rat_king_parser/extern/maco/rkp_maco.py +0 -0
- {rat_king_parser-4.2.1 → rat_king_parser-4.2.2}/src/rat_king_parser/rkp.py +0 -0
- {rat_king_parser-4.2.1 → rat_king_parser-4.2.2}/src/rat_king_parser/yara_utils/__init__.py +0 -0
- {rat_king_parser-4.2.1 → rat_king_parser-4.2.2}/src/rat_king_parser/yara_utils/recompile.py +0 -0
- {rat_king_parser-4.2.1 → rat_king_parser-4.2.2}/src/rat_king_parser/yara_utils/rules.yar +0 -0
- {rat_king_parser-4.2.1 → rat_king_parser-4.2.2}/src/rat_king_parser/yara_utils/rules.yarc +0 -0
- {rat_king_parser-4.2.1 → rat_king_parser-4.2.2}/src/rat_king_parser.egg-info/dependency_links.txt +0 -0
- {rat_king_parser-4.2.1 → rat_king_parser-4.2.2}/src/rat_king_parser.egg-info/entry_points.txt +0 -0
- {rat_king_parser-4.2.1 → rat_king_parser-4.2.2}/src/rat_king_parser.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: rat-king-parser
|
|
3
|
-
Version: 4.2.
|
|
3
|
+
Version: 4.2.2
|
|
4
4
|
Summary: A robust, multiprocessing-capable, multi-family RAT config parser/config extractor for AsyncRAT, DcRAT, VenomRAT, QuasarRAT, XWorm, Xeno RAT, and cloned/derivative RAT families.
|
|
5
5
|
Author-email: jeFF0Falltrades <8444166+jeFF0Falltrades@users.noreply.github.com>
|
|
6
6
|
Maintainer-email: jeFF0Falltrades <8444166+jeFF0Falltrades@users.noreply.github.com>
|
|
@@ -31,6 +31,7 @@ Requires-Dist: pycryptodomex
|
|
|
31
31
|
Requires-Dist: yara-python
|
|
32
32
|
Provides-Extra: dev
|
|
33
33
|
Requires-Dist: pre-commit; extra == "dev"
|
|
34
|
+
Requires-Dist: pytest; extra == "dev"
|
|
34
35
|
Provides-Extra: maco
|
|
35
36
|
Requires-Dist: maco; extra == "maco"
|
|
36
37
|
Requires-Dist: validators; extra == "maco"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[build-system]
|
|
2
2
|
build-backend = "setuptools.build_meta"
|
|
3
|
-
requires = [
|
|
3
|
+
requires = ["setuptools"]
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "rat-king-parser"
|
|
@@ -34,10 +34,10 @@ classifiers = [
|
|
|
34
34
|
"Programming Language :: Python :: 3.12",
|
|
35
35
|
"Programming Language :: Python :: 3.13",
|
|
36
36
|
]
|
|
37
|
-
dynamic = [
|
|
38
|
-
dependencies = [
|
|
39
|
-
optional-dependencies.dev = [
|
|
40
|
-
optional-dependencies.maco = [
|
|
37
|
+
dynamic = ["version"]
|
|
38
|
+
dependencies = ["dnfile", "pycryptodomex", "yara-python"]
|
|
39
|
+
optional-dependencies.dev = ["pre-commit", "pytest"]
|
|
40
|
+
optional-dependencies.maco = ["maco", "validators"]
|
|
41
41
|
urls."Bug Reports" = "https://github.com/jeFF0Falltrades/rat_king_parser/issues"
|
|
42
42
|
urls."Homepage" = "https://github.com/jeFF0Falltrades/rat_king_parser"
|
|
43
43
|
urls."Say Thanks!" = "https://www.buymeacoffee.com/jeff0falltrades"
|
|
@@ -47,15 +47,15 @@ scripts.rat-king-parser = "rat_king_parser:main"
|
|
|
47
47
|
version = { attr = "rat_king_parser._version.__version__" }
|
|
48
48
|
|
|
49
49
|
[tool.setuptools.packages.find]
|
|
50
|
-
where = [
|
|
51
|
-
include = [
|
|
50
|
+
where = ["src"]
|
|
51
|
+
include = ["rat_king_parser*"]
|
|
52
52
|
namespaces = false
|
|
53
53
|
|
|
54
54
|
[tool.setuptools.package-data]
|
|
55
|
-
"rat_king_parser.yara_utils" = [
|
|
55
|
+
"rat_king_parser.yara_utils" = ["*.yar", "*.yarc"]
|
|
56
56
|
|
|
57
57
|
[tool.ruff]
|
|
58
|
-
lint.extend-select = [
|
|
58
|
+
lint.extend-select = ["I"]
|
|
59
59
|
|
|
60
60
|
[tool.pre-commit]
|
|
61
61
|
hook-config = "file:.pre-commit-config.yaml"
|
|
@@ -92,11 +92,13 @@ class RATConfigParser:
|
|
|
92
92
|
# Assigned in _decrypt_and_decode_config()
|
|
93
93
|
self._decryptor: ConfigDecryptor = None
|
|
94
94
|
self.report["config"] = self._get_config()
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
if self._decryptor
|
|
98
|
-
|
|
99
|
-
|
|
95
|
+
key_hex = "None"
|
|
96
|
+
if self._decryptor is not None and self._decryptor.key is not None:
|
|
97
|
+
if isinstance(self._decryptor.key, bytes):
|
|
98
|
+
key_hex = self._decryptor.key.hex()
|
|
99
|
+
else:
|
|
100
|
+
key_hex = str(self._decryptor.key)
|
|
101
|
+
self.report["key"] = key_hex
|
|
100
102
|
self.report["salt"] = (
|
|
101
103
|
self._decryptor.salt.hex()
|
|
102
104
|
if self._decryptor is not None and self._decryptor.salt is not None
|
|
@@ -122,7 +124,7 @@ class RATConfigParser:
|
|
|
122
124
|
config_fields_map[k] = field_name
|
|
123
125
|
item_data[field_name] = v
|
|
124
126
|
if len(item_data) > 0:
|
|
125
|
-
if
|
|
127
|
+
if isinstance(item, config_item.EncryptedStringConfigItem):
|
|
126
128
|
# Translate config value RVAs to string values
|
|
127
129
|
for k in item_data:
|
|
128
130
|
item_data[k] = self._dnpp.user_string_from_rva(item_data[k])
|
|
@@ -159,7 +161,7 @@ class RATConfigParser:
|
|
|
159
161
|
if self._decryptor is None:
|
|
160
162
|
raise ConfigParserException("All decryptors failed")
|
|
161
163
|
|
|
162
|
-
elif
|
|
164
|
+
elif isinstance(item, config_item.ByteArrayConfigItem):
|
|
163
165
|
for k in item_data:
|
|
164
166
|
arr_size, arr_rva = item_data[k]
|
|
165
167
|
item_data[k] = self._dnpp.byte_array_from_size_and_rva(
|
|
@@ -168,7 +170,7 @@ class RATConfigParser:
|
|
|
168
170
|
|
|
169
171
|
decoded_config.update(item_data)
|
|
170
172
|
# UrlHost is a marker of a special case until this can be standardized
|
|
171
|
-
if len(decoded_config) < min_config_len and "UrlHost" not in
|
|
173
|
+
if len(decoded_config) < min_config_len and "UrlHost" not in decoded_config:
|
|
172
174
|
raise ConfigParserException(
|
|
173
175
|
f"Minimum threshold of config items not met: {len(decoded_config)}/{min_config_len}"
|
|
174
176
|
)
|
|
@@ -31,11 +31,11 @@ from ..config_parser_exception import ConfigParserException
|
|
|
31
31
|
|
|
32
32
|
|
|
33
33
|
# Converts a bytes object to an int object using the specified byte order
|
|
34
|
-
def bytes_to_int(
|
|
34
|
+
def bytes_to_int(data: bytes, order: str = "little") -> int:
|
|
35
35
|
try:
|
|
36
|
-
return int.from_bytes(
|
|
36
|
+
return int.from_bytes(data, byteorder=order)
|
|
37
37
|
except Exception:
|
|
38
|
-
raise ConfigParserException(f"Error parsing int from value: {
|
|
38
|
+
raise ConfigParserException(f"Error parsing int from value: {data}")
|
|
39
39
|
|
|
40
40
|
|
|
41
41
|
# Decodes a bytes object to a Unicode string, using UTF-16LE for byte values
|
|
@@ -57,8 +57,8 @@ def decode_bytes(byte_str: bytes | str) -> str:
|
|
|
57
57
|
|
|
58
58
|
|
|
59
59
|
# Converts an int to a bytes object, with the specified length and order
|
|
60
|
-
def int_to_bytes(
|
|
60
|
+
def int_to_bytes(value: int, length: int = 4, order: str = "little") -> bytes:
|
|
61
61
|
try:
|
|
62
|
-
return
|
|
62
|
+
return value.to_bytes(length, order)
|
|
63
63
|
except Exception:
|
|
64
|
-
raise ConfigParserException(f"Error parsing bytes from value: {
|
|
64
|
+
raise ConfigParserException(f"Error parsing bytes from value: {value}")
|
|
@@ -79,9 +79,9 @@ class ConfigDecryptorRandomHardcoded(ConfigDecryptor):
|
|
|
79
79
|
hardcoded_hosts = []
|
|
80
80
|
for rva in hardcoded_host_rvas:
|
|
81
81
|
try:
|
|
82
|
-
|
|
83
|
-
if
|
|
84
|
-
hardcoded_hosts.append(
|
|
82
|
+
extracted_hosts = self._payload.user_string_from_rva(bytes_to_int(rva))
|
|
83
|
+
if extracted_hosts != ".":
|
|
84
|
+
hardcoded_hosts.append(extracted_hosts)
|
|
85
85
|
except Exception as e:
|
|
86
86
|
logger.error(f"Error translating hardcoded host at {hex(rva)}: {e}")
|
|
87
87
|
continue
|
|
@@ -102,7 +102,6 @@ class ConfigDecryptorRijndael(ConfigDecryptor):
|
|
|
102
102
|
logger.debug("Decrypting encrypted strings...")
|
|
103
103
|
if not self.key:
|
|
104
104
|
try:
|
|
105
|
-
#
|
|
106
105
|
raw_key_field = self._payload.field_name_from_rva(self._key_rva)
|
|
107
106
|
if raw_key_field in encrypted_strings:
|
|
108
107
|
key = encrypted_strings[raw_key_field]
|
|
@@ -110,11 +109,15 @@ class ConfigDecryptorRijndael(ConfigDecryptor):
|
|
|
110
109
|
else:
|
|
111
110
|
for key_pattern in self._KEY_PATTERNS:
|
|
112
111
|
key_hit = search(key_pattern, self._payload.data)
|
|
112
|
+
if not key_hit:
|
|
113
|
+
continue
|
|
113
114
|
key_rva = bytes_to_int(key_hit.groups()[0])
|
|
114
115
|
raw_key_field = self._payload.field_name_from_rva(key_rva)
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
116
|
+
if raw_key_field in encrypted_strings:
|
|
117
|
+
key = encrypted_strings[raw_key_field]
|
|
118
|
+
self.key = self._derive_key(key)
|
|
119
|
+
break
|
|
120
|
+
|
|
118
121
|
except Exception as e:
|
|
119
122
|
raise ConfigParserException(f"Failed to derive AES key: {e}")
|
|
120
123
|
|
|
@@ -234,6 +234,13 @@ class DotNetPEPayload:
|
|
|
234
234
|
"""
|
|
235
235
|
config = {}
|
|
236
236
|
try:
|
|
237
|
+
ca_map = {}
|
|
238
|
+
for ca in self.dotnetpe.net.mdtables.CustomAttribute.rows:
|
|
239
|
+
idx = ca.Parent.row_index
|
|
240
|
+
if idx not in ca_map:
|
|
241
|
+
ca_map[idx] = []
|
|
242
|
+
ca_map[idx].append(ca)
|
|
243
|
+
|
|
237
244
|
for td in self.dotnetpe.net.mdtables.TypeDef.rows:
|
|
238
245
|
if (
|
|
239
246
|
td.TypeNamespace.value != typespacename
|
|
@@ -253,10 +260,10 @@ class DotNetPEPayload:
|
|
|
253
260
|
"String_",
|
|
254
261
|
):
|
|
255
262
|
continue
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
263
|
+
# CustomAttribute Parent index is 1-based
|
|
264
|
+
target_index = pd_row_index + 1
|
|
265
|
+
if target_index in ca_map:
|
|
266
|
+
for ca in ca_map[target_index]:
|
|
260
267
|
# Extract the value from the CustomAttribute blob
|
|
261
268
|
blob_data = ca.Value.value
|
|
262
269
|
if blob_data and blob_data != b"\x01\x00\x00\x00":
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: rat-king-parser
|
|
3
|
-
Version: 4.2.
|
|
3
|
+
Version: 4.2.2
|
|
4
4
|
Summary: A robust, multiprocessing-capable, multi-family RAT config parser/config extractor for AsyncRAT, DcRAT, VenomRAT, QuasarRAT, XWorm, Xeno RAT, and cloned/derivative RAT families.
|
|
5
5
|
Author-email: jeFF0Falltrades <8444166+jeFF0Falltrades@users.noreply.github.com>
|
|
6
6
|
Maintainer-email: jeFF0Falltrades <8444166+jeFF0Falltrades@users.noreply.github.com>
|
|
@@ -31,6 +31,7 @@ Requires-Dist: pycryptodomex
|
|
|
31
31
|
Requires-Dist: yara-python
|
|
32
32
|
Provides-Extra: dev
|
|
33
33
|
Requires-Dist: pre-commit; extra == "dev"
|
|
34
|
+
Requires-Dist: pytest; extra == "dev"
|
|
34
35
|
Provides-Extra: maco
|
|
35
36
|
Requires-Dist: maco; extra == "maco"
|
|
36
37
|
Requires-Dist: validators; extra == "maco"
|
|
@@ -34,4 +34,5 @@ src/rat_king_parser/extern/maco/rkp_maco.py
|
|
|
34
34
|
src/rat_king_parser/yara_utils/__init__.py
|
|
35
35
|
src/rat_king_parser/yara_utils/recompile.py
|
|
36
36
|
src/rat_king_parser/yara_utils/rules.yar
|
|
37
|
-
src/rat_king_parser/yara_utils/rules.yarc
|
|
37
|
+
src/rat_king_parser/yara_utils/rules.yarc
|
|
38
|
+
tests/test_known_samples.py
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
#
|
|
3
|
+
# test_known_samples.py
|
|
4
|
+
#
|
|
5
|
+
# Author: jeFF0Falltrades
|
|
6
|
+
#
|
|
7
|
+
# Test runner for CI job against known samples (only available in main repo)
|
|
8
|
+
#
|
|
9
|
+
# MIT License
|
|
10
|
+
#
|
|
11
|
+
# Copyright (c) 2026 Jeff Archer
|
|
12
|
+
#
|
|
13
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
14
|
+
# of this software and associated documentation files (the "Software"), to deal
|
|
15
|
+
# in the Software without restriction, including without limitation the rights
|
|
16
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
17
|
+
# copies of the Software, and to permit persons to whom the Software is
|
|
18
|
+
# furnished to do so, subject to the following conditions:
|
|
19
|
+
#
|
|
20
|
+
# The above copyright notice and this permission notice shall be included in all
|
|
21
|
+
# copies or substantial portions of the Software.
|
|
22
|
+
#
|
|
23
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
24
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
25
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
26
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
27
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
28
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
29
|
+
# SOFTWARE.
|
|
30
|
+
import json
|
|
31
|
+
import subprocess
|
|
32
|
+
from pathlib import Path
|
|
33
|
+
|
|
34
|
+
import pytest
|
|
35
|
+
|
|
36
|
+
SAMPLES_DIR = Path("tests/samples")
|
|
37
|
+
EXPECTED_DIR = Path("tests/expected")
|
|
38
|
+
|
|
39
|
+
# Fields that are allowed to exist in parser output
|
|
40
|
+
ALLOWED_FIELDS = {
|
|
41
|
+
"sha256",
|
|
42
|
+
"yara_possible_family",
|
|
43
|
+
"key",
|
|
44
|
+
"salt",
|
|
45
|
+
"config",
|
|
46
|
+
"file_path",
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def normalize_output(data: dict) -> dict:
|
|
51
|
+
"""
|
|
52
|
+
Strip non-deterministic or environment-specific fields
|
|
53
|
+
"""
|
|
54
|
+
return {
|
|
55
|
+
"sha256": data.get("sha256"),
|
|
56
|
+
"yara_possible_family": data.get("yara_possible_family"),
|
|
57
|
+
"key": data.get("key"),
|
|
58
|
+
"salt": data.get("salt"),
|
|
59
|
+
"config": data.get("config"),
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
@pytest.mark.skipif(
|
|
64
|
+
not SAMPLES_DIR.exists(),
|
|
65
|
+
reason="Malware samples not available (is this a fork PR?)",
|
|
66
|
+
)
|
|
67
|
+
@pytest.mark.parametrize(
|
|
68
|
+
"expected_file",
|
|
69
|
+
sorted(EXPECTED_DIR.glob("*.json")),
|
|
70
|
+
ids=lambda p: p.stem,
|
|
71
|
+
)
|
|
72
|
+
def test_parser_against_known_samples(expected_file):
|
|
73
|
+
with expected_file.open("r", encoding="utf-8") as f:
|
|
74
|
+
expected = json.load(f)
|
|
75
|
+
|
|
76
|
+
assert isinstance(expected, dict), "Expected output must be a JSON object"
|
|
77
|
+
assert "sha256" in expected, "Expected output missing sha256"
|
|
78
|
+
|
|
79
|
+
sha = expected["sha256"]
|
|
80
|
+
|
|
81
|
+
sample_path = next((p for p in SAMPLES_DIR.iterdir() if p.is_file() and p.name.startswith(sha)), None)
|
|
82
|
+
|
|
83
|
+
assert sample_path is not None, f"No sample file found for SHA {sha}"
|
|
84
|
+
|
|
85
|
+
proc = subprocess.run(
|
|
86
|
+
["rat-king-parser", str(sample_path)],
|
|
87
|
+
capture_output=True,
|
|
88
|
+
text=True,
|
|
89
|
+
check=True,
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
try:
|
|
93
|
+
parsed = json.loads(proc.stdout)
|
|
94
|
+
except json.JSONDecodeError:
|
|
95
|
+
pytest.fail(
|
|
96
|
+
"Parser did not emit valid JSON.\n"
|
|
97
|
+
f"STDOUT:\n{proc.stdout}\n\nSTDERR:\n{proc.stderr}"
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
assert isinstance(parsed, list), "Parser output must be a JSON array"
|
|
101
|
+
assert len(parsed) > 0, "Parser output array is empty"
|
|
102
|
+
|
|
103
|
+
parsed = parsed[0]
|
|
104
|
+
|
|
105
|
+
assert isinstance(parsed, dict), "Parser result must be a JSON object"
|
|
106
|
+
assert parsed.get("sha256") == sha, "SHA256 mismatch in parser output"
|
|
107
|
+
assert isinstance(parsed.get("config"), dict), "config must be a dictionary"
|
|
108
|
+
|
|
109
|
+
unexpected_fields = set(parsed.keys()) - ALLOWED_FIELDS
|
|
110
|
+
assert not unexpected_fields, f"Unexpected output fields: {unexpected_fields}"
|
|
111
|
+
|
|
112
|
+
normalized_actual = normalize_output(parsed)
|
|
113
|
+
normalized_expected = normalize_output(expected)
|
|
114
|
+
|
|
115
|
+
assert normalized_actual == normalized_expected
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{rat_king_parser-4.2.1 → rat_king_parser-4.2.2}/src/rat_king_parser/config_parser/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{rat_king_parser-4.2.1 → rat_king_parser-4.2.2}/src/rat_king_parser/config_parser/utils/__init__.py
RENAMED
|
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
|
{rat_king_parser-4.2.1 → rat_king_parser-4.2.2}/src/rat_king_parser.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
{rat_king_parser-4.2.1 → rat_king_parser-4.2.2}/src/rat_king_parser.egg-info/entry_points.txt
RENAMED
|
File without changes
|
|
File without changes
|