rat-king-parser 3.1.7__tar.gz → 3.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-3.1.7/src/rat_king_parser.egg-info → rat_king_parser-3.2.2}/PKG-INFO +2 -2
- {rat_king_parser-3.1.7 → rat_king_parser-3.2.2}/README.md +1 -1
- {rat_king_parser-3.1.7 → rat_king_parser-3.2.2}/src/rat_king_parser/_version.py +1 -1
- {rat_king_parser-3.1.7 → rat_king_parser-3.2.2}/src/rat_king_parser/config_parser/utils/decryptors/__init__.py +3 -3
- rat_king_parser-3.1.7/src/rat_king_parser/config_parser/utils/decryptors/config_decryptor_aes_cbc.py → rat_king_parser-3.2.2/src/rat_king_parser/config_parser/utils/decryptors/config_decryptor_aes_with_iv.py +34 -14
- {rat_king_parser-3.1.7 → rat_king_parser-3.2.2/src/rat_king_parser.egg-info}/PKG-INFO +2 -2
- {rat_king_parser-3.1.7 → rat_king_parser-3.2.2}/src/rat_king_parser.egg-info/SOURCES.txt +1 -1
- {rat_king_parser-3.1.7 → rat_king_parser-3.2.2}/LICENSE +0 -0
- {rat_king_parser-3.1.7 → rat_king_parser-3.2.2}/pyproject.toml +0 -0
- {rat_king_parser-3.1.7 → rat_king_parser-3.2.2}/setup.cfg +0 -0
- {rat_king_parser-3.1.7 → rat_king_parser-3.2.2}/src/rat_king_parser/__init__.py +0 -0
- {rat_king_parser-3.1.7 → rat_king_parser-3.2.2}/src/rat_king_parser/config_parser/__init__.py +0 -0
- {rat_king_parser-3.1.7 → rat_king_parser-3.2.2}/src/rat_king_parser/config_parser/config_parser_exception.py +0 -0
- {rat_king_parser-3.1.7 → rat_king_parser-3.2.2}/src/rat_king_parser/config_parser/rat_config_parser.py +0 -0
- {rat_king_parser-3.1.7 → rat_king_parser-3.2.2}/src/rat_king_parser/config_parser/utils/__init__.py +0 -0
- {rat_king_parser-3.1.7 → rat_king_parser-3.2.2}/src/rat_king_parser/config_parser/utils/config_item.py +0 -0
- {rat_king_parser-3.1.7 → rat_king_parser-3.2.2}/src/rat_king_parser/config_parser/utils/data_utils.py +0 -0
- {rat_king_parser-3.1.7 → rat_king_parser-3.2.2}/src/rat_king_parser/config_parser/utils/decryptors/config_decryptor.py +0 -0
- {rat_king_parser-3.1.7 → rat_king_parser-3.2.2}/src/rat_king_parser/config_parser/utils/decryptors/config_decryptor_aes_ecb.py +0 -0
- {rat_king_parser-3.1.7 → rat_king_parser-3.2.2}/src/rat_king_parser/config_parser/utils/decryptors/config_decryptor_decrypt_xor.py +0 -0
- {rat_king_parser-3.1.7 → rat_king_parser-3.2.2}/src/rat_king_parser/config_parser/utils/decryptors/config_decryptor_plaintext.py +0 -0
- {rat_king_parser-3.1.7 → rat_king_parser-3.2.2}/src/rat_king_parser/config_parser/utils/decryptors/config_decryptor_random_hardcoded.py +0 -0
- {rat_king_parser-3.1.7 → rat_king_parser-3.2.2}/src/rat_king_parser/config_parser/utils/dotnet_constants.py +0 -0
- {rat_king_parser-3.1.7 → rat_king_parser-3.2.2}/src/rat_king_parser/config_parser/utils/dotnetpe_payload.py +0 -0
- {rat_king_parser-3.1.7 → rat_king_parser-3.2.2}/src/rat_king_parser/extern/__init__.py +0 -0
- {rat_king_parser-3.1.7 → rat_king_parser-3.2.2}/src/rat_king_parser/extern/maco/__init__.py +0 -0
- {rat_king_parser-3.1.7 → rat_king_parser-3.2.2}/src/rat_king_parser/extern/maco/rkp_maco.py +0 -0
- {rat_king_parser-3.1.7 → rat_king_parser-3.2.2}/src/rat_king_parser/rkp.py +0 -0
- {rat_king_parser-3.1.7 → rat_king_parser-3.2.2}/src/rat_king_parser/yara_utils/__init__.py +0 -0
- {rat_king_parser-3.1.7 → rat_king_parser-3.2.2}/src/rat_king_parser/yara_utils/recompile.py +0 -0
- {rat_king_parser-3.1.7 → rat_king_parser-3.2.2}/src/rat_king_parser/yara_utils/rules.yar +0 -0
- {rat_king_parser-3.1.7 → rat_king_parser-3.2.2}/src/rat_king_parser/yara_utils/rules.yarc +0 -0
- {rat_king_parser-3.1.7 → rat_king_parser-3.2.2}/src/rat_king_parser.egg-info/dependency_links.txt +0 -0
- {rat_king_parser-3.1.7 → rat_king_parser-3.2.2}/src/rat_king_parser.egg-info/entry_points.txt +0 -0
- {rat_king_parser-3.1.7 → rat_king_parser-3.2.2}/src/rat_king_parser.egg-info/requires.txt +0 -0
- {rat_king_parser-3.1.7 → rat_king_parser-3.2.2}/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.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>
|
|
@@ -495,7 +495,7 @@ Thank you!
|
|
|
495
495
|
## Contributions & Attribution
|
|
496
496
|
Huge thanks to the following contributors for their outstanding work:
|
|
497
497
|
|
|
498
|
-
- [doomedraven](https://github.com/doomedraven): For your help in integrating RKP into CAPEv2
|
|
498
|
+
- [doomedraven](https://github.com/doomedraven): For your help in integrating RKP into CAPEv2, as well as your continued contributions to the project and great feedback!
|
|
499
499
|
- [cccs-rs](https://github.com/cccs-rs): For your help in integrating RKP into AssemblyLine, as well as helping me wrap it to work with MACO
|
|
500
500
|
|
|
501
501
|
The logo for this project contains modifications of the following images:
|
|
@@ -460,7 +460,7 @@ Thank you!
|
|
|
460
460
|
## Contributions & Attribution
|
|
461
461
|
Huge thanks to the following contributors for their outstanding work:
|
|
462
462
|
|
|
463
|
-
- [doomedraven](https://github.com/doomedraven): For your help in integrating RKP into CAPEv2
|
|
463
|
+
- [doomedraven](https://github.com/doomedraven): For your help in integrating RKP into CAPEv2, as well as your continued contributions to the project and great feedback!
|
|
464
464
|
- [cccs-rs](https://github.com/cccs-rs): For your help in integrating RKP into AssemblyLine, as well as helping me wrap it to work with MACO
|
|
465
465
|
|
|
466
466
|
The logo for this project contains modifications of the following images:
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
25
25
|
# SOFTWARE.
|
|
26
26
|
from .config_decryptor import ConfigDecryptor, IncompatibleDecryptorException
|
|
27
|
-
from .config_decryptor_aes_cbc import ConfigDecryptorAESCBC
|
|
28
27
|
from .config_decryptor_aes_ecb import ConfigDecryptorAESECB
|
|
28
|
+
from .config_decryptor_aes_with_iv import ConfigDecryptorAESWithIV
|
|
29
29
|
from .config_decryptor_decrypt_xor import ConfigDecryptorDecryptXOR
|
|
30
30
|
from .config_decryptor_plaintext import ConfigDecryptorPlaintext
|
|
31
31
|
from .config_decryptor_random_hardcoded import ConfigDecryptorRandomHardcoded
|
|
@@ -33,7 +33,7 @@ from .config_decryptor_random_hardcoded import ConfigDecryptorRandomHardcoded
|
|
|
33
33
|
__all__ = [
|
|
34
34
|
ConfigDecryptor,
|
|
35
35
|
IncompatibleDecryptorException,
|
|
36
|
-
|
|
36
|
+
ConfigDecryptorAESWithIV,
|
|
37
37
|
ConfigDecryptorAESECB,
|
|
38
38
|
ConfigDecryptorDecryptXOR,
|
|
39
39
|
ConfigDecryptorRandomHardcoded,
|
|
@@ -42,7 +42,7 @@ __all__ = [
|
|
|
42
42
|
|
|
43
43
|
# ConfigDecryptorPlaintext should always be the last fallthrough case
|
|
44
44
|
SUPPORTED_DECRYPTORS = [
|
|
45
|
-
|
|
45
|
+
ConfigDecryptorAESWithIV,
|
|
46
46
|
ConfigDecryptorAESECB,
|
|
47
47
|
ConfigDecryptorDecryptXOR,
|
|
48
48
|
ConfigDecryptorRandomHardcoded,
|
|
@@ -31,13 +31,18 @@
|
|
|
31
31
|
# SOFTWARE.
|
|
32
32
|
import re
|
|
33
33
|
from base64 import b64decode
|
|
34
|
+
from contextlib import suppress
|
|
34
35
|
from logging import getLogger
|
|
35
36
|
from typing import Tuple
|
|
36
37
|
|
|
37
38
|
from cryptography.hazmat.backends import default_backend
|
|
38
39
|
from cryptography.hazmat.primitives.ciphers import Cipher
|
|
39
40
|
from cryptography.hazmat.primitives.ciphers.algorithms import AES
|
|
40
|
-
from cryptography.hazmat.primitives.ciphers.modes import
|
|
41
|
+
from cryptography.hazmat.primitives.ciphers.modes import (
|
|
42
|
+
CBC,
|
|
43
|
+
CFB8,
|
|
44
|
+
ModeWithInitializationVector,
|
|
45
|
+
)
|
|
41
46
|
from cryptography.hazmat.primitives.hashes import SHA1
|
|
42
47
|
from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC
|
|
43
48
|
from cryptography.hazmat.primitives.padding import PKCS7
|
|
@@ -51,13 +56,18 @@ from .config_decryptor import ConfigDecryptor, IncompatibleDecryptorException
|
|
|
51
56
|
logger = getLogger(__name__)
|
|
52
57
|
|
|
53
58
|
|
|
54
|
-
class
|
|
59
|
+
class ConfigDecryptorAESWithIV(ConfigDecryptor):
|
|
55
60
|
# Minimum length of valid ciphertext
|
|
56
61
|
_MIN_CIPHERTEXT_LEN = 48
|
|
62
|
+
_ALGO_MAP = {
|
|
63
|
+
23: CBC,
|
|
64
|
+
26: CFB8,
|
|
65
|
+
}
|
|
57
66
|
|
|
58
67
|
# Patterns for identifying AES metadata
|
|
59
|
-
|
|
60
|
-
b"[\x06-\x09]\x20(.{4})\x6f.{4}[\x06-\x09]\x20(.{4})",
|
|
68
|
+
_PATTERN_AES_KEY_AND_BLOCK_SIZE_AND_ALGO = re.compile(
|
|
69
|
+
b"[\x06-\x09]\x20(.{4})\x6f.{4}[\x06-\x09]\x20(.{4})\x6f.{4}[\x06-\x09](.)\x6f.{4}",
|
|
70
|
+
re.DOTALL,
|
|
61
71
|
)
|
|
62
72
|
# Do not re.compile in-line replacement patterns
|
|
63
73
|
_PATTERN_AES_KEY_BASE = b"(.{3}\x04).%b"
|
|
@@ -68,6 +78,7 @@ class ConfigDecryptorAESCBC(ConfigDecryptor):
|
|
|
68
78
|
|
|
69
79
|
def __init__(self, payload: DotNetPEPayload) -> None:
|
|
70
80
|
super().__init__(payload)
|
|
81
|
+
self.aes_algo: ModeWithInitializationVector = CBC
|
|
71
82
|
self._block_size: int = None
|
|
72
83
|
self._iterations: int = None
|
|
73
84
|
self._key_candidates: list[bytes] = None
|
|
@@ -84,7 +95,7 @@ class ConfigDecryptorAESCBC(ConfigDecryptor):
|
|
|
84
95
|
logger.debug(
|
|
85
96
|
f"Decrypting {ciphertext} with key {self.key.hex()} and IV {iv.hex()}..."
|
|
86
97
|
)
|
|
87
|
-
aes_cipher = Cipher(AES(self.key),
|
|
98
|
+
aes_cipher = Cipher(AES(self.key), self.aes_algo(iv), backend=default_backend())
|
|
88
99
|
decryptor = aes_cipher.decryptor()
|
|
89
100
|
# Use a PKCS7 unpadder to remove padding from decrypted value
|
|
90
101
|
# https://cryptography.io/en/latest/hazmat/primitives/padding/
|
|
@@ -107,10 +118,8 @@ class ConfigDecryptorAESCBC(ConfigDecryptor):
|
|
|
107
118
|
# will be added as candidates
|
|
108
119
|
def _derive_aes_passphrase_candidates(self, key_val: str) -> list[bytes]:
|
|
109
120
|
passphrase_candidates = [key_val.encode()]
|
|
110
|
-
|
|
121
|
+
with suppress(Exception):
|
|
111
122
|
passphrase_candidates.append(b64decode(key_val))
|
|
112
|
-
except Exception:
|
|
113
|
-
pass
|
|
114
123
|
logger.debug(f"AES passphrase candidates found: {passphrase_candidates}")
|
|
115
124
|
return passphrase_candidates
|
|
116
125
|
|
|
@@ -204,9 +213,13 @@ class ConfigDecryptorAESCBC(ConfigDecryptor):
|
|
|
204
213
|
return keys
|
|
205
214
|
|
|
206
215
|
# Extracts the AES key and block size from the payload
|
|
207
|
-
def
|
|
216
|
+
def _get_aes_key_block_size_and_algo(
|
|
217
|
+
self,
|
|
218
|
+
) -> Tuple[int, int, ModeWithInitializationVector]:
|
|
208
219
|
logger.debug("Extracting AES key and block size...")
|
|
209
|
-
hit = re.search(
|
|
220
|
+
hit = re.search(
|
|
221
|
+
self._PATTERN_AES_KEY_AND_BLOCK_SIZE_AND_ALGO, self._payload.data
|
|
222
|
+
)
|
|
210
223
|
if hit is None:
|
|
211
224
|
raise ConfigParserException("Could not extract AES key or block size")
|
|
212
225
|
|
|
@@ -214,9 +227,15 @@ class ConfigDecryptorAESCBC(ConfigDecryptor):
|
|
|
214
227
|
# Note use of // instead of / to ensure integer output, not float
|
|
215
228
|
key_size = bytes_to_int(hit.groups()[0]) // 8
|
|
216
229
|
block_size = bytes_to_int(hit.groups()[1])
|
|
230
|
+
algo_id = bytes_to_int(hit.groups()[2])
|
|
231
|
+
if algo_id not in self._ALGO_MAP:
|
|
232
|
+
raise ConfigParserException("Could not extract AES algorithm ID byte")
|
|
233
|
+
algo = self._ALGO_MAP[algo_id]
|
|
217
234
|
|
|
218
|
-
logger.debug(
|
|
219
|
-
|
|
235
|
+
logger.debug(
|
|
236
|
+
f"Found key size {key_size}, block size {block_size} , and AES algorithm {algo}"
|
|
237
|
+
)
|
|
238
|
+
return key_size, block_size, algo
|
|
220
239
|
|
|
221
240
|
# Given an offset to an instruction within the Method that sets up the
|
|
222
241
|
# Cipher, extracts the AES key RVA from the payload
|
|
@@ -262,8 +281,9 @@ class ConfigDecryptorAESCBC(ConfigDecryptor):
|
|
|
262
281
|
if metadata is None:
|
|
263
282
|
raise ConfigParserException("Could not identify AES metadata")
|
|
264
283
|
logger.debug(f"AES metadata found at offset {hex(metadata.start())}")
|
|
265
|
-
|
|
266
|
-
|
|
284
|
+
self._key_size, self._block_size, self.aes_algo = (
|
|
285
|
+
self._get_aes_key_block_size_and_algo()
|
|
286
|
+
)
|
|
267
287
|
|
|
268
288
|
logger.debug("Extracting AES iterations...")
|
|
269
289
|
self._iterations = bytes_to_int(metadata.groups()[1])
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: rat-king-parser
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.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>
|
|
@@ -495,7 +495,7 @@ Thank you!
|
|
|
495
495
|
## Contributions & Attribution
|
|
496
496
|
Huge thanks to the following contributors for their outstanding work:
|
|
497
497
|
|
|
498
|
-
- [doomedraven](https://github.com/doomedraven): For your help in integrating RKP into CAPEv2
|
|
498
|
+
- [doomedraven](https://github.com/doomedraven): For your help in integrating RKP into CAPEv2, as well as your continued contributions to the project and great feedback!
|
|
499
499
|
- [cccs-rs](https://github.com/cccs-rs): For your help in integrating RKP into AssemblyLine, as well as helping me wrap it to work with MACO
|
|
500
500
|
|
|
501
501
|
The logo for this project contains modifications of the following images:
|
|
@@ -20,8 +20,8 @@ src/rat_king_parser/config_parser/utils/dotnet_constants.py
|
|
|
20
20
|
src/rat_king_parser/config_parser/utils/dotnetpe_payload.py
|
|
21
21
|
src/rat_king_parser/config_parser/utils/decryptors/__init__.py
|
|
22
22
|
src/rat_king_parser/config_parser/utils/decryptors/config_decryptor.py
|
|
23
|
-
src/rat_king_parser/config_parser/utils/decryptors/config_decryptor_aes_cbc.py
|
|
24
23
|
src/rat_king_parser/config_parser/utils/decryptors/config_decryptor_aes_ecb.py
|
|
24
|
+
src/rat_king_parser/config_parser/utils/decryptors/config_decryptor_aes_with_iv.py
|
|
25
25
|
src/rat_king_parser/config_parser/utils/decryptors/config_decryptor_decrypt_xor.py
|
|
26
26
|
src/rat_king_parser/config_parser/utils/decryptors/config_decryptor_plaintext.py
|
|
27
27
|
src/rat_king_parser/config_parser/utils/decryptors/config_decryptor_random_hardcoded.py
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{rat_king_parser-3.1.7 → rat_king_parser-3.2.2}/src/rat_king_parser/config_parser/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{rat_king_parser-3.1.7 → rat_king_parser-3.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
|
{rat_king_parser-3.1.7 → rat_king_parser-3.2.2}/src/rat_king_parser.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
{rat_king_parser-3.1.7 → rat_king_parser-3.2.2}/src/rat_king_parser.egg-info/entry_points.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|