rat-king-parser 3.2.2__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.2/src/rat_king_parser.egg-info → rat_king_parser-3.3.0}/PKG-INFO +1 -1
- {rat_king_parser-3.2.2 → rat_king_parser-3.3.0}/src/rat_king_parser/_version.py +1 -1
- {rat_king_parser-3.2.2 → rat_king_parser-3.3.0}/src/rat_king_parser/config_parser/rat_config_parser.py +24 -7
- {rat_king_parser-3.2.2 → 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.2 → 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.2 → rat_king_parser-3.3.0}/src/rat_king_parser/config_parser/utils/dotnetpe_payload.py +12 -5
- {rat_king_parser-3.2.2 → rat_king_parser-3.3.0}/src/rat_king_parser/extern/maco/rkp_maco.py +3 -7
- {rat_king_parser-3.2.2 → rat_king_parser-3.3.0/src/rat_king_parser.egg-info}/PKG-INFO +1 -1
- {rat_king_parser-3.2.2 → rat_king_parser-3.3.0}/LICENSE +0 -0
- {rat_king_parser-3.2.2 → rat_king_parser-3.3.0}/README.md +0 -0
- {rat_king_parser-3.2.2 → rat_king_parser-3.3.0}/pyproject.toml +0 -0
- {rat_king_parser-3.2.2 → rat_king_parser-3.3.0}/setup.cfg +0 -0
- {rat_king_parser-3.2.2 → rat_king_parser-3.3.0}/src/rat_king_parser/__init__.py +0 -0
- {rat_king_parser-3.2.2 → rat_king_parser-3.3.0}/src/rat_king_parser/config_parser/__init__.py +0 -0
- {rat_king_parser-3.2.2 → rat_king_parser-3.3.0}/src/rat_king_parser/config_parser/config_parser_exception.py +0 -0
- {rat_king_parser-3.2.2 → rat_king_parser-3.3.0}/src/rat_king_parser/config_parser/utils/__init__.py +0 -0
- {rat_king_parser-3.2.2 → rat_king_parser-3.3.0}/src/rat_king_parser/config_parser/utils/config_item.py +0 -0
- {rat_king_parser-3.2.2 → rat_king_parser-3.3.0}/src/rat_king_parser/config_parser/utils/data_utils.py +0 -0
- {rat_king_parser-3.2.2 → rat_king_parser-3.3.0}/src/rat_king_parser/config_parser/utils/decryptors/__init__.py +0 -0
- {rat_king_parser-3.2.2 → rat_king_parser-3.3.0}/src/rat_king_parser/config_parser/utils/decryptors/config_decryptor.py +0 -0
- {rat_king_parser-3.2.2 → 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.2 → 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.2 → 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.2 → rat_king_parser-3.3.0}/src/rat_king_parser/config_parser/utils/dotnet_constants.py +0 -0
- {rat_king_parser-3.2.2 → rat_king_parser-3.3.0}/src/rat_king_parser/extern/__init__.py +0 -0
- {rat_king_parser-3.2.2 → rat_king_parser-3.3.0}/src/rat_king_parser/extern/maco/__init__.py +0 -0
- {rat_king_parser-3.2.2 → rat_king_parser-3.3.0}/src/rat_king_parser/rkp.py +0 -0
- {rat_king_parser-3.2.2 → rat_king_parser-3.3.0}/src/rat_king_parser/yara_utils/__init__.py +0 -0
- {rat_king_parser-3.2.2 → rat_king_parser-3.3.0}/src/rat_king_parser/yara_utils/recompile.py +0 -0
- {rat_king_parser-3.2.2 → rat_king_parser-3.3.0}/src/rat_king_parser/yara_utils/rules.yar +0 -0
- {rat_king_parser-3.2.2 → rat_king_parser-3.3.0}/src/rat_king_parser/yara_utils/rules.yarc +0 -0
- {rat_king_parser-3.2.2 → rat_king_parser-3.3.0}/src/rat_king_parser.egg-info/SOURCES.txt +0 -0
- {rat_king_parser-3.2.2 → rat_king_parser-3.3.0}/src/rat_king_parser.egg-info/dependency_links.txt +0 -0
- {rat_king_parser-3.2.2 → rat_king_parser-3.3.0}/src/rat_king_parser.egg-info/entry_points.txt +0 -0
- {rat_king_parser-3.2.2 → rat_king_parser-3.3.0}/src/rat_king_parser.egg-info/requires.txt +0 -0
- {rat_king_parser-3.2.2 → 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,13 +72,14 @@ class RATConfigParser:
|
|
|
65
72
|
"salt": "",
|
|
66
73
|
"config": {},
|
|
67
74
|
}
|
|
75
|
+
self.remap_config = remap_config
|
|
68
76
|
try:
|
|
69
|
-
if not isfile(file_path):
|
|
77
|
+
if not data and not isfile(file_path):
|
|
70
78
|
raise ConfigParserException("File not found")
|
|
71
79
|
# Filled in _decrypt_and_decode_config()
|
|
72
80
|
self._incompatible_decryptors: list[int] = []
|
|
73
81
|
try:
|
|
74
|
-
self._dnpp = DotNetPEPayload(file_path, yara_rule)
|
|
82
|
+
self._dnpp = DotNetPEPayload(file_path, yara_rule, data)
|
|
75
83
|
except Exception as e:
|
|
76
84
|
raise e
|
|
77
85
|
self.report["sha256"] = self._dnpp.sha256
|
|
@@ -102,11 +110,14 @@ class RATConfigParser:
|
|
|
102
110
|
|
|
103
111
|
for item_class in config_item.SUPPORTED_CONFIG_ITEMS:
|
|
104
112
|
item = item_class()
|
|
113
|
+
config_fields_map = {}
|
|
105
114
|
# Translate config Field RVAs to Field names
|
|
106
|
-
item_data = {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
115
|
+
item_data = {}
|
|
116
|
+
# Translate config Field RVAs to Field names
|
|
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
|
|
110
121
|
|
|
111
122
|
if len(item_data) > 0:
|
|
112
123
|
if type(item) is config_item.EncryptedStringConfigItem:
|
|
@@ -159,6 +170,12 @@ class RATConfigParser:
|
|
|
159
170
|
raise ConfigParserException(
|
|
160
171
|
f"Minimum threshold of config items not met: {len(decoded_config)}/{min_config_len}"
|
|
161
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
|
|
162
179
|
return decoded_config
|
|
163
180
|
|
|
164
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,9 +53,13 @@ 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
|
-
self.data =
|
|
60
|
+
self.data = data
|
|
61
|
+
if not self.data:
|
|
62
|
+
self.data = self._get_file_data()
|
|
59
63
|
|
|
60
64
|
# Calculate SHA256
|
|
61
65
|
sha256_obj = sha256()
|
|
@@ -64,7 +68,10 @@ class DotNetPEPayload:
|
|
|
64
68
|
|
|
65
69
|
self.dotnetpe: dnPE = None
|
|
66
70
|
try:
|
|
67
|
-
|
|
71
|
+
if self.data:
|
|
72
|
+
self.dotnetpe = dnPE(data=self.data, clr_lazy_load=True)
|
|
73
|
+
else:
|
|
74
|
+
self.dotnetpe = dnPE(self.file_path, clr_lazy_load=True)
|
|
68
75
|
except Exception:
|
|
69
76
|
raise ConfigParserException("Failed to load project as dotnet executable")
|
|
70
77
|
|
|
@@ -162,11 +169,11 @@ class DotNetPEPayload:
|
|
|
162
169
|
logger.debug(f"Successfully read {len(data)} bytes")
|
|
163
170
|
return data
|
|
164
171
|
|
|
165
|
-
# Tests a given YARA rule object against the file
|
|
172
|
+
# Tests a given YARA rule object against the file content,
|
|
166
173
|
# returning the matching rule's name, or "No match"
|
|
167
174
|
def _match_yara(self, rule: Rules) -> str:
|
|
168
175
|
try:
|
|
169
|
-
match = rule.match(self.
|
|
176
|
+
match = rule.match(data=self.data)
|
|
170
177
|
return str(match[0]) if len(match) > 0 else "No match"
|
|
171
178
|
except Exception as e:
|
|
172
179
|
logger.exception(e)
|
|
@@ -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.2 → 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.2 → 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.2 → rat_king_parser-3.3.0}/src/rat_king_parser.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
{rat_king_parser-3.2.2 → 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
|