maco 1.2.17__py3-none-any.whl → 1.2.18__py3-none-any.whl
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.
- extractor_setup/maco/__init__.py +0 -0
- extractor_setup/maco/base_test.py +98 -0
- extractor_setup/maco/cli.py +275 -0
- extractor_setup/maco/collector.py +220 -0
- extractor_setup/maco/exceptions.py +33 -0
- extractor_setup/maco/extractor.py +70 -0
- extractor_setup/maco/model/__init__.py +1 -0
- extractor_setup/maco/model/model.py +606 -0
- extractor_setup/maco/utils.py +587 -0
- extractor_setup/maco/yara.py +129 -0
- maco/utils.py +2 -2
- {maco-1.2.17.dist-info → maco-1.2.18.dist-info}/METADATA +2 -1
- {maco-1.2.17.dist-info → maco-1.2.18.dist-info}/RECORD +19 -9
- {maco-1.2.17.dist-info → maco-1.2.18.dist-info}/top_level.txt +1 -0
- model_setup/maco/utils.py +2 -2
- pipelines/publish.yaml +30 -24
- {maco-1.2.17.dist-info → maco-1.2.18.dist-info}/WHEEL +0 -0
- {maco-1.2.17.dist-info → maco-1.2.18.dist-info}/entry_points.txt +0 -0
- {maco-1.2.17.dist-info → maco-1.2.18.dist-info}/licenses/LICENSE.md +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from maco.model.model import * # noqa: F403
|
|
@@ -0,0 +1,606 @@
|
|
|
1
|
+
"""Malware config extractor output model."""
|
|
2
|
+
|
|
3
|
+
from enum import Enum
|
|
4
|
+
from typing import Any, Dict, List, Optional, Union
|
|
5
|
+
|
|
6
|
+
from pydantic import BaseModel, ConfigDict
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class ForbidModel(BaseModel):
|
|
10
|
+
"""We want to forbid extra properties, so that the 'other' field is used instead."""
|
|
11
|
+
|
|
12
|
+
model_config = ConfigDict(extra="forbid", use_enum_values=True)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class ConnUsageEnum(str, Enum):
|
|
16
|
+
"""Purpose of the connection."""
|
|
17
|
+
|
|
18
|
+
c2 = "c2" # issue commands to malware
|
|
19
|
+
upload = "upload" # get data out of the network
|
|
20
|
+
download = "download" # fetch dynamic config, second stage, etc
|
|
21
|
+
propagate = "propagate" # spread through the network
|
|
22
|
+
tunnel = "tunnel" # communicate through the network
|
|
23
|
+
ransom = "ransom" # payment
|
|
24
|
+
decoy = "decoy" # Decoy connections to obfuscate malicious
|
|
25
|
+
other = "other"
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class Encryption(ForbidModel):
|
|
29
|
+
"""Encryption usage."""
|
|
30
|
+
|
|
31
|
+
class UsageEnum(str, Enum):
|
|
32
|
+
"""Purpose of the encryption."""
|
|
33
|
+
|
|
34
|
+
config = "config"
|
|
35
|
+
communication = "communication"
|
|
36
|
+
binary = "binary"
|
|
37
|
+
ransom = "ransom"
|
|
38
|
+
other = "other"
|
|
39
|
+
|
|
40
|
+
algorithm: Optional[str] = None
|
|
41
|
+
public_key: Optional[str] = None
|
|
42
|
+
key: Optional[str] = None # private key or symmetric key
|
|
43
|
+
provider: Optional[str] = None # encryption library used. openssl, homebrew, etc.
|
|
44
|
+
|
|
45
|
+
mode: Optional[str] = None # block vs stream
|
|
46
|
+
# base 64'd binary data for these details?
|
|
47
|
+
# TODO to confirm usage of these different properties
|
|
48
|
+
iv: Optional[str] = None # initialisation vector
|
|
49
|
+
seed: Optional[str] = None
|
|
50
|
+
nonce: Optional[str] = None
|
|
51
|
+
constants: List[str] = []
|
|
52
|
+
|
|
53
|
+
usage: Optional[UsageEnum] = None
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
class CategoryEnum(str, Enum):
|
|
57
|
+
"""Category of the malware."""
|
|
58
|
+
|
|
59
|
+
# Software that shows you extra promotions that you cannot control as you use your PC.
|
|
60
|
+
# You wouldn't see the extra ads if you didn't have adware installed.
|
|
61
|
+
adware = "adware"
|
|
62
|
+
|
|
63
|
+
# Malware related to an Advanced Persistent Threat (APT) group.
|
|
64
|
+
apt = "apt"
|
|
65
|
+
|
|
66
|
+
# A backdoor Trojan gives malicious users remote control over the infected computer.
|
|
67
|
+
# They enable the author to do anything they wish on the infected computer including
|
|
68
|
+
# sending, receiving, launching and deleting files, displaying data and rebooting the computer.
|
|
69
|
+
# Backdoor Trojans are often used to unite a group of victim computers to form a botnet or
|
|
70
|
+
# zombie network that can be used for criminal purposes.
|
|
71
|
+
backdoor = "backdoor"
|
|
72
|
+
|
|
73
|
+
# Trojan Banker programs are designed to steal your account data for online banking systems,
|
|
74
|
+
# e-payment systems and credit or debit cards.
|
|
75
|
+
banker = "banker"
|
|
76
|
+
|
|
77
|
+
# A malware variant that modifies the boot sectors of a hard drive, including the Master Boot Record (MBR)
|
|
78
|
+
# and Volume Boot Record (VBR).
|
|
79
|
+
bootkit = "bootkit"
|
|
80
|
+
|
|
81
|
+
# A malicious bot is self-propagating malware designed to infect a host and connect back to a central server
|
|
82
|
+
# or servers that act as a command and control (C&C) center for an entire network of compromised devices,
|
|
83
|
+
# or botnet.
|
|
84
|
+
bot = "bot"
|
|
85
|
+
|
|
86
|
+
# A browser hijacker is defined as a form of unwanted software that modifies a web browser's settings without
|
|
87
|
+
# the user's permission. The result is the placement of unwanted advertising into the browser,
|
|
88
|
+
# and possibly the replacement of an existing home page or search page with the hijacker page.
|
|
89
|
+
browser_hijacker = "browser_hijacker"
|
|
90
|
+
|
|
91
|
+
# Trojan bruteforcer are trying to brute force website in order to achieve something else
|
|
92
|
+
# (EX: Finding WordPress websites with default credentials).
|
|
93
|
+
bruteforcer = "bruteforcer"
|
|
94
|
+
|
|
95
|
+
# A type of trojan that can use your PC to 'click' on websites or applications.
|
|
96
|
+
# They are usually used to make money for a malicious hacker by clicking on online advertisements
|
|
97
|
+
# and making it look like the website gets more traffic than it does.
|
|
98
|
+
# They can also be used to skew online polls, install programs on your PC, or make unwanted software
|
|
99
|
+
# appear more popular than it is.
|
|
100
|
+
clickfraud = "clickfraud"
|
|
101
|
+
|
|
102
|
+
# Cryptocurrency mining malware.
|
|
103
|
+
cryptominer = "cryptominer"
|
|
104
|
+
|
|
105
|
+
# These programs conduct DoS (Denial of Service) attacks against a targeted web address.
|
|
106
|
+
# By sending multiple requests from your computer and several other infected computers,
|
|
107
|
+
# the attack can overwhelm the target address leading to a denial of service.
|
|
108
|
+
ddos = "ddos"
|
|
109
|
+
|
|
110
|
+
# Trojan Downloaders can download and install new versions of malicious programs in the target system.
|
|
111
|
+
downloader = "downloader"
|
|
112
|
+
|
|
113
|
+
# These programs are used by hackers in order to install malware or to prevent the detection of malicious programs.
|
|
114
|
+
dropper = "dropper"
|
|
115
|
+
|
|
116
|
+
# Exploit kits are programs that contain data or code that takes advantage of a vulnerability
|
|
117
|
+
# within an application that is running in the target system.
|
|
118
|
+
exploitkit = "exploitkit"
|
|
119
|
+
|
|
120
|
+
# Trojan FakeAV programs simulate the activity of antivirus software.
|
|
121
|
+
# They are designed to extort money in return for the detection and removal of threat, even though the
|
|
122
|
+
# threats that they report are actually non-existent.
|
|
123
|
+
fakeav = "fakeav"
|
|
124
|
+
|
|
125
|
+
# A type of tool that can be used to allow and maintain unauthorized access to your PC.
|
|
126
|
+
hacktool = "hacktool"
|
|
127
|
+
|
|
128
|
+
# A program that collects your personal information, such as your browsing history,
|
|
129
|
+
# and uses it without adequate consent.
|
|
130
|
+
infostealer = "infostealer"
|
|
131
|
+
|
|
132
|
+
# A keylogger monitors and logs every keystroke it can identify.
|
|
133
|
+
# Once installed, the virus either keeps track of all the keys and stores the information locally,
|
|
134
|
+
# after which the hacker needs physical access to the computer to retrieve the information,
|
|
135
|
+
# or the logs are sent over the internet back to the hacker.
|
|
136
|
+
keylogger = "keylogger"
|
|
137
|
+
|
|
138
|
+
# A program that loads another application / memory space.
|
|
139
|
+
loader = "loader"
|
|
140
|
+
|
|
141
|
+
# A type of malware that hides its code and purpose to make it more difficult for
|
|
142
|
+
# security software to detect or remove it.
|
|
143
|
+
obfuscator = "obfuscator"
|
|
144
|
+
|
|
145
|
+
# Point-of-sale malware is usually a type of malware that is used by cybercriminals to target point of sale (POS)
|
|
146
|
+
# and payment terminals with the intent to obtain credit card and debit card information.
|
|
147
|
+
pos = "pos"
|
|
148
|
+
|
|
149
|
+
# This type of trojan allows unauthorized parties to use the infected computer as a proxy server
|
|
150
|
+
# to access the Internet anonymously.
|
|
151
|
+
proxy = "proxy"
|
|
152
|
+
|
|
153
|
+
# A program that can be used by a remote hacker to gain access and control of an infected machine.
|
|
154
|
+
rat = "rat"
|
|
155
|
+
|
|
156
|
+
# This type of malware can modify data in the target computer so the operating system
|
|
157
|
+
# will stop running correctly or the data is no longer accessible.
|
|
158
|
+
# The criminal will only restore the computer state or data after a ransom is paid to them
|
|
159
|
+
# (mostly using cryptocurrency).
|
|
160
|
+
ransomware = "ransomware"
|
|
161
|
+
|
|
162
|
+
# A reverse proxy is a server that receives requests from the internet and forwards them to a small set of servers.
|
|
163
|
+
reverse_proxy = "reverse_proxy"
|
|
164
|
+
|
|
165
|
+
# Rootkits are designed to conceal certain objects or activities in the system.
|
|
166
|
+
# Often their main purpose is to prevent malicious programs being detected
|
|
167
|
+
# in order to extend the period in which programs can run on an infected computer.
|
|
168
|
+
rootkit = "rootkit"
|
|
169
|
+
|
|
170
|
+
# This type of malware scan the internet / network(s) / system(s) / service(s) to collect information.
|
|
171
|
+
# That information could be used later to perpetuate an cyber attack.
|
|
172
|
+
scanner = "scanner"
|
|
173
|
+
|
|
174
|
+
# Scareware is a form of malware which uses social engineering to cause shock, anxiety,
|
|
175
|
+
# or the perception of a threat in order to manipulate users into buying unwanted software.
|
|
176
|
+
scareware = "scareware"
|
|
177
|
+
|
|
178
|
+
# Malware that is sending spam.
|
|
179
|
+
spammer = "spammer"
|
|
180
|
+
|
|
181
|
+
# Generic or Unknown Trojan
|
|
182
|
+
trojan = "trojan"
|
|
183
|
+
|
|
184
|
+
# A generic computer virus
|
|
185
|
+
virus = "virus"
|
|
186
|
+
|
|
187
|
+
# A type of malware that destroy the data.
|
|
188
|
+
wiper = "wiper"
|
|
189
|
+
|
|
190
|
+
# A web shell is a script that can be uploaded to a web server to enable remote administration of the machine.
|
|
191
|
+
webshell = "webshell"
|
|
192
|
+
|
|
193
|
+
# A type of malware that spreads to other PCs.
|
|
194
|
+
worm = "worm"
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
class ExtractorModel(ForbidModel):
|
|
198
|
+
r"""Captured config/iocs, unpacked binaries and other malware properties from a robo-analyst.
|
|
199
|
+
|
|
200
|
+
This model defines common fields for output of a script targeting a specific malware family.
|
|
201
|
+
Usage of this model will allow for easier sharing of scripts between different authors and systems.
|
|
202
|
+
The model will not define fields for all data that can be extracted from a binary, only the most common.
|
|
203
|
+
This is to make it easier for authors to understand and use the model.
|
|
204
|
+
|
|
205
|
+
This model can have new fields added in the future if they become more common,
|
|
206
|
+
but the intent is to avoid removing or modifying existing fields, for backwards compatibility.
|
|
207
|
+
|
|
208
|
+
Where data does not fit with the current model, the 'others' field should be used.
|
|
209
|
+
Contents in this field is not defined by the model and verification/normalisation is up to
|
|
210
|
+
the author and whatever systems run the scripts.
|
|
211
|
+
If many decoders define similar data in the 'others' field, that field should be migrated to this model.
|
|
212
|
+
|
|
213
|
+
The model must be kept relatively flat, with nested lists of dictionaries to be avoided.
|
|
214
|
+
This is to make queries simpler to write in sql, elasticsearch and other storage systems.
|
|
215
|
+
|
|
216
|
+
Malware and systems that investigate malware can do pretty much anything.
|
|
217
|
+
This model needs to be simple and flexible to make sharing easy.
|
|
218
|
+
Some things should be out of scope for this model.
|
|
219
|
+
Responsibility for these things are up to authors and systems that use this model.
|
|
220
|
+
|
|
221
|
+
Out of scope
|
|
222
|
+
* Verifying anything in the 'others' dict, including that it is json-compatible.
|
|
223
|
+
* We don't know anything about the structure
|
|
224
|
+
* checking is json compatible requires dumping to json string, which can be slow
|
|
225
|
+
* Connecting specific config items to malware behaviour catalog
|
|
226
|
+
* i.e. "Persistence::Modify Registry" with 'registry' item from model (SYSTEM\ControlSet001\Services\)
|
|
227
|
+
* due to complexity and normalisation difficulties
|
|
228
|
+
* much malware behaviour is not related to specific config items
|
|
229
|
+
* Normalisation/verification of individual properties
|
|
230
|
+
* i.e. lowercase filepaths - some filesystems are case sensitive
|
|
231
|
+
* i.e. checking registry hives match known - not enough SME and too complex for a simple model
|
|
232
|
+
* generally, this quickly becomes complex (validating a fully defined http item)
|
|
233
|
+
* calling systems are probably performing their own validation anyway
|
|
234
|
+
* requiring specific properties to be set
|
|
235
|
+
* i.e. if http item is defined, requiring hostname to be set
|
|
236
|
+
* Some use cases always seem to exist where a property should not be set
|
|
237
|
+
"""
|
|
238
|
+
|
|
239
|
+
family: Union[str, List[str]] # family or families of malware that was detected
|
|
240
|
+
version: Optional[str] = None # version/variant of malware
|
|
241
|
+
category: List[CategoryEnum] = [] # capability/purpose of the malware
|
|
242
|
+
attack: List[str] = [] # mitre att&ck reference ids, e.g. 'T1129'
|
|
243
|
+
|
|
244
|
+
#
|
|
245
|
+
# simple config properties
|
|
246
|
+
#
|
|
247
|
+
|
|
248
|
+
# capabilities of the malware enabled/disabled in config
|
|
249
|
+
# note these are probably malware-specific capabilities so no attempt to normalise has been made
|
|
250
|
+
# note - av/sandbox detection should be noted by 'detect_<product>'
|
|
251
|
+
capability_enabled: List[str] = []
|
|
252
|
+
capability_disabled: List[str] = []
|
|
253
|
+
|
|
254
|
+
campaign_id: List[str] = [] # Server/Campaign Id for malware
|
|
255
|
+
identifier: List[str] = [] # UUID/Identifiers for deployed instance
|
|
256
|
+
decoded_strings: List[str] = [] # decoded strings from within malware
|
|
257
|
+
password: List[str] = [] # Any password extracted from the binary
|
|
258
|
+
mutex: List[str] = [] # mutex to prevent multiple instances
|
|
259
|
+
pipe: List[str] = [] # pipe name used for communication
|
|
260
|
+
sleep_delay: Optional[int] = None # time to sleep/delay execution (milliseconds)
|
|
261
|
+
# additional time applied to sleep_delay (milliseconds).
|
|
262
|
+
# Jitter implementations can vary but usually it is a value from which a random number is generated and
|
|
263
|
+
# added/subtracted to the sleep_delay to make behaviour more unpredictable
|
|
264
|
+
sleep_delay_jitter: Optional[int] = None
|
|
265
|
+
inject_exe: List[str] = [] # name of executable to inject into
|
|
266
|
+
|
|
267
|
+
# configuration or clustering/research data that doesnt fit the other fields
|
|
268
|
+
# * rarely used by decoders or specific to one decoder
|
|
269
|
+
# to prevent key explosion, the keys must not be dynamically generated
|
|
270
|
+
# e.g. api_imports, api_checksums, num_imports, import_hash + many more
|
|
271
|
+
# data stored here must always be JSON-serialisable
|
|
272
|
+
other: Dict[str, Any] = {}
|
|
273
|
+
|
|
274
|
+
#
|
|
275
|
+
# embedded binary data
|
|
276
|
+
#
|
|
277
|
+
class Binary(ForbidModel):
|
|
278
|
+
"""Binary data extracted by decoder."""
|
|
279
|
+
|
|
280
|
+
class TypeEnum(str, Enum):
|
|
281
|
+
"""Type of binary data."""
|
|
282
|
+
|
|
283
|
+
payload = "payload" # contained within the original file
|
|
284
|
+
config = "config" # sometimes malware uses json/formatted text for config
|
|
285
|
+
other = "other"
|
|
286
|
+
|
|
287
|
+
datatype: Optional[TypeEnum] = None # what the binary data is used for
|
|
288
|
+
data: bytes # binary data, not json compatible
|
|
289
|
+
|
|
290
|
+
# other information for the extracted binary rather than the config
|
|
291
|
+
# data stored here must always be JSON-serialisable
|
|
292
|
+
# e.g. filename, extension, relationship label
|
|
293
|
+
other: Dict[str, Any] = {}
|
|
294
|
+
|
|
295
|
+
# convenience for ret.encryption.append(ret.Encryption(*properties))
|
|
296
|
+
# Define as class as only way to allow for this to be accessed and not have pydantic try to parse it.
|
|
297
|
+
class Encryption(Encryption):
|
|
298
|
+
"""Encryption usage."""
|
|
299
|
+
|
|
300
|
+
pass
|
|
301
|
+
|
|
302
|
+
encryption: Union[List[Encryption], Encryption, None] = None # encryption information for the binary
|
|
303
|
+
|
|
304
|
+
binaries: List[Binary] = []
|
|
305
|
+
|
|
306
|
+
#
|
|
307
|
+
# communication protocols
|
|
308
|
+
#
|
|
309
|
+
class FTP(ForbidModel):
|
|
310
|
+
"""Usage of FTP connection."""
|
|
311
|
+
|
|
312
|
+
username: Optional[str] = None
|
|
313
|
+
password: Optional[str] = None
|
|
314
|
+
hostname: Optional[str] = None
|
|
315
|
+
port: Optional[int] = None
|
|
316
|
+
|
|
317
|
+
path: Optional[str] = None
|
|
318
|
+
|
|
319
|
+
usage: Optional[ConnUsageEnum] = None
|
|
320
|
+
|
|
321
|
+
ftp: List[FTP] = []
|
|
322
|
+
|
|
323
|
+
class SMTP(ForbidModel):
|
|
324
|
+
"""Usage of SMTP."""
|
|
325
|
+
|
|
326
|
+
# credentials and location of server
|
|
327
|
+
username: Optional[str] = None
|
|
328
|
+
password: Optional[str] = None
|
|
329
|
+
hostname: Optional[str] = None
|
|
330
|
+
port: Optional[int] = None
|
|
331
|
+
|
|
332
|
+
mail_to: List[str] = [] # receivers
|
|
333
|
+
mail_from: Optional[str] = None # sender
|
|
334
|
+
subject: Optional[str] = None
|
|
335
|
+
|
|
336
|
+
usage: Optional[ConnUsageEnum] = None
|
|
337
|
+
|
|
338
|
+
smtp: List[SMTP] = [] # SMTP server for malware
|
|
339
|
+
|
|
340
|
+
class Http(ForbidModel):
|
|
341
|
+
"""Usage of HTTP connection."""
|
|
342
|
+
|
|
343
|
+
# malware sometimes does weird stuff with uris so we don't want to force
|
|
344
|
+
# authors to break the uri into username, hostname, path, etc.
|
|
345
|
+
# as we lose that information.
|
|
346
|
+
# e.g. extra '?' or '/' when unnecessary.
|
|
347
|
+
# or something that is technically an invalid uri but still works
|
|
348
|
+
uri: Optional[str] = None
|
|
349
|
+
|
|
350
|
+
# on the other hand we might not have enough info to construct a uri
|
|
351
|
+
protocol: Optional[str] = None # http,https
|
|
352
|
+
username: Optional[str] = None
|
|
353
|
+
password: Optional[str] = None
|
|
354
|
+
hostname: Optional[str] = None # (A host/hostname can be an IP, domain or hostname)
|
|
355
|
+
port: Optional[int] = None
|
|
356
|
+
path: Optional[str] = None
|
|
357
|
+
query: Optional[str] = None
|
|
358
|
+
fragment: Optional[str] = None
|
|
359
|
+
|
|
360
|
+
user_agent: Optional[str] = None # user agent sent by malware
|
|
361
|
+
method: Optional[str] = None # get put delete etc
|
|
362
|
+
headers: Optional[Dict[str, str]] = None # custom/additional HTTP headers
|
|
363
|
+
max_size: Optional[int] = None
|
|
364
|
+
|
|
365
|
+
usage: Optional[ConnUsageEnum] = None
|
|
366
|
+
|
|
367
|
+
http: List[Http] = []
|
|
368
|
+
|
|
369
|
+
class SSH(ForbidModel):
|
|
370
|
+
"""Usage of ssh connection."""
|
|
371
|
+
|
|
372
|
+
username: Optional[str] = None
|
|
373
|
+
password: Optional[str] = None
|
|
374
|
+
hostname: Optional[str] = None
|
|
375
|
+
port: Optional[int] = None
|
|
376
|
+
|
|
377
|
+
usage: Optional[ConnUsageEnum] = None
|
|
378
|
+
|
|
379
|
+
ssh: List[SSH] = []
|
|
380
|
+
|
|
381
|
+
class Proxy(ForbidModel):
|
|
382
|
+
"""Usage of proxy connection."""
|
|
383
|
+
|
|
384
|
+
protocol: Optional[str] = None # socks5,http
|
|
385
|
+
username: Optional[str] = None
|
|
386
|
+
password: Optional[str] = None
|
|
387
|
+
hostname: Optional[str] = None
|
|
388
|
+
port: Optional[int] = None
|
|
389
|
+
|
|
390
|
+
usage: Optional[ConnUsageEnum] = None
|
|
391
|
+
|
|
392
|
+
proxy: List[Proxy] = []
|
|
393
|
+
|
|
394
|
+
class ICMP(ForbidModel):
|
|
395
|
+
"""Usage of ICMP."""
|
|
396
|
+
|
|
397
|
+
type: Optional[int] = None
|
|
398
|
+
code: Optional[int] = None
|
|
399
|
+
header: Optional[str] = None # Some malware uses non-standard header fields
|
|
400
|
+
hostname: Optional[str] = None
|
|
401
|
+
|
|
402
|
+
usage: Optional[ConnUsageEnum] = None
|
|
403
|
+
|
|
404
|
+
icmp: List[ICMP] = []
|
|
405
|
+
|
|
406
|
+
#
|
|
407
|
+
# inter process communication (IPC)
|
|
408
|
+
#
|
|
409
|
+
class IPC(ForbidModel):
|
|
410
|
+
"""Usage of named pipe communications."""
|
|
411
|
+
|
|
412
|
+
# A record stored on disk, or a record synthesized on demand by a file
|
|
413
|
+
# server, which can be accessed by multiple processes.
|
|
414
|
+
file: Optional[List[str]] = None
|
|
415
|
+
# Data sent over a network interface, either to a different process on
|
|
416
|
+
# the same computer or to another computer on the network. Stream
|
|
417
|
+
# oriented (TCP; data written through a socket requires formatting to
|
|
418
|
+
# preserve message boundaries) or more rarely message-oriented (UDP,
|
|
419
|
+
# SCTP).
|
|
420
|
+
socket: Optional[List[str]] = None
|
|
421
|
+
# Similar to an internet socket, but all communication occurs within
|
|
422
|
+
# the kernel. Domain sockets use the file system as their address
|
|
423
|
+
# space. Processes reference a domain socket as an inode, and multiple
|
|
424
|
+
# processes can communicate with one socket.
|
|
425
|
+
unix_domain_socket: Optional[List[str]] = None
|
|
426
|
+
# A file mapped to RAM and can be modified by changing memory
|
|
427
|
+
# addresses directly instead of outputting to a stream. This shares
|
|
428
|
+
# the same benefits as a standard file.
|
|
429
|
+
memory_mapped_file: Optional[Union[bytes, List[str]]] = None
|
|
430
|
+
# A data stream similar to a socket, but which usually preserves
|
|
431
|
+
# message boundaries. Typically implemented by the operating system,
|
|
432
|
+
# they allow multiple processes to read and write to the message queue
|
|
433
|
+
# without being directly connected to each other.
|
|
434
|
+
message_queue: Optional[List[str]] = None
|
|
435
|
+
# A unidirectional data channel using standard input and output. Data
|
|
436
|
+
# written to the write-end of the pipe is buffered by the operating
|
|
437
|
+
# system until it is read from the read-end of the pipe. Two-way
|
|
438
|
+
# communication between processes can be achieved by using two pipes
|
|
439
|
+
# in opposite "directions".
|
|
440
|
+
anonymous_pipe: Optional[List[str]] = None
|
|
441
|
+
# A pipe that is treated like a file. Instead of using standard input
|
|
442
|
+
# and output as with an anonymous pipe, processes write to and read
|
|
443
|
+
# from a named pipe, as if it were a regular file.
|
|
444
|
+
named_pipe: Optional[List[str]] = None
|
|
445
|
+
# The process names involved in the IPC communication
|
|
446
|
+
process_names: Optional[List[str]] = None
|
|
447
|
+
# Multiple processes are given access to the same block of memory,
|
|
448
|
+
# which creates a shared buffer for the processes to communicate with
|
|
449
|
+
# each other.
|
|
450
|
+
shared_memory: Optional[bytes] = None
|
|
451
|
+
usage: Optional[ConnUsageEnum] = None
|
|
452
|
+
|
|
453
|
+
ipc: List[IPC] = [] # Inter-Process Communications (similar to 'pipe' but more detailed)
|
|
454
|
+
|
|
455
|
+
class DNS(ForbidModel):
|
|
456
|
+
"""Direct usage of DNS."""
|
|
457
|
+
|
|
458
|
+
class RecordTypeEnum(str, Enum):
|
|
459
|
+
"""DNS record types."""
|
|
460
|
+
|
|
461
|
+
A = "A"
|
|
462
|
+
AAAA = "AAAA"
|
|
463
|
+
AFSDB = "AFSDB"
|
|
464
|
+
APL = "APL"
|
|
465
|
+
CAA = "CAA"
|
|
466
|
+
CDNSKEY = "CDNSKEY"
|
|
467
|
+
CDS = "CDS"
|
|
468
|
+
CERT = "CERT"
|
|
469
|
+
CNAME = "CNAME"
|
|
470
|
+
CSYNC = "CSYNC"
|
|
471
|
+
DHCID = "DHCID"
|
|
472
|
+
DLV = "DLV"
|
|
473
|
+
DNAME = "DNAME"
|
|
474
|
+
DNSKEY = "DNSKEY"
|
|
475
|
+
DS = "DS"
|
|
476
|
+
EUI48 = "EUI48"
|
|
477
|
+
EUI64 = "EUI64"
|
|
478
|
+
HINFO = "HINFO"
|
|
479
|
+
HIP = "HIP"
|
|
480
|
+
HTTPS = "HTTPS"
|
|
481
|
+
IPSECKEY = "IPSECKEY"
|
|
482
|
+
KEY = "KEY"
|
|
483
|
+
KX = "KX"
|
|
484
|
+
LOC = "LOC"
|
|
485
|
+
MX = "MX"
|
|
486
|
+
NAPTR = "NAPTR"
|
|
487
|
+
NS = "NS"
|
|
488
|
+
NSEC = "NSEC"
|
|
489
|
+
NSEC3 = "NSEC3"
|
|
490
|
+
NSEC3PARAM = "NSEC3PARAM"
|
|
491
|
+
OPENPGPKEY = "OPENPGPKEY"
|
|
492
|
+
PTR = "PTR"
|
|
493
|
+
RRSIG = "RRSIG"
|
|
494
|
+
RP = "RP"
|
|
495
|
+
SIG = "SIG"
|
|
496
|
+
SMIMEA = "SMIMEA"
|
|
497
|
+
SOA = "SOA"
|
|
498
|
+
SRV = "SRV"
|
|
499
|
+
SSHFP = "SSHFP"
|
|
500
|
+
SVCB = "SVCB"
|
|
501
|
+
TA = "TA"
|
|
502
|
+
TKEY = "TKEY"
|
|
503
|
+
TLSA = "TLSA"
|
|
504
|
+
TSIG = "TSIG"
|
|
505
|
+
TXT = "TXT"
|
|
506
|
+
URI = "URI"
|
|
507
|
+
ZONEMD = "ZONEMD"
|
|
508
|
+
|
|
509
|
+
ip: Optional[str] = None
|
|
510
|
+
port: Optional[int] = None # The default value is 53
|
|
511
|
+
hostname: Optional[str] = None # This is the query hostname
|
|
512
|
+
record_type: Optional[RecordTypeEnum] = None # The DNS record type that is queried
|
|
513
|
+
usage: Optional[ConnUsageEnum] = None
|
|
514
|
+
|
|
515
|
+
dns: List[DNS] = [] # custom DNS address to use for name resolution
|
|
516
|
+
|
|
517
|
+
class Connection(ForbidModel):
|
|
518
|
+
"""Generic TCP/UDP usage."""
|
|
519
|
+
|
|
520
|
+
client_ip: Optional[str] = None
|
|
521
|
+
client_port: Optional[int] = None
|
|
522
|
+
server_ip: Optional[str] = None
|
|
523
|
+
server_domain: Optional[str] = None
|
|
524
|
+
server_port: Optional[int] = None
|
|
525
|
+
|
|
526
|
+
usage: Optional[ConnUsageEnum] = None
|
|
527
|
+
|
|
528
|
+
tcp: List[Connection] = []
|
|
529
|
+
udp: List[Connection] = []
|
|
530
|
+
|
|
531
|
+
#
|
|
532
|
+
# complex configuration properties
|
|
533
|
+
#
|
|
534
|
+
# convenience for ret.encryption.append(ret.Encryption(*properties))
|
|
535
|
+
# Define as class as only way to allow for this to be accessed and not have pydantic try to parse it.
|
|
536
|
+
class Encryption(Encryption):
|
|
537
|
+
"""Encryption usage."""
|
|
538
|
+
|
|
539
|
+
pass
|
|
540
|
+
|
|
541
|
+
encryption: List[Encryption] = []
|
|
542
|
+
|
|
543
|
+
class Service(ForbidModel):
|
|
544
|
+
"""OS service usage by malware."""
|
|
545
|
+
|
|
546
|
+
dll: Optional[str] = None # dll that the service is loaded from
|
|
547
|
+
name: Optional[str] = None # service/driver name for persistence
|
|
548
|
+
display_name: Optional[str] = None # display name for service
|
|
549
|
+
description: Optional[str] = None # description for service
|
|
550
|
+
|
|
551
|
+
service: List[Service] = []
|
|
552
|
+
|
|
553
|
+
class Cryptocurrency(ForbidModel):
|
|
554
|
+
"""Cryptocoin usage (ransomware/miner)."""
|
|
555
|
+
|
|
556
|
+
class UsageEnum(str, Enum):
|
|
557
|
+
"""Cryptocoin usage."""
|
|
558
|
+
|
|
559
|
+
ransomware = "ransomware" # request money to unlock
|
|
560
|
+
miner = "miner" # use gpu/cpu to mint coins
|
|
561
|
+
other = "other"
|
|
562
|
+
|
|
563
|
+
coin: Optional[str] = None # BTC,ETH,USDT,BNB, etc
|
|
564
|
+
address: Optional[str] = None
|
|
565
|
+
ransom_amount: Optional[float] = None # number of coins required (if hardcoded)
|
|
566
|
+
|
|
567
|
+
usage: UsageEnum
|
|
568
|
+
|
|
569
|
+
cryptocurrency: List[Cryptocurrency] = []
|
|
570
|
+
|
|
571
|
+
class Path(ForbidModel):
|
|
572
|
+
"""Path used by malware."""
|
|
573
|
+
|
|
574
|
+
class UsageEnum(str, Enum):
|
|
575
|
+
"""Purpose of the path."""
|
|
576
|
+
|
|
577
|
+
c2 = "c2" # file/folder issues commands to malware
|
|
578
|
+
config = "config" # config is loaded from this path
|
|
579
|
+
install = "install" # install directory/filename for malware
|
|
580
|
+
plugins = "plugins" # load new capability from this directory
|
|
581
|
+
logs = "logs" # location to log activity
|
|
582
|
+
storage = "storage" # location to store/backup copied files
|
|
583
|
+
other = "other"
|
|
584
|
+
|
|
585
|
+
# C:\User\tmp\whatever.txt or /some/unix/folder/path
|
|
586
|
+
path: str
|
|
587
|
+
usage: Optional[UsageEnum] = None
|
|
588
|
+
|
|
589
|
+
paths: List[Path] = [] # files/directories used by malware
|
|
590
|
+
|
|
591
|
+
class Registry(ForbidModel):
|
|
592
|
+
"""Registry usage by malware."""
|
|
593
|
+
|
|
594
|
+
class UsageEnum(str, Enum):
|
|
595
|
+
"""Registry usage."""
|
|
596
|
+
|
|
597
|
+
persistence = "persistence" # stay alive
|
|
598
|
+
store_data = "store_data" # generated encryption keys or config
|
|
599
|
+
store_payload = "store_payload" # malware hidden in registry key
|
|
600
|
+
read = "read" # read system registry keys
|
|
601
|
+
other = "other"
|
|
602
|
+
|
|
603
|
+
key: str
|
|
604
|
+
usage: Optional[UsageEnum] = None
|
|
605
|
+
|
|
606
|
+
registry: List[Registry] = []
|