rat-king-parser 3.2.3__tar.gz → 3.3.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.
- {rat_king_parser-3.2.3/src/rat_king_parser.egg-info → rat_king_parser-3.3.0}/PKG-INFO +1 -1
- {rat_king_parser-3.2.3 → rat_king_parser-3.3.0}/src/rat_king_parser/_version.py +1 -1
- {rat_king_parser-3.2.3 → rat_king_parser-3.3.0}/src/rat_king_parser/config_parser/rat_config_parser.py +22 -6
- {rat_king_parser-3.2.3 → rat_king_parser-3.3.0}/src/rat_king_parser/config_parser/utils/decryptors/config_decryptor_aes_with_iv.py +7 -5
- {rat_king_parser-3.2.3 → rat_king_parser-3.3.0}/src/rat_king_parser/config_parser/utils/decryptors/config_decryptor_plaintext.py +2 -0
- {rat_king_parser-3.2.3 → rat_king_parser-3.3.0}/src/rat_king_parser/config_parser/utils/dotnetpe_payload.py +3 -1
- {rat_king_parser-3.2.3 → rat_king_parser-3.3.0}/src/rat_king_parser/extern/maco/rkp_maco.py +3 -7
- {rat_king_parser-3.2.3 → rat_king_parser-3.3.0/src/rat_king_parser.egg-info}/PKG-INFO +1 -1
- {rat_king_parser-3.2.3 → rat_king_parser-3.3.0}/LICENSE +0 -0
- {rat_king_parser-3.2.3 → rat_king_parser-3.3.0}/README.md +0 -0
- {rat_king_parser-3.2.3 → rat_king_parser-3.3.0}/pyproject.toml +0 -0
- {rat_king_parser-3.2.3 → rat_king_parser-3.3.0}/setup.cfg +0 -0
- {rat_king_parser-3.2.3 → rat_king_parser-3.3.0}/src/rat_king_parser/__init__.py +0 -0
- {rat_king_parser-3.2.3 → rat_king_parser-3.3.0}/src/rat_king_parser/config_parser/__init__.py +0 -0
- {rat_king_parser-3.2.3 → rat_king_parser-3.3.0}/src/rat_king_parser/config_parser/config_parser_exception.py +0 -0
- {rat_king_parser-3.2.3 → rat_king_parser-3.3.0}/src/rat_king_parser/config_parser/utils/__init__.py +0 -0
- {rat_king_parser-3.2.3 → rat_king_parser-3.3.0}/src/rat_king_parser/config_parser/utils/config_item.py +0 -0
- {rat_king_parser-3.2.3 → rat_king_parser-3.3.0}/src/rat_king_parser/config_parser/utils/data_utils.py +0 -0
- {rat_king_parser-3.2.3 → rat_king_parser-3.3.0}/src/rat_king_parser/config_parser/utils/decryptors/__init__.py +0 -0
- {rat_king_parser-3.2.3 → rat_king_parser-3.3.0}/src/rat_king_parser/config_parser/utils/decryptors/config_decryptor.py +0 -0
- {rat_king_parser-3.2.3 → rat_king_parser-3.3.0}/src/rat_king_parser/config_parser/utils/decryptors/config_decryptor_aes_ecb.py +0 -0
- {rat_king_parser-3.2.3 → rat_king_parser-3.3.0}/src/rat_king_parser/config_parser/utils/decryptors/config_decryptor_decrypt_xor.py +0 -0
- {rat_king_parser-3.2.3 → rat_king_parser-3.3.0}/src/rat_king_parser/config_parser/utils/decryptors/config_decryptor_random_hardcoded.py +0 -0
- {rat_king_parser-3.2.3 → rat_king_parser-3.3.0}/src/rat_king_parser/config_parser/utils/dotnet_constants.py +0 -0
- {rat_king_parser-3.2.3 → rat_king_parser-3.3.0}/src/rat_king_parser/extern/__init__.py +0 -0
- {rat_king_parser-3.2.3 → rat_king_parser-3.3.0}/src/rat_king_parser/extern/maco/__init__.py +0 -0
- {rat_king_parser-3.2.3 → rat_king_parser-3.3.0}/src/rat_king_parser/rkp.py +0 -0
- {rat_king_parser-3.2.3 → rat_king_parser-3.3.0}/src/rat_king_parser/yara_utils/__init__.py +0 -0
- {rat_king_parser-3.2.3 → rat_king_parser-3.3.0}/src/rat_king_parser/yara_utils/recompile.py +0 -0
- {rat_king_parser-3.2.3 → rat_king_parser-3.3.0}/src/rat_king_parser/yara_utils/rules.yar +0 -0
- {rat_king_parser-3.2.3 → rat_king_parser-3.3.0}/src/rat_king_parser/yara_utils/rules.yarc +0 -0
- {rat_king_parser-3.2.3 → rat_king_parser-3.3.0}/src/rat_king_parser.egg-info/SOURCES.txt +0 -0
- {rat_king_parser-3.2.3 → rat_king_parser-3.3.0}/src/rat_king_parser.egg-info/dependency_links.txt +0 -0
- {rat_king_parser-3.2.3 → rat_king_parser-3.3.0}/src/rat_king_parser.egg-info/entry_points.txt +0 -0
- {rat_king_parser-3.2.3 → rat_king_parser-3.3.0}/src/rat_king_parser.egg-info/requires.txt +0 -0
- {rat_king_parser-3.2.3 → rat_king_parser-3.3.0}/src/rat_king_parser.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: rat-king-parser
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.3.0
|
|
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>
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
28
28
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
29
29
|
# SOFTWARE.
|
|
30
|
+
from collections import OrderedDict
|
|
30
31
|
from logging import getLogger
|
|
31
32
|
from os.path import isfile
|
|
32
33
|
from re import DOTALL, compile, search
|
|
@@ -56,7 +57,13 @@ class RATConfigParser:
|
|
|
56
57
|
rb"\x7e.{3}\x04(?:\x6f.{3}\x0a){2}\x74.{3}\x01", DOTALL
|
|
57
58
|
)
|
|
58
59
|
|
|
59
|
-
def __init__(
|
|
60
|
+
def __init__(
|
|
61
|
+
self,
|
|
62
|
+
file_path: str = "",
|
|
63
|
+
yara_rule: Rules = None,
|
|
64
|
+
data: bytes = None,
|
|
65
|
+
remap_config: bool = False,
|
|
66
|
+
) -> None:
|
|
60
67
|
self.report = {
|
|
61
68
|
"file_path": file_path,
|
|
62
69
|
"sha256": "",
|
|
@@ -65,8 +72,8 @@ class RATConfigParser:
|
|
|
65
72
|
"salt": "",
|
|
66
73
|
"config": {},
|
|
67
74
|
}
|
|
75
|
+
self.remap_config = remap_config
|
|
68
76
|
try:
|
|
69
|
-
|
|
70
77
|
if not data and not isfile(file_path):
|
|
71
78
|
raise ConfigParserException("File not found")
|
|
72
79
|
# Filled in _decrypt_and_decode_config()
|
|
@@ -103,11 +110,14 @@ class RATConfigParser:
|
|
|
103
110
|
|
|
104
111
|
for item_class in config_item.SUPPORTED_CONFIG_ITEMS:
|
|
105
112
|
item = item_class()
|
|
113
|
+
config_fields_map = {}
|
|
114
|
+
# Translate config Field RVAs to Field names
|
|
115
|
+
item_data = {}
|
|
106
116
|
# Translate config Field RVAs to Field names
|
|
107
|
-
|
|
108
|
-
self._dnpp.field_name_from_rva(k)
|
|
109
|
-
|
|
110
|
-
|
|
117
|
+
for k, v in item.parse_from(encrypted_config).items():
|
|
118
|
+
field_name = self._dnpp.field_name_from_rva(k)
|
|
119
|
+
config_fields_map[k] = field_name
|
|
120
|
+
item_data[field_name] = v
|
|
111
121
|
|
|
112
122
|
if len(item_data) > 0:
|
|
113
123
|
if type(item) is config_item.EncryptedStringConfigItem:
|
|
@@ -160,6 +170,12 @@ class RATConfigParser:
|
|
|
160
170
|
raise ConfigParserException(
|
|
161
171
|
f"Minimum threshold of config items not met: {len(decoded_config)}/{min_config_len}"
|
|
162
172
|
)
|
|
173
|
+
if self.remap_config:
|
|
174
|
+
sorted_decoded_config = OrderedDict()
|
|
175
|
+
for k in sorted(config_fields_map.keys()):
|
|
176
|
+
key_name = config_fields_map[k]
|
|
177
|
+
sorted_decoded_config[key_name] = decoded_config[key_name]
|
|
178
|
+
return sorted_decoded_config
|
|
163
179
|
return decoded_config
|
|
164
180
|
|
|
165
181
|
# Searches for the RAT configuration section, using the VerifyHash() marker
|
|
@@ -60,13 +60,15 @@ class ConfigDecryptorAESWithIV(ConfigDecryptor):
|
|
|
60
60
|
# Minimum length of valid ciphertext
|
|
61
61
|
_MIN_CIPHERTEXT_LEN = 48
|
|
62
62
|
_ALGO_MAP = {
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
b"\x17": CBC,
|
|
64
|
+
# b"\x18": ECB,
|
|
65
|
+
# b"\x19": OFB,
|
|
66
|
+
b"\x1a": CFB8,
|
|
65
67
|
}
|
|
66
68
|
|
|
67
69
|
# Patterns for identifying AES metadata
|
|
68
70
|
_PATTERN_AES_KEY_AND_BLOCK_SIZE_AND_ALGO = re.compile(
|
|
69
|
-
|
|
71
|
+
rb"[\x06-\x09]\x20(.{4})\x6f.{4}[\x06-\x09]\x20(.{4})\x6f.{4}[\x06-\x09](.)\x6f.{4}|\x11\x01\x20(.{4})\x28.{4}\x11\x01\x20(.{4})\x6f.{4}\x11\x01(.)\x6f.{4}",
|
|
70
72
|
re.DOTALL,
|
|
71
73
|
)
|
|
72
74
|
# Do not re.compile in-line replacement patterns
|
|
@@ -220,14 +222,14 @@ class ConfigDecryptorAESWithIV(ConfigDecryptor):
|
|
|
220
222
|
hit = re.search(
|
|
221
223
|
self._PATTERN_AES_KEY_AND_BLOCK_SIZE_AND_ALGO, self._payload.data
|
|
222
224
|
)
|
|
223
|
-
if hit
|
|
225
|
+
if not hit:
|
|
224
226
|
raise ConfigParserException("Could not extract AES key or block size")
|
|
225
227
|
|
|
226
228
|
# Convert key size from bits to bytes by dividing by 8
|
|
227
229
|
# Note use of // instead of / to ensure integer output, not float
|
|
228
230
|
key_size = bytes_to_int(hit.groups()[0]) // 8
|
|
229
231
|
block_size = bytes_to_int(hit.groups()[1])
|
|
230
|
-
algo_id =
|
|
232
|
+
algo_id = hit.groups()[2]
|
|
231
233
|
if algo_id not in self._ALGO_MAP:
|
|
232
234
|
raise ConfigParserException("Could not extract AES algorithm ID byte")
|
|
233
235
|
algo = self._ALGO_MAP[algo_id]
|
|
@@ -45,6 +45,7 @@ KNOWN_CONFIG_FIELD_NAMES = set(
|
|
|
45
45
|
"Anti_Process",
|
|
46
46
|
"BDOS",
|
|
47
47
|
"BS_OD",
|
|
48
|
+
"ClientFullPath",
|
|
48
49
|
"Certifi_cate",
|
|
49
50
|
"Certificate",
|
|
50
51
|
"DIRECTORY",
|
|
@@ -55,6 +56,7 @@ KNOWN_CONFIG_FIELD_NAMES = set(
|
|
|
55
56
|
"EncryptionKey",
|
|
56
57
|
"Groub",
|
|
57
58
|
"Group",
|
|
59
|
+
"GroupTag",
|
|
58
60
|
"HIDEFILE",
|
|
59
61
|
"HIDEINSTALLSUBDIRECTORY",
|
|
60
62
|
"HIDELOGDIRECTORY",
|
|
@@ -53,7 +53,9 @@ class DotNetPEMethod:
|
|
|
53
53
|
|
|
54
54
|
|
|
55
55
|
class DotNetPEPayload:
|
|
56
|
-
def __init__(
|
|
56
|
+
def __init__(
|
|
57
|
+
self, file_path: str, yara_rule: Rules = None, data: bytes = None
|
|
58
|
+
) -> None:
|
|
57
59
|
self.file_path = file_path
|
|
58
60
|
self.data = data
|
|
59
61
|
if not self.data:
|
|
@@ -30,7 +30,6 @@ from enum import Enum, auto
|
|
|
30
30
|
from logging import getLogger
|
|
31
31
|
from pathlib import Path
|
|
32
32
|
from re import search
|
|
33
|
-
from tempfile import NamedTemporaryFile
|
|
34
33
|
from typing import Optional
|
|
35
34
|
|
|
36
35
|
import validators
|
|
@@ -77,12 +76,9 @@ class RKPMACO(extractor.Extractor):
|
|
|
77
76
|
def run(
|
|
78
77
|
self, stream: typing.BinaryIO, matches: typing.List[Match]
|
|
79
78
|
) -> typing.Optional[model.ExtractorModel]:
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
report = RATConfigParser(
|
|
84
|
-
fh.name, load(str(Path(__file__).parent / YARC_PATH))
|
|
85
|
-
).report
|
|
79
|
+
report = RATConfigParser(
|
|
80
|
+
load(str(Path(__file__).parent / YARC_PATH)), data=stream.read()
|
|
81
|
+
).report
|
|
86
82
|
|
|
87
83
|
# Check if exception occurred within RKP parsing
|
|
88
84
|
if isinstance(report["config"], str) and report["config"].startswith(
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: rat-king-parser
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.3.0
|
|
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>
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{rat_king_parser-3.2.3 → rat_king_parser-3.3.0}/src/rat_king_parser/config_parser/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{rat_king_parser-3.2.3 → rat_king_parser-3.3.0}/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
|
{rat_king_parser-3.2.3 → rat_king_parser-3.3.0}/src/rat_king_parser.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
{rat_king_parser-3.2.3 → rat_king_parser-3.3.0}/src/rat_king_parser.egg-info/entry_points.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|