assemblyline-v4-service 4.6.0.dev7__py3-none-any.whl → 4.6.0.23__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.

Potentially problematic release.


This version of assemblyline-v4-service might be problematic. Click here for more details.

@@ -1 +1 @@
1
- 4.6.0.dev7
1
+ 4.6.0.23
@@ -164,12 +164,11 @@ class PrivilegedServiceAPI:
164
164
  def get_safelist(self, tag_list=None):
165
165
  if DEVELOPMENT_MODE:
166
166
  return {}
167
- tag_types = None
168
167
 
169
168
  if tag_list and not isinstance(tag_list, list):
170
169
  raise ValueError("Parameter tag_list should be a list of strings.")
171
170
 
172
- return self.safelist_client.get_safelisted_tags(tag_types)
171
+ return self.safelist_client.get_safelisted_tags(tag_list)
173
172
 
174
173
  def lookup_safelist(self, qhash):
175
174
  if DEVELOPMENT_MODE:
@@ -8,103 +8,76 @@ from assemblyline_v4_service.common.utils import PASSWORD_WORDS
8
8
  # The terms related to each indicator category
9
9
  OCR_INDICATORS_TERMS: dict[str, list[str]] = {
10
10
  "ransomware": [
11
- # https://github.com/cuckoosandbox/community/blob/master/modules/signatures/windows/ransomware_message.py
12
- "AES 128",
13
- "AES 256",
14
- "AES-128",
15
- "AES-256",
16
- "AES128",
17
- "AES256",
18
- "RSA 1024",
19
- "RSA 2048",
20
- "RSA 4096",
21
- "RSA-1024",
22
- "RSA-2048",
23
- "RSA-4096",
24
- "RSA1024",
25
- "RSA2048",
26
- "RSA4096",
27
- "bitcoin",
28
- "bootkit",
29
- "decrypt",
30
- "download tor",
31
- "encrypt",
32
- "enter code",
33
- "has been locked",
34
- "install tor",
35
- "pay a fine",
36
- "pay fine",
37
- "pay the fine",
38
- "payment",
39
- "personal code",
40
- "personal key",
41
- "private code",
42
- "private key",
43
- "ransom",
44
- "recover data",
45
- "recover data",
46
- "recover files",
47
- "recover files",
48
- "recover personal",
49
- "recover the data",
50
- "recover the files",
51
- "recover them",
52
- "recover your",
53
- "restore data",
54
- "restore files",
55
- "restore the data",
56
- "restore the files",
57
- "rootkit",
58
- "secret internet server",
59
- "secret server",
60
- "tor browser",
61
- "tor gateway",
62
- "tor-browser",
63
- "tor-gateway",
64
- "torbrowser",
65
- "torgateway",
66
- "torproject.org",
67
- "unique key",
68
- "victim",
69
- "your code",
70
- "your data",
71
- "your documents",
72
- "your files",
73
- "your key",
74
- # https://github.com/CAPESandbox/community/blob/815e21980f4b234cf84e78749447f262af2beef9/modules/signatures/office_macro.py
75
- "bank account",
76
- # https://github.com/CAPESandbox/community/blob/815e21980f4b234cf84e78749447f262af2beef9/modules/signatures/ransomware_message.py
77
- "Attention!",
78
- "BTC",
79
- "HardwareID",
80
- "bit coin",
81
- "decrypter",
82
- "decryptor",
83
- "device ID",
84
- "encrypted",
85
- "encryption ID",
86
- "ethereum",
87
- "get back my",
88
- "get back your",
89
- "localbitcoins",
90
- "military grade encryption",
91
- "personal ID",
92
- "personal identification code",
93
- "personal identifier",
94
- "recover datarecover the files",
95
- "recover my",
96
- "restore system",
97
- "restore the system",
98
- "unique ID",
99
- "wallet address",
100
- "what happend",
101
- "what happened",
102
- "your database",
103
- "your network",
104
- # Other
105
- "coin",
106
- "ether",
107
- "litecoin",
11
+ "tor browser",
12
+ "torproject org",
13
+ "www torproject",
14
+ "www torproject org",
15
+ "https www torproject",
16
+ "https www torproject org",
17
+ "install tor",
18
+ "install tor browser",
19
+ "tor browser https",
20
+ "files encrypted",
21
+ "download install tor",
22
+ "download install tor browser",
23
+ "browser https www torproject",
24
+ "decrypt files",
25
+ "tor browser https www",
26
+ "private key",
27
+ "id snip",
28
+ "download tor",
29
+ "onion http",
30
+ "install tor browser https",
31
+ "https torproject",
32
+ "https torproject org",
33
+ "onion snip",
34
+ "torproject org download",
35
+ "www torproject org download",
36
+ "download tor browser",
37
+ "restore files",
38
+ "recover files",
39
+ "decryption software",
40
+ "pay ransom",
41
+ "decryption tool",
42
+ "data loss",
43
+ "tor browser open",
44
+ "data encrypted",
45
+ "important files",
46
+ "data stolen",
47
+ "damage files",
48
+ "decrypt file",
49
+ "tor browser http",
50
+ "leaked data",
51
+ "recover data",
52
+ "tor browser site",
53
+ "using tor",
54
+ "decrypt data",
55
+ "decrypt file free",
56
+ "install tor browser site",
57
+ "key snip",
58
+ "tor browser site https",
59
+ "using tor browser",
60
+ "decryption key",
61
+ "onion login",
62
+ "password snip",
63
+ "site https torproject",
64
+ "site https torproject org",
65
+ "tor browser download",
66
+ "browser https torproject",
67
+ "browser https torproject org",
68
+ "browser site https torproject",
69
+ "permanent data",
70
+ "permanent data loss",
71
+ "tor browser https torproject",
72
+ "torproject org open",
73
+ "contact soon possible",
74
+ "delete data",
75
+ "don try",
76
+ "encrypted data",
77
+ "https ibb",
78
+ "https ibb snip",
79
+ "ibb snip",
80
+ "onionmail org",
108
81
  ],
109
82
  "macros": [
110
83
  # https://github.com/cuckoosandbox/community/blob/17d57d46ccbca0327a8299cb93abba8604b74df7/modules/signatures/windows/office_enablecontent_ocr.py
@@ -80,14 +80,14 @@ def __extract_passwords_from_lines(texts, password_word, password_regex):
80
80
  password_keyword = f"{password_word}:"
81
81
  for line in texts:
82
82
  if password_keyword in line.lower():
83
- new_passwords = re.split(password_regex, line)
83
+ new_passwords = set(re.split(password_regex, line))
84
84
  index = line.lower().rindex(password_keyword)
85
85
  if index > 0 and line[index - 1] != " ":
86
86
  special_char = line[index - 1]
87
87
  if special_char in BRACKET_PAIRS:
88
88
  special_char = BRACKET_PAIRS[special_char]
89
- for password in new_passwords:
90
- new_passwords.extend([password[:i] for i, ltr in enumerate(password) if ltr == special_char])
89
+ for password in list(new_passwords):
90
+ new_passwords.update([password[:i] for i, ltr in enumerate(password) if ltr == special_char])
91
91
 
92
92
  new_passwords = set(new_passwords)
93
93
  new_passwords.discard("")
@@ -121,7 +121,8 @@ def _is_dev_mode() -> bool:
121
121
  stack_trace.seek(0)
122
122
  read_stack_trace = stack_trace.read()
123
123
 
124
- if any(msg in read_stack_trace for msg in ['run_service_once', 'pytest', 'assemblyline_v4_service.testing.helper']):
124
+ if any(msg in read_stack_trace
125
+ for msg in ['run_service_once', 'pytest', 'assemblyline_service_utilites.testing.helper']):
125
126
  return True
126
127
 
127
128
  return False
@@ -1,6 +1,5 @@
1
1
  import argparse
2
2
  import cProfile
3
- import importlib
4
3
  import json
5
4
  import logging
6
5
  import os
@@ -9,8 +8,6 @@ import shutil
9
8
  import tempfile
10
9
  from typing import Dict, Union
11
10
 
12
- from cart import get_metadata_only, unpack_stream
13
-
14
11
  from assemblyline.common import forge
15
12
  from assemblyline.common.heuristics import HeuristicHandler, InvalidHeuristicException
16
13
  from assemblyline.common.importing import load_module_by_path
@@ -22,11 +19,12 @@ from assemblyline.odm.models.service import Service
22
19
  from assemblyline_v4_service.common.base import ServiceBase
23
20
  from assemblyline_v4_service.common.helper import get_heuristics, get_service_manifest
24
21
  from assemblyline_v4_service.dev.updater import load_rules
22
+ from cart import get_metadata_only, unpack_stream
25
23
 
26
24
 
27
25
  class RunService:
28
26
  def __init__(self):
29
- self.service: ServiceBase = None
27
+ self.service: Union[ServiceBase, None] = None
30
28
  self.service_class = None
31
29
  self.submission_params = None
32
30
  self.file_dir = None
@@ -185,7 +183,7 @@ class RunService:
185
183
  LOG.info(f"Cleaning up file used for temporary processing: {target_file}")
186
184
  os.unlink(target_file)
187
185
 
188
- if self.service.rules_directory:
186
+ if self.service.rules_directory and self.service.rules_directory != "/":
189
187
  LOG.info("Cleaning up downloaded signatures..")
190
188
  shutil.rmtree(self.service.rules_directory)
191
189
 
@@ -3,23 +3,22 @@ import json
3
3
  import os
4
4
  import shutil
5
5
  import tempfile
6
- import yaml
7
-
8
- from json import JSONDecodeError
9
6
  from io import BytesIO
7
+ from json import JSONDecodeError
8
+
9
+ import yaml
10
+ from assemblyline_core.server_base import ServerBase
11
+ from assemblyline_core.tasking_client import TaskingClient
10
12
 
11
- from assemblyline.common import forge
12
13
  from assemblyline.common.digests import get_sha256_for_file
13
14
  from assemblyline.common.importing import load_module_by_path
14
15
  from assemblyline.common.metrics import MetricsFactory
15
16
  from assemblyline.common.str_utils import StringTable
16
- from assemblyline.common.version import FRAMEWORK_VERSION, SYSTEM_VERSION, BUILD_MINOR
17
+ from assemblyline.common.version import BUILD_MINOR, FRAMEWORK_VERSION, SYSTEM_VERSION
17
18
  from assemblyline.filestore import FileStoreException
18
- from assemblyline.remote.datatypes import get_client
19
19
  from assemblyline.odm.messages.service_heartbeat import Metrics
20
20
  from assemblyline.odm.messages.task import Task as ServiceTask
21
- from assemblyline_core.tasking_client import TaskingClient
22
- from assemblyline_core.server_base import ServerBase
21
+ from assemblyline.remote.datatypes import get_client
23
22
  from assemblyline_v4_service.common.base import is_recoverable_runtime_error
24
23
 
25
24
  SERVICE_PATH = os.environ['SERVICE_PATH']
@@ -74,7 +73,7 @@ class RunPrivilegedService(ServerBase):
74
73
 
75
74
  self.status = STATUSES.INITIALIZING
76
75
  self.metric_factory = None
77
-
76
+
78
77
  def _load_manifest(self):
79
78
  bio = BytesIO()
80
79
  with open(SERVICE_MANIFEST, "rb") as srv_manifest:
@@ -126,6 +125,7 @@ class RunPrivilegedService(ServerBase):
126
125
 
127
126
  # Load on-disk manifest for bootstrap/registration
128
127
  service_manifest = self._load_manifest()
128
+ file_required = service_manifest.get('file_required', True)
129
129
 
130
130
  # Register the service
131
131
  registration = self.tasking_client.register_service(service_manifest)
@@ -146,7 +146,6 @@ class RunPrivilegedService(ServerBase):
146
146
  self.service_tool_version = self.service.get_tool_version()
147
147
  self.metric_factory = MetricsFactory('service', Metrics, name=self.service_name,
148
148
  export_zero=False, redis=self.redis)
149
- file_required = self.service_config.get('file_required', True)
150
149
 
151
150
  # Start the service
152
151
  self.service.start_service()
@@ -12,6 +12,7 @@ import psutil
12
12
  import regex as re
13
13
  import requests
14
14
  from git import Repo
15
+ from azure.identity import DefaultAzureCredential
15
16
 
16
17
  from assemblyline.common.digests import get_sha256_for_file
17
18
  from assemblyline.common.identify import Identify
@@ -162,7 +163,7 @@ def url_download(source: Dict[str, Any], previous_update: int, logger: Logger, o
162
163
  format = ident_type.split('archive/')[-1]
163
164
 
164
165
  # Make sure identified format is supported by the library
165
- format = format if format in ["zip", "tar"] else None
166
+ format = {"zip": "zip", "tar": "tar", "gzip": "gztar"}.get(format)
166
167
  shutil.unpack_archive(file_path, extract_dir=extract_dir, format=format)
167
168
 
168
169
  return extract_dir
@@ -187,6 +188,7 @@ def git_clone_repo(source: Dict[str, Any], previous_update: int = None, logger=N
187
188
  name = source['name']
188
189
  url = source['uri']
189
190
  key = source.get('private_key', None)
191
+ use_managed_identity = source.get('use_managed_identity', False)
190
192
  username = source.get('username', None)
191
193
  password = source.get('password', None)
192
194
  branch = source.get('git_branch', None) or None
@@ -195,15 +197,29 @@ def git_clone_repo(source: Dict[str, Any], previous_update: int = None, logger=N
195
197
  ca_cert = source.get("ca_cert")
196
198
  proxy = source.get('proxy', None)
197
199
  auth = None
198
- if username and password:
200
+ git_env = {}
201
+
202
+ if use_managed_identity:
203
+ # Get Azure managed identity token
204
+ try:
205
+ credential = DefaultAzureCredential()
206
+ except Exception as e:
207
+ logger.warning(f"No managed identity available: {str(e)}")
208
+ raise SkipSource()
209
+ # Get token for Azure DevOps scope
210
+ token = credential.get_token("499b84ac-1321-427f-aa17-267ca6975798/.default")
211
+
212
+ git_env['GIT_CONFIG_COUNT'] = '1'
213
+ git_env['GIT_CONFIG_KEY_0'] = 'http.extraheader'
214
+ git_env['GIT_CONFIG_VALUE_0'] = f'AUTHORIZATION: bearer {token.token}'
215
+ auth = None
216
+ elif username and password:
199
217
  # Basic authentication scheme
200
218
  auth = f'{username}:{password}@'
201
219
  elif password:
202
220
  # Token-based authentication
203
221
  auth = f'{password}@'
204
222
 
205
- git_env = {}
206
-
207
223
  if ignore_ssl_errors:
208
224
  git_env['GIT_SSL_NO_VERIFY'] = '1'
209
225
 
@@ -177,7 +177,8 @@ class ServiceUpdater(ThreadedCoreBase):
177
177
  return 0
178
178
 
179
179
  def get_local_update_hash(self) -> str:
180
- return hashlib.sha256(open(self._update_tar, "rb").read()).hexdigest()
180
+ with open(self._update_tar, "rb") as tar_file:
181
+ return hashlib.sha256(tar_file.read()).hexdigest()
181
182
 
182
183
  def status(self):
183
184
  return {
@@ -584,7 +585,9 @@ class ServiceUpdater(ThreadedCoreBase):
584
585
  source.name: {'classification': source['default_classification'].value}
585
586
  for source in self._service.update_config.sources
586
587
  }
587
- open(os.path.join(new_directory, SIGNATURES_META_FILENAME), 'w').write(json.dumps(signature_map, indent=2))
588
+
589
+ with open(os.path.join(new_directory, SIGNATURES_META_FILENAME), 'w') as meta_file:
590
+ meta_file.write(json.dumps(signature_map, indent=2))
588
591
 
589
592
  try:
590
593
  # Tar update directory
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: assemblyline-v4-service
3
- Version: 4.6.0.dev7
3
+ Version: 4.6.0.23
4
4
  Summary: Assemblyline 4 - Service base
5
5
  Home-page: https://github.com/CybercentreCanada/assemblyline-v4-service/
6
6
  Author: CCCS Assemblyline development team
@@ -1,30 +1,30 @@
1
- assemblyline_v4_service/VERSION,sha256=RXif7lViUl2L5dgXfZbvMKnNzXb6AtzBTGVMAhZYWeM,11
1
+ assemblyline_v4_service/VERSION,sha256=lNW-OljxL5aGkQmUD36vHwW5TAY2vv5qq0ECHx0RZ24,9
2
2
  assemblyline_v4_service/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
3
  assemblyline_v4_service/healthz.py,sha256=3QGBg0EZuXC6UN411HFwpLNEop9UvS9feFhvBUTP-k4,1576
4
4
  assemblyline_v4_service/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
- assemblyline_v4_service/run_privileged_service.py,sha256=IRqhG5ULKjOuy7-W4Fm_R0xb3HPhBlF5iHwNyRBHIME,14535
5
+ assemblyline_v4_service/run_privileged_service.py,sha256=un2zcZjQVKYwMWihLLmeUc3IMJ6ALnFbR1FPeMW1U2A,14486
6
6
  assemblyline_v4_service/run_service.py,sha256=XfdABk3hEZsIw31tmFcJc-FbcxvBF9tiDIlg9oHCtZA,5900
7
7
  assemblyline_v4_service/common/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
- assemblyline_v4_service/common/api.py,sha256=Xzp8j4HCCfjPvNSGKiZl5ttH2_Itg47cjlH0NXNtth0,6849
8
+ assemblyline_v4_service/common/api.py,sha256=59XcuHxOpR4gSZI0foNqOaRh7IINTGvWD-pjEUrU-jU,6823
9
9
  assemblyline_v4_service/common/base.py,sha256=psivTxiOeN2jqL3G3I26oY9JFK-qPuwrg5y_y_d7xYs,14127
10
10
  assemblyline_v4_service/common/helper.py,sha256=xs9quuf-M1JOdKieBqOmWaOece0CtzXFhhe85xQYmuY,3289
11
- assemblyline_v4_service/common/ocr.py,sha256=3fV0PyY3oui_ucAM9dkolP0VRYKACKJuGY4M64DudIE,8841
11
+ assemblyline_v4_service/common/ocr.py,sha256=NgkFqAq2lRzIveYUulKJmiiWYqwf4siYbL59n1Ow02o,8350
12
12
  assemblyline_v4_service/common/ontology_helper.py,sha256=9Ad81qbddg_pRMupT8o_KzxbKgpodaRqpc3mPoEKLtw,8494
13
13
  assemblyline_v4_service/common/request.py,sha256=W7fqC2xQE3i5i2jlCDyUDp3ZqJQQqSshNW0mQfJMkFg,11792
14
14
  assemblyline_v4_service/common/result.py,sha256=9AqM6qCYiia_Bpyn_fBFhzNQMcqJbtFSiGjp57fXW2E,32713
15
15
  assemblyline_v4_service/common/task.py,sha256=dJsvRpW0x88CCF_LW6w87jQ_UKTVaOs2Gb117IDNiU8,14233
16
- assemblyline_v4_service/common/utils.py,sha256=k2__d-V5LjB6o2IKbjVe7tJWKcKuUHto5TyT5oKhIa0,3890
16
+ assemblyline_v4_service/common/utils.py,sha256=FDFsFcI6wt-pWyeQYnDWivsPbtme5RqVyofmNiggh6Y,3922
17
17
  assemblyline_v4_service/dev/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
18
- assemblyline_v4_service/dev/run_service_once.py,sha256=wx_82hGwavxWhMsmNDfmlYs4KbcLnqeMg91ZGfXTZV0,10621
18
+ assemblyline_v4_service/dev/run_service_once.py,sha256=W9kR49IUbkt8tNXjCT40ZMh-8p5W_odxlkDx6nhTAYM,10656
19
19
  assemblyline_v4_service/dev/updater.py,sha256=b-FK6XPRZbETbl-SIYEhnYGT-W7EcQhnxwD6x2NMC7g,6411
20
20
  assemblyline_v4_service/updater/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
21
21
  assemblyline_v4_service/updater/__main__.py,sha256=9Os-u8Tf7MD73JSrUSPmOaErTgfvesNLiEeszU4ujXA,133
22
22
  assemblyline_v4_service/updater/app.py,sha256=Mtmx4bkXfP4nFqqa5q15jW8QIXr4JK84lCovxAVyvPs,3317
23
23
  assemblyline_v4_service/updater/client.py,sha256=tLY84gaGdFBVIDaMgRHIEa7x2S8jBl7lQLzp4seC6aI,11200
24
24
  assemblyline_v4_service/updater/gunicorn_config.py,sha256=p3j2KPBeD5jvMw9O5i7vAtlRgPSVVxIG9AO0DfN82J8,1247
25
- assemblyline_v4_service/updater/helper.py,sha256=Zy6OBmbTh0YurW0MnM0wM92vaKYMbo_MKnafe_5ONUI,10034
26
- assemblyline_v4_service/updater/updater.py,sha256=kli-5v1uVmk2FARAI9DsZ9YM4EhgirkmWJaMJWdm9GI,31795
27
- assemblyline_v4_service-4.6.0.dev7.dist-info/licenses/LICENCE.md,sha256=NSkYo9EH8h5oOkzg4VhjAHF4339MqPP2cQ8msTPgl-c,1396
25
+ assemblyline_v4_service/updater/helper.py,sha256=OTV6WA77wBDOSVWaxijNg-HpwvEwnZozH03S3Q4oUns,10764
26
+ assemblyline_v4_service/updater/updater.py,sha256=XiqabDp89-t_J6C3U33R-RvA5lMIahFW_MsAVUGyXok,31876
27
+ assemblyline_v4_service-4.6.0.23.dist-info/licenses/LICENCE.md,sha256=NSkYo9EH8h5oOkzg4VhjAHF4339MqPP2cQ8msTPgl-c,1396
28
28
  test/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
29
29
  test/conftest.py,sha256=W3SieQpZsZpGEmtLqY4aIlxREDSsHceyCrFcFsWUM0U,1851
30
30
  test/test_healthz.py,sha256=DkeLUlrb7rGx3nZ04aADU9HXXu5mZTf_DBwT0xhzIv4,7
@@ -34,13 +34,13 @@ test/test_common/__init__.py,sha256=RkOm3vnVp5L947mD1jTo4bdOgLTZJ24_NX-kqfMn5a8,
34
34
  test/test_common/test_api.py,sha256=7wlo7wgB12T23zMLbwjJ3GIomLHqE_Qvs3xkibSsR1U,4902
35
35
  test/test_common/test_base.py,sha256=fuJSSlPxIDHq6HU1xbvaMFitw2z1spOZNHD2SJ4UUic,13346
36
36
  test/test_common/test_helper.py,sha256=sO6YAiBhKTqaxlpLhFYDuy2ZdbuF2cg07Ylzo83ZzQs,2575
37
- test/test_common/test_ocr.py,sha256=mt_PgElgwQKJmNrp2nRVx9NjfMedVk40I6IV317vATI,1753
37
+ test/test_common/test_ocr.py,sha256=X_Y3c_yfRljD0o2SRUHuotKLTTX0lD5zW68mzQ7LKu4,1250
38
38
  test/test_common/test_ontology_helper.py,sha256=Q9-Eqeo8Ih7XlbFmlUAXCtgnfW8JCDqqlYFb56077h4,10331
39
- test/test_common/test_request.py,sha256=Ceyds8BNO1O0f1kH1VEb84faJcaupvSjVKIrGdHexsc,11842
40
- test/test_common/test_result.py,sha256=6BiOKxEPrKBjOY44jv3TY-yiXm0qI1ok_CZBnjP9TM4,45447
39
+ test/test_common/test_request.py,sha256=HiDU1n4Rjso_U0qDME4ohA_9j7rpfqLSD1-e2RfqDYs,11186
40
+ test/test_common/test_result.py,sha256=ZtLUddBDA_BTIjG3Jasbq78_AdEjCRe4cb85XLBwH5o,43585
41
41
  test/test_common/test_task.py,sha256=P44mNcSe-3tJgDk9ppN3KbM7oN4LBVIuhONG-Gveh74,19007
42
42
  test/test_common/test_utils.py,sha256=TbnBxqpS_ZC5ptXR9XJX3xtbItD0mTbtiBxxdyP8J5k,5904
43
- assemblyline_v4_service-4.6.0.dev7.dist-info/METADATA,sha256=AN3yICWqA4Zrg2qxniucq_N-mwp-MhTfZvCM5oKYQH4,5623
44
- assemblyline_v4_service-4.6.0.dev7.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
45
- assemblyline_v4_service-4.6.0.dev7.dist-info/top_level.txt,sha256=LpTOEaVCatkrvbVq3EZseMSIa2PQZU-2rhuO_FTpZgY,29
46
- assemblyline_v4_service-4.6.0.dev7.dist-info/RECORD,,
43
+ assemblyline_v4_service-4.6.0.23.dist-info/METADATA,sha256=qlCtnIYJy133FR_xB5Cbv1Mg8RdLqAVLSD4-PpZ8UaM,5621
44
+ assemblyline_v4_service-4.6.0.23.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
45
+ assemblyline_v4_service-4.6.0.23.dist-info/top_level.txt,sha256=LpTOEaVCatkrvbVq3EZseMSIa2PQZU-2rhuO_FTpZgY,29
46
+ assemblyline_v4_service-4.6.0.23.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (78.1.0)
2
+ Generator: setuptools (80.9.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,29 +1,29 @@
1
1
  import os
2
- from test.test_common import TESSERACT_LIST
3
2
 
4
3
  import pytest
4
+ from assemblyline_v4_service.common.ocr import (
5
+ detections,
6
+ ocr_detections,
7
+ update_ocr_config,
8
+ )
9
+
10
+ from test.test_common import TESSERACT_LIST
5
11
 
6
- from assemblyline_v4_service.common.ocr import ocr_detections, detections, update_ocr_config
7
12
 
8
- @pytest.mark.skipif(len(TESSERACT_LIST) < 1, reason="Requires tesseract-ocr apt package")
13
+ @pytest.mark.skipif(
14
+ len(TESSERACT_LIST) < 1, reason="Requires tesseract-ocr apt package"
15
+ )
9
16
  def test_ocr_detections():
10
17
  update_ocr_config()
11
- file_path = os.path.join(os.path.dirname(__file__), "b32969aa664e3905c20f865cdd7b921f922678f5c3850c78e4c803fbc1757a8e")
18
+ file_path = os.path.join(
19
+ os.path.dirname(__file__),
20
+ "094177fc6c4642f12fbf6dce18f272227ace95576ff1765384902d2abebf09bf",
21
+ )
12
22
  assert ocr_detections(file_path) == {
13
- 'ransomware': [
14
- "YOUR FILES HAVE BEEN ENCRYPTED AND YOU WON'T BE ABLE TO "
15
- 'DECRYPT THEM.',
16
- 'YOU CAN BUY DECRYPTION SOFTWARE FROM US, THIS SOFTWARE WILL '
17
- 'ALLOW YOU TO RECOVER ALL OF YOUR DATA AND',
18
- 'RANSOMWARE FROM YOUR COMPUTER. THE PRICE OF THE SOFTWARE IS '
19
- '$.2..%.. PAYMENT CAN BE MADE IN BITCOIN OR XMR.',
20
- 'How 00! PAY, WHERE DO | GET BITCOIN OR XMR?',
21
- 'YOURSELF TO FIND OUT HOW TO BUY BITCOIN OR XMR.',
22
- 'PAYMENT INFORMATION: SEND $15, TO ONE OF OUR CRYPTO '
23
- 'ADDRESSES, THEN SEND US EMAIL WITH PAYMENT',
24
- "CONFIRMATION AND YOU'LL GET THE DECRYPTION SOFTWARE IN EMAIL.",
25
- "BTC ADDRESS : bciqsht77cpgw7kv420r4secmu88g34wvn96dsyc5s",
26
- ],
23
+ "ransomware": [
24
+ "YOU CAN BUY DECRYPTION SOFTWARE FROM US, THIS SOFTWARE WILL ALLOW YOU TO RECOVER ALL OF YOUR DATA AND",
25
+ "CONFIRMATION AND YOU'LL GET THE DECRYPTION KEY IN EMAIL.",
26
+ ]
27
27
  }
28
28
 
29
29
 
@@ -40,4 +40,6 @@ def test_detections():
40
40
  assert detections("blah\nrecover them\nblah") == {}
41
41
 
42
42
  # Containing two ransomware strings
43
- assert detections("blah\nrecover them\nblah\nencrypt") == {"ransomware": ["recover them", "encrypt"]}
43
+ assert detections("blah\nrecover data\nblah\nencrypted data") == {
44
+ "ransomware": ["recover data", "encrypted data"]
45
+ }
@@ -1,7 +1,6 @@
1
1
  import os
2
2
  import tempfile
3
3
  from logging import Logger
4
- from test.test_common import TESSERACT_LIST, setup_module
5
4
 
6
5
  import pytest
7
6
  from assemblyline_v4_service.common.request import ServiceRequest
@@ -9,6 +8,7 @@ from assemblyline_v4_service.common.result import Result, get_heuristic_primitiv
9
8
  from assemblyline_v4_service.common.task import MaxExtractedExceeded, Task
10
9
 
11
10
  from assemblyline.odm.messages.task import Task as ServiceTask
11
+ from test.test_common import TESSERACT_LIST, setup_module
12
12
 
13
13
  # Ensure service manifest is instantiated before importing from OCR submodule
14
14
  setup_module()
@@ -112,19 +112,19 @@ def test_add_extracted(service_request):
112
112
  def test_add_image(service_request):
113
113
  image_path = os.path.join(
114
114
  os.path.dirname(__file__),
115
- "b32969aa664e3905c20f865cdd7b921f922678f5c3850c78e4c803fbc1757a8e")
115
+ "094177fc6c4642f12fbf6dce18f272227ace95576ff1765384902d2abebf09bf")
116
116
 
117
117
  # Basic
118
118
  assert service_request.add_image(image_path, "image_name", "description of image") == {
119
119
  'img': {
120
120
  'description': 'description of image',
121
121
  'name': 'image_name',
122
- 'sha256': '09bf99ab5431af13b701a06dc2b04520aea9fd346584fa2a034d6d4af0c57329'
122
+ 'sha256': 'f52a9f1cf33e800e804c100908206525d794f15a92d9637dc03226a84e26810f'
123
123
  },
124
124
  'thumb': {
125
125
  'description': 'description of image (thumbnail)',
126
126
  'name': 'image_name.thumb',
127
- 'sha256': '1af0e0d99845493b64cf402b3704170f17ecf15001714016e48f9d4854218901'
127
+ 'sha256': '00b5239a2d010b64e2a35fae38671bdda44c60cc4008af361d98bb1d12a845e8'
128
128
  }
129
129
  }
130
130
 
@@ -139,7 +139,7 @@ def test_add_image(service_request):
139
139
  'is_supplementary': True,
140
140
  'name': 'image_name',
141
141
  'parent_relation': 'INFORMATION',
142
- 'sha256': '09bf99ab5431af13b701a06dc2b04520aea9fd346584fa2a034d6d4af0c57329'
142
+ 'sha256': 'f52a9f1cf33e800e804c100908206525d794f15a92d9637dc03226a84e26810f'
143
143
  },
144
144
  {
145
145
  'allow_dynamic_recursion': False,
@@ -149,7 +149,7 @@ def test_add_image(service_request):
149
149
  'is_supplementary': True,
150
150
  'name': 'image_name.thumb',
151
151
  'parent_relation': 'INFORMATION',
152
- 'sha256': '1af0e0d99845493b64cf402b3704170f17ecf15001714016e48f9d4854218901'
152
+ 'sha256': '00b5239a2d010b64e2a35fae38671bdda44c60cc4008af361d98bb1d12a845e8'
153
153
  },
154
154
  ]
155
155
 
@@ -164,31 +164,19 @@ def test_add_image(service_request):
164
164
  assert data["img"] == {
165
165
  'description': 'description of image',
166
166
  'name': 'image_name',
167
- 'sha256': '09bf99ab5431af13b701a06dc2b04520aea9fd346584fa2a034d6d4af0c57329'
167
+ 'sha256': 'f52a9f1cf33e800e804c100908206525d794f15a92d9637dc03226a84e26810f'
168
168
  }
169
169
  assert data["thumb"] == {
170
170
  'description': 'description of image (thumbnail)',
171
171
  'name': 'image_name.thumb',
172
- 'sha256': '1af0e0d99845493b64cf402b3704170f17ecf15001714016e48f9d4854218901'
172
+ 'sha256': '00b5239a2d010b64e2a35fae38671bdda44c60cc4008af361d98bb1d12a845e8'
173
173
  }
174
174
  assert data["ocr_section"].__dict__["section_body"].__dict__ == {
175
175
  '_config': {},
176
176
  '_data': {
177
- 'ransomware': [
178
- "YOUR FILES HAVE BEEN ENCRYPTED AND YOU WON'T BE "
179
- 'ABLE TO DECRYPT THEM.',
180
- 'YOU CAN BUY DECRYPTION SOFTWARE FROM US, THIS '
181
- 'SOFTWARE WILL ALLOW YOU TO RECOVER ALL OF YOUR DATA '
182
- 'AND',
183
- 'RANSOMWARE FROM YOUR COMPUTER. THE PRICE OF THE '
184
- 'SOFTWARE IS $.2..%.. PAYMENT CAN BE MADE IN BITCOIN '
185
- 'OR XMR.',
186
- 'How 00! PAY, WHERE DO | GET BITCOIN OR XMR?',
187
- 'YOURSELF TO FIND OUT HOW TO BUY BITCOIN OR XMR.',
188
- 'PAYMENT INFORMATION: SEND $15, TO ONE OF OUR CRYPTO '
189
- 'ADDRESSES, THEN SEND US EMAIL WITH PAYMENT',
190
- "CONFIRMATION AND YOU'LL GET THE DECRYPTION SOFTWARE IN EMAIL.",
191
- "BTC ADDRESS : bciqsht77cpgw7kv420r4secmu88g34wvn96dsyc5s",
177
+ "ransomware": [
178
+ "YOU CAN BUY DECRYPTION SOFTWARE FROM US, THIS SOFTWARE WILL ALLOW YOU TO RECOVER ALL OF YOUR DATA AND",
179
+ "CONFIRMATION AND YOU'LL GET THE DECRYPTION KEY IN EMAIL.",
192
180
  ]
193
181
  },
194
182
  '_format': 'KEY_VALUE'
@@ -197,8 +185,8 @@ def test_add_image(service_request):
197
185
  heur_dict = get_heuristic_primitives(data["ocr_section"].__dict__["_heuristic"])
198
186
 
199
187
  assert heur_dict == {
200
- 'heur_id': 1, 'score': 1200, 'attack_ids': ['T1005'],
201
- 'signatures': {'ransomware_strings': 8},
188
+ 'heur_id': 1, 'score': 500, 'attack_ids': ['T1005'],
189
+ 'signatures': {'ransomware_strings': 2},
202
190
  'frequency': 0, 'score_map': {}}
203
191
 
204
192
  assert service_request.temp_submission_data == {}
@@ -1,17 +1,50 @@
1
- from assemblyline.odm.messages.task import Task as ServiceTask
2
- from assemblyline_v4_service.common.task import Task
3
- from assemblyline_v4_service.common.result import (
4
- BODY_FORMAT, DividerSectionBody, GraphSectionBody, Heuristic, ImageSectionBody, InvalidFunctionException,
5
- InvalidHeuristicException, JSONSectionBody, KVSectionBody, MemorydumpSectionBody, MultiSectionBody,
6
- OrderedKVSectionBody, ProcessItem, ProcessTreeSectionBody, Result, ResultAggregationException, ResultGraphSection,
7
- ResultImageSection, ResultJSONSection, ResultKeyValueSection, ResultMemoryDumpSection, ResultMultiSection,
8
- ResultOrderedKeyValueSection, ResultProcessTreeSection, ResultSection, ResultTableSection, ResultTextSection,
9
- ResultTimelineSection, ResultURLSection, SectionBody, TableRow, TableSectionBody, TextSectionBody,
10
- TimelineSectionBody, TypeSpecificResultSection, URLSectionBody, get_heuristic_primitives)
11
- from assemblyline_v4_service.common.request import ServiceRequest
12
- import pytest
13
1
  import os
14
2
  import tempfile
3
+
4
+ import pytest
5
+ from assemblyline_v4_service.common.request import ServiceRequest
6
+ from assemblyline_v4_service.common.result import (
7
+ BODY_FORMAT,
8
+ DividerSectionBody,
9
+ GraphSectionBody,
10
+ Heuristic,
11
+ ImageSectionBody,
12
+ InvalidFunctionException,
13
+ InvalidHeuristicException,
14
+ JSONSectionBody,
15
+ KVSectionBody,
16
+ MemorydumpSectionBody,
17
+ MultiSectionBody,
18
+ OrderedKVSectionBody,
19
+ ProcessItem,
20
+ ProcessTreeSectionBody,
21
+ Result,
22
+ ResultAggregationException,
23
+ ResultGraphSection,
24
+ ResultImageSection,
25
+ ResultJSONSection,
26
+ ResultKeyValueSection,
27
+ ResultMemoryDumpSection,
28
+ ResultMultiSection,
29
+ ResultOrderedKeyValueSection,
30
+ ResultProcessTreeSection,
31
+ ResultSection,
32
+ ResultTableSection,
33
+ ResultTextSection,
34
+ ResultTimelineSection,
35
+ ResultURLSection,
36
+ SectionBody,
37
+ TableRow,
38
+ TableSectionBody,
39
+ TextSectionBody,
40
+ TimelineSectionBody,
41
+ TypeSpecificResultSection,
42
+ URLSectionBody,
43
+ get_heuristic_primitives,
44
+ )
45
+ from assemblyline_v4_service.common.task import Task
46
+
47
+ from assemblyline.odm.messages.task import Task as ServiceTask
15
48
  from test.test_common import TESSERACT_LIST, setup_module
16
49
 
17
50
  # Ensure service manifest is instantiated before importing from OCR submodule
@@ -602,18 +635,18 @@ def test_imagesectionbody_add_image(service_request):
602
635
  isb = ImageSectionBody(service_request)
603
636
  image_path = os.path.join(
604
637
  os.path.dirname(__file__),
605
- "b32969aa664e3905c20f865cdd7b921f922678f5c3850c78e4c803fbc1757a8e")
638
+ "094177fc6c4642f12fbf6dce18f272227ace95576ff1765384902d2abebf09bf")
606
639
 
607
640
  # Basic
608
641
  assert isb.add_image(image_path, "image_name", "description of image") is None
609
642
  assert isb._data == [
610
643
  {'img': {
611
644
  'name': 'image_name',
612
- 'sha256': '09bf99ab5431af13b701a06dc2b04520aea9fd346584fa2a034d6d4af0c57329',
645
+ 'sha256': 'f52a9f1cf33e800e804c100908206525d794f15a92d9637dc03226a84e26810f',
613
646
  'description': 'description of image'},
614
647
  'thumb': {
615
648
  'name': 'image_name.thumb',
616
- 'sha256': '1af0e0d99845493b64cf402b3704170f17ecf15001714016e48f9d4854218901',
649
+ 'sha256': '00b5239a2d010b64e2a35fae38671bdda44c60cc4008af361d98bb1d12a845e8',
617
650
  'description': 'description of image (thumbnail)'}}]
618
651
 
619
652
  isb._data.clear()
@@ -623,23 +656,15 @@ def test_imagesectionbody_add_image(service_request):
623
656
  _, path = tempfile.mkstemp()
624
657
  ocr_io = open(path, "w")
625
658
  assert isb.add_image(image_path, "image_name", "description of image", "TLP:A", ocr_heuristic_id,
626
- ocr_io).body == '{"ransomware": ["YOUR FILES HAVE BEEN ENCRYPTED AND YOU WON\'T BE ABLE TO ' \
627
- 'DECRYPT THEM.", "YOU CAN BUY DECRYPTION SOFTWARE FROM US, THIS SOFTWARE ' \
628
- 'WILL ALLOW YOU TO RECOVER ALL OF YOUR DATA AND", "RANSOMWARE FROM YOUR ' \
629
- 'COMPUTER. THE PRICE OF THE SOFTWARE IS $.2..%.. PAYMENT CAN BE MADE IN ' \
630
- 'BITCOIN OR XMR.", "How 00! PAY, WHERE DO | GET BITCOIN OR XMR?", "YOURSELF ' \
631
- 'TO FIND OUT HOW TO BUY BITCOIN OR XMR.", "PAYMENT INFORMATION: SEND $15, ' \
632
- 'TO ONE OF OUR CRYPTO ADDRESSES, THEN SEND US EMAIL WITH PAYMENT", ' \
633
- '"CONFIRMATION AND YOU\'LL GET THE DECRYPTION SOFTWARE IN EMAIL.", ' \
634
- '"BTC ADDRESS : bciqsht77cpgw7kv420r4secmu88g34wvn96dsyc5s"]}'
659
+ ocr_io).body == '{"ransomware": ["YOU CAN BUY DECRYPTION SOFTWARE FROM US, THIS SOFTWARE WILL ALLOW YOU TO RECOVER ALL OF YOUR DATA AND", "CONFIRMATION AND YOU\'LL GET THE DECRYPTION KEY IN EMAIL."]}'
635
660
  assert isb._data == [
636
661
  {'img': {
637
662
  'name': 'image_name',
638
- 'sha256': '09bf99ab5431af13b701a06dc2b04520aea9fd346584fa2a034d6d4af0c57329',
663
+ 'sha256': 'f52a9f1cf33e800e804c100908206525d794f15a92d9637dc03226a84e26810f',
639
664
  'description': 'description of image'},
640
665
  'thumb': {
641
666
  'name': 'image_name.thumb',
642
- 'sha256': '1af0e0d99845493b64cf402b3704170f17ecf15001714016e48f9d4854218901',
667
+ 'sha256': '00b5239a2d010b64e2a35fae38671bdda44c60cc4008af361d98bb1d12a845e8',
643
668
  'description': 'description of image (thumbnail)'}}]
644
669
 
645
670
 
@@ -1281,18 +1306,18 @@ def test_resultimagesection_add_image(service_request):
1281
1306
  ris = ResultImageSection(service_request, "title_text_as_str")
1282
1307
 
1283
1308
  image_path = os.path.join(os.path.dirname(__file__),
1284
- "b32969aa664e3905c20f865cdd7b921f922678f5c3850c78e4c803fbc1757a8e")
1309
+ "094177fc6c4642f12fbf6dce18f272227ace95576ff1765384902d2abebf09bf")
1285
1310
 
1286
1311
  # Basic
1287
1312
  assert ris.add_image(image_path, "image_name", "description of image") is None
1288
1313
  assert ris.section_body._data == [{
1289
1314
  'img':
1290
1315
  {'name': 'image_name',
1291
- 'sha256': '09bf99ab5431af13b701a06dc2b04520aea9fd346584fa2a034d6d4af0c57329',
1316
+ 'sha256': 'f52a9f1cf33e800e804c100908206525d794f15a92d9637dc03226a84e26810f',
1292
1317
  'description': 'description of image'},
1293
1318
  'thumb':
1294
1319
  {'name': 'image_name.thumb',
1295
- 'sha256': '1af0e0d99845493b64cf402b3704170f17ecf15001714016e48f9d4854218901',
1320
+ 'sha256': '00b5239a2d010b64e2a35fae38671bdda44c60cc4008af361d98bb1d12a845e8',
1296
1321
  'description': 'description of image (thumbnail)'}}]
1297
1322
 
1298
1323
  ris = ResultImageSection(service_request, "title_text_as_str")
@@ -1305,11 +1330,11 @@ def test_resultimagesection_add_image(service_request):
1305
1330
  assert ris.section_body._data == [{
1306
1331
  'img':
1307
1332
  {'name': 'image_name',
1308
- 'sha256': '09bf99ab5431af13b701a06dc2b04520aea9fd346584fa2a034d6d4af0c57329',
1333
+ 'sha256': 'f52a9f1cf33e800e804c100908206525d794f15a92d9637dc03226a84e26810f',
1309
1334
  'description': 'description of image'},
1310
1335
  'thumb':
1311
1336
  {'name': 'image_name.thumb',
1312
- 'sha256': '1af0e0d99845493b64cf402b3704170f17ecf15001714016e48f9d4854218901',
1337
+ 'sha256': '00b5239a2d010b64e2a35fae38671bdda44c60cc4008af361d98bb1d12a845e8',
1313
1338
  'description': 'description of image (thumbnail)'}}]
1314
1339
 
1315
1340
  ris = ResultImageSection(service_request, "title_text_as_str")
@@ -1319,26 +1344,15 @@ def test_resultimagesection_add_image(service_request):
1319
1344
  _, path = tempfile.mkstemp()
1320
1345
  ocr_io = open(path, "w")
1321
1346
  assert ris.add_image(image_path, "image_name", "description of image", "TLP:A", ocr_heuristic_id, ocr_io,
1322
- auto_add_ocr_section=False).body == '{"ransomware": ["YOUR FILES HAVE BEEN ENCRYPTED AND ' \
1323
- 'YOU WON\'T BE ABLE TO DECRYPT THEM.", "YOU CAN BUY ' \
1324
- 'DECRYPTION SOFTWARE FROM US, THIS SOFTWARE WILL ALLOW ' \
1325
- 'YOU TO RECOVER ALL OF YOUR DATA AND", "RANSOMWARE FROM ' \
1326
- 'YOUR COMPUTER. THE PRICE OF THE SOFTWARE IS $.2..%.. ' \
1327
- 'PAYMENT CAN BE MADE IN BITCOIN OR XMR.", "How 00! PAY, ' \
1328
- 'WHERE DO | GET BITCOIN OR XMR?", "YOURSELF TO FIND OUT ' \
1329
- 'HOW TO BUY BITCOIN OR XMR.", "PAYMENT INFORMATION: ' \
1330
- 'SEND $15, TO ONE OF OUR CRYPTO ADDRESSES, THEN SEND ' \
1331
- 'US EMAIL WITH PAYMENT", "CONFIRMATION AND YOU\'LL GET ' \
1332
- 'THE DECRYPTION SOFTWARE IN EMAIL.", "BTC ADDRESS : ' \
1333
- 'bciqsht77cpgw7kv420r4secmu88g34wvn96dsyc5s"]}'
1347
+ auto_add_ocr_section=False).body == '{"ransomware": ["YOU CAN BUY DECRYPTION SOFTWARE FROM US, THIS SOFTWARE WILL ALLOW YOU TO RECOVER ALL OF YOUR DATA AND", "CONFIRMATION AND YOU\'LL GET THE DECRYPTION KEY IN EMAIL."]}'
1334
1348
  assert ris.section_body._data == [{
1335
1349
  'img': {
1336
1350
  'name': 'image_name',
1337
- 'sha256': '09bf99ab5431af13b701a06dc2b04520aea9fd346584fa2a034d6d4af0c57329',
1351
+ 'sha256': 'f52a9f1cf33e800e804c100908206525d794f15a92d9637dc03226a84e26810f',
1338
1352
  'description': 'description of image'},
1339
1353
  'thumb': {
1340
1354
  'name': 'image_name.thumb',
1341
- 'sha256': '1af0e0d99845493b64cf402b3704170f17ecf15001714016e48f9d4854218901',
1355
+ 'sha256': '00b5239a2d010b64e2a35fae38671bdda44c60cc4008af361d98bb1d12a845e8',
1342
1356
  'description': 'description of image (thumbnail)'}}]
1343
1357
 
1344
1358
  # Ensure that the image files added are marked as `is_image_section`