blint 2.4.0__tar.gz → 3.0.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.
Files changed (41) hide show
  1. {blint-2.4.0 → blint-3.0.0}/PKG-INFO +32 -20
  2. {blint-2.4.0 → blint-3.0.0}/README.md +17 -5
  3. {blint-2.4.0 → blint-3.0.0}/blint/cli.py +18 -1
  4. {blint-2.4.0 → blint-3.0.0}/blint/config.py +123 -63
  5. blint-3.0.0/blint/data/annotations/review_functions_generic.yml +132 -0
  6. {blint-2.4.0 → blint-3.0.0}/blint/lib/analysis.py +138 -32
  7. {blint-2.4.0 → blint-3.0.0}/blint/lib/android.py +0 -1
  8. {blint-2.4.0 → blint-3.0.0}/blint/lib/binary.py +156 -76
  9. blint-3.0.0/blint/lib/disassembler.py +639 -0
  10. {blint-2.4.0 → blint-3.0.0}/blint/lib/runners.py +78 -17
  11. {blint-2.4.0 → blint-3.0.0}/blint/lib/sbom.py +219 -112
  12. {blint-2.4.0 → blint-3.0.0}/blint/lib/utils.py +61 -2
  13. {blint-2.4.0 → blint-3.0.0}/pyproject.toml +16 -15
  14. {blint-2.4.0 → blint-3.0.0}/LICENSE +0 -0
  15. {blint-2.4.0 → blint-3.0.0}/blint/__init__.py +0 -0
  16. {blint-2.4.0 → blint-3.0.0}/blint/cyclonedx/README.md +0 -0
  17. {blint-2.4.0 → blint-3.0.0}/blint/cyclonedx/__init__.py +0 -0
  18. {blint-2.4.0 → blint-3.0.0}/blint/cyclonedx/spdx.py +0 -0
  19. {blint-2.4.0 → blint-3.0.0}/blint/cyclonedx/spec.py +0 -0
  20. {blint-2.4.0 → blint-3.0.0}/blint/data/__init__.py +0 -0
  21. {blint-2.4.0 → blint-3.0.0}/blint/data/annotations/__init__.py +0 -0
  22. {blint-2.4.0 → blint-3.0.0}/blint/data/annotations/review_entries_generic.yml +0 -0
  23. {blint-2.4.0 → blint-3.0.0}/blint/data/annotations/review_entries_pe.yml +0 -0
  24. {blint-2.4.0 → blint-3.0.0}/blint/data/annotations/review_exe_go.yml +0 -0
  25. {blint-2.4.0 → blint-3.0.0}/blint/data/annotations/review_imports_pe.yml +0 -0
  26. {blint-2.4.0 → blint-3.0.0}/blint/data/annotations/review_methods_generic.yml +0 -0
  27. {blint-2.4.0 → blint-3.0.0}/blint/data/annotations/review_methods_mips.yml +0 -0
  28. {blint-2.4.0 → blint-3.0.0}/blint/data/annotations/review_monero_generic.yml +0 -0
  29. {blint-2.4.0 → blint-3.0.0}/blint/data/annotations/review_monero_go.yml +0 -0
  30. {blint-2.4.0 → blint-3.0.0}/blint/data/annotations/review_monero_rust.yml +0 -0
  31. {blint-2.4.0 → blint-3.0.0}/blint/data/annotations/review_rootkits_win.yml +0 -0
  32. {blint-2.4.0 → blint-3.0.0}/blint/data/annotations/review_symbols_antiforensic.yml +0 -0
  33. {blint-2.4.0 → blint-3.0.0}/blint/data/annotations/review_symbols_generic.yml +0 -0
  34. {blint-2.4.0 → blint-3.0.0}/blint/data/annotations/review_symbols_hooka.yml +0 -0
  35. {blint-2.4.0 → blint-3.0.0}/blint/data/annotations/review_symbols_macho.yml +0 -0
  36. {blint-2.4.0 → blint-3.0.0}/blint/data/annotations/review_symbols_rust.yml +0 -0
  37. {blint-2.4.0 → blint-3.0.0}/blint/data/rules.yml +0 -0
  38. {blint-2.4.0 → blint-3.0.0}/blint/db.py +0 -0
  39. {blint-2.4.0 → blint-3.0.0}/blint/lib/__init__.py +0 -0
  40. {blint-2.4.0 → blint-3.0.0}/blint/lib/checks.py +0 -0
  41. {blint-2.4.0 → blint-3.0.0}/blint/logger.py +0 -0
@@ -1,8 +1,9 @@
1
- Metadata-Version: 2.3
1
+ Metadata-Version: 2.4
2
2
  Name: blint
3
- Version: 2.4.0
3
+ Version: 3.0.0
4
4
  Summary: Linter and SBOM generator for binary files.
5
- License: MIT
5
+ License-Expression: MIT
6
+ License-File: LICENSE
6
7
  Keywords: linter,binary,security,sast
7
8
  Author: Team AppThreat
8
9
  Author-email: cloud@appthreat.com
@@ -17,26 +18,25 @@ Classifier: Programming Language :: Python :: 3.11
17
18
  Classifier: Programming Language :: Python :: 3.12
18
19
  Classifier: Programming Language :: Python :: 3.13
19
20
  Classifier: Operating System :: OS Independent
20
- Provides-Extra: db
21
21
  Provides-Extra: dev
22
22
  Requires-Dist: PyYAML (>=6.0.2)
23
23
  Requires-Dist: appdirs (>=1.4.4)
24
24
  Requires-Dist: apsw (>=3.49.1.0)
25
- Requires-Dist: ar (>=0.9.1)
25
+ Requires-Dist: ar (>=1.0.0)
26
26
  Requires-Dist: black (>=25.1.0) ; extra == "dev"
27
- Requires-Dist: custom-json-diff (>=2.1.5)
27
+ Requires-Dist: custom-json-diff (>=2.1.6)
28
28
  Requires-Dist: defusedxml (>=0.7.1)
29
- Requires-Dist: flake8 (>=7.1.2) ; extra == "dev"
30
- Requires-Dist: lief (>=0.16.4)
31
- Requires-Dist: oras (>=0.2.25) ; extra == "db"
32
- Requires-Dist: orjson (>=3.10.15)
29
+ Requires-Dist: flake8 (>=7.2.0) ; extra == "dev"
30
+ Requires-Dist: lief (>=0.16.6)
31
+ Requires-Dist: oras (>=0.2.28)
32
+ Requires-Dist: orjson (>=3.10.16)
33
33
  Requires-Dist: packageurl-python (>=0.16.0)
34
- Requires-Dist: pydantic[email] (>=2.10.6)
34
+ Requires-Dist: pydantic[email] (>=2.11.3)
35
35
  Requires-Dist: pyinstaller (>=6.12.0) ; extra == "dev"
36
- Requires-Dist: pylint (>=3.3.4) ; extra == "dev"
37
- Requires-Dist: pytest (>=8.3.4) ; extra == "dev"
38
- Requires-Dist: pytest-cov (>=6.0.0) ; extra == "dev"
39
- Requires-Dist: rich (>=13.9.4)
36
+ Requires-Dist: pylint (>=3.3.6) ; extra == "dev"
37
+ Requires-Dist: pytest (>=8.3.5) ; extra == "dev"
38
+ Requires-Dist: pytest-cov (>=6.1.1) ; extra == "dev"
39
+ Requires-Dist: rich (>=14.0.0)
40
40
  Requires-Dist: symbolic (==10.2.1)
41
41
  Project-URL: CI, https://github.com/owasp-dep-scan/blint/actions
42
42
  Description-Content-Type: text/markdown
@@ -56,7 +56,7 @@ Supported binary formats:
56
56
  - PE (exe, dll)
57
57
  - Mach-O (x64, arm64)
58
58
 
59
- You can run blint on Linux, Windows, and Mac against any of these binary formats.
59
+ You can run blint on Linux and Mac against any of these binary formats.
60
60
 
61
61
  ## Motivation
62
62
 
@@ -78,6 +78,12 @@ NOTE: The presence of capabilities doesn't imply that the binary always performs
78
78
  pip install blint
79
79
  ```
80
80
 
81
+ For [disassembly](./docs/DISASSEMBLE.md) support, install the extended group which includes [nyxstone](https://github.com/emproof-com/nyxstone).
82
+
83
+ ```bash
84
+ pip install blint[extended]
85
+ ```
86
+
81
87
  ### Single binary releases
82
88
 
83
89
  You can download single binary builds from the [blint-bin releases](https://github.com/OWASP-dep-scan/blint/releases). These executables should work without requiring python to be installed. The macOS .pkg file is signed with a valid developer account.
@@ -100,6 +106,10 @@ options:
100
106
  --no-reviews Do not perform method reviews.
101
107
  --suggest-fuzzable Suggest functions and symbols for fuzzing based on a dictionary.
102
108
  --use-blintdb Use blintdb for symbol resolution. Use environment variables: BLINTDB_IMAGE_URL, BLINTDB_HOME, and BLINTDB_REFRESH for customization.
109
+ --disassemble Disassemble functions and store the instructions in the metadata. Requires blint extended group to be installed.
110
+ --custom-rules-dir CUSTOM_RULES_DIR
111
+ Path to a directory containing custom YAML rule files (.yml or .yaml). These will be loaded in addition to default rules.
112
+ -q, --quiet Disable logging and progress bars.
103
113
 
104
114
  sub-commands:
105
115
  Additional sub-commands
@@ -159,6 +169,12 @@ Pass `--suggest-fuzzable` to get suggestions for fuzzing. A dictionary containin
159
169
  blint -i ~/ngrok -o /tmp/blint --suggest-fuzzable
160
170
  ```
161
171
 
172
+ To use [custom rules](./docs/RULES.md), use the `--custom-rules-dir` argument.
173
+
174
+ ```
175
+ blint --custom-rules-dir /path/to/my_custom_rules ...
176
+ ```
177
+
162
178
  To generate SBOM in [CycloneDX format](https://cyclonedx.org/) for supported binaries, use the sbom sub-command.
163
179
 
164
180
  ```shell
@@ -217,10 +233,6 @@ sbom command generates CycloneDX json.
217
233
  - [lief examples](https://github.com/lief-project/LIEF/tree/master/examples)
218
234
  - [checksec](https://github.com/Wenzel/checksec.py)
219
235
 
220
- ## Discord support
221
-
222
- The developers can be reached via the [Discord](https://discord.gg/DCNxzaeUpd) channel.
223
-
224
236
  ## Sponsorship wishlist
225
237
 
226
238
  If you love blint, you should consider [donating](https://owasp.org/donate?reponame=www-project-dep-scan&title=OWASP+dep-scan) to our project. In addition, consider donating to the below projects, which make blint possible.
@@ -13,7 +13,7 @@ Supported binary formats:
13
13
  - PE (exe, dll)
14
14
  - Mach-O (x64, arm64)
15
15
 
16
- You can run blint on Linux, Windows, and Mac against any of these binary formats.
16
+ You can run blint on Linux and Mac against any of these binary formats.
17
17
 
18
18
  ## Motivation
19
19
 
@@ -35,6 +35,12 @@ NOTE: The presence of capabilities doesn't imply that the binary always performs
35
35
  pip install blint
36
36
  ```
37
37
 
38
+ For [disassembly](./docs/DISASSEMBLE.md) support, install the extended group which includes [nyxstone](https://github.com/emproof-com/nyxstone).
39
+
40
+ ```bash
41
+ pip install blint[extended]
42
+ ```
43
+
38
44
  ### Single binary releases
39
45
 
40
46
  You can download single binary builds from the [blint-bin releases](https://github.com/OWASP-dep-scan/blint/releases). These executables should work without requiring python to be installed. The macOS .pkg file is signed with a valid developer account.
@@ -57,6 +63,10 @@ options:
57
63
  --no-reviews Do not perform method reviews.
58
64
  --suggest-fuzzable Suggest functions and symbols for fuzzing based on a dictionary.
59
65
  --use-blintdb Use blintdb for symbol resolution. Use environment variables: BLINTDB_IMAGE_URL, BLINTDB_HOME, and BLINTDB_REFRESH for customization.
66
+ --disassemble Disassemble functions and store the instructions in the metadata. Requires blint extended group to be installed.
67
+ --custom-rules-dir CUSTOM_RULES_DIR
68
+ Path to a directory containing custom YAML rule files (.yml or .yaml). These will be loaded in addition to default rules.
69
+ -q, --quiet Disable logging and progress bars.
60
70
 
61
71
  sub-commands:
62
72
  Additional sub-commands
@@ -116,6 +126,12 @@ Pass `--suggest-fuzzable` to get suggestions for fuzzing. A dictionary containin
116
126
  blint -i ~/ngrok -o /tmp/blint --suggest-fuzzable
117
127
  ```
118
128
 
129
+ To use [custom rules](./docs/RULES.md), use the `--custom-rules-dir` argument.
130
+
131
+ ```
132
+ blint --custom-rules-dir /path/to/my_custom_rules ...
133
+ ```
134
+
119
135
  To generate SBOM in [CycloneDX format](https://cyclonedx.org/) for supported binaries, use the sbom sub-command.
120
136
 
121
137
  ```shell
@@ -174,10 +190,6 @@ sbom command generates CycloneDX json.
174
190
  - [lief examples](https://github.com/lief-project/LIEF/tree/master/examples)
175
191
  - [checksec](https://github.com/Wenzel/checksec.py)
176
192
 
177
- ## Discord support
178
-
179
- The developers can be reached via the [Discord](https://discord.gg/DCNxzaeUpd) channel.
180
-
181
193
  ## Sponsorship wishlist
182
194
 
183
195
  If you love blint, you should consider [donating](https://owasp.org/donate?reponame=www-project-dep-scan&title=OWASP+dep-scan) to our project. In addition, consider donating to the below projects, which make blint possible.
@@ -47,6 +47,7 @@ def build_parser():
47
47
  "--src",
48
48
  dest="src_dir_image",
49
49
  action="extend",
50
+ default=[],
50
51
  nargs="+",
51
52
  help="Source directories, container images or binary files. Defaults "
52
53
  "to current directory.",
@@ -93,6 +94,19 @@ def build_parser():
93
94
  dest="use_blintdb",
94
95
  help=f"Use blintdb for symbol resolution. Defaults to true if the file exists at {BLINTDB_LOC}. Use environment variables: BLINTDB_IMAGE_URL, BLINTDB_HOME, and BLINTDB_REFRESH for customization.",
95
96
  )
97
+ parser.add_argument(
98
+ "--disassemble",
99
+ action="store_true",
100
+ default=False,
101
+ dest="disassemble",
102
+ help="Disassemble functions and store the instructions in the metadata. Requires blint extended group to be installed.",
103
+ )
104
+ parser.add_argument(
105
+ "--custom-rules-dir",
106
+ dest="custom_rules_dir",
107
+ type=str,
108
+ help="Path to a directory containing custom YAML rule files (.yml or .yaml). These will be loaded in addition to default rules.",
109
+ )
96
110
  parser.add_argument(
97
111
  "-q",
98
112
  "--quiet",
@@ -116,6 +130,7 @@ def build_parser():
116
130
  "--src",
117
131
  dest="src_dir_image",
118
132
  action="extend",
133
+ default=[os.getcwd()],
119
134
  nargs="+",
120
135
  help="Source directories, container images or binary files. Defaults to current directory.",
121
136
  )
@@ -238,7 +253,9 @@ def handle_args():
238
253
  src_dir_boms=args.src_dir_boms,
239
254
  src_dir_image=args.src_dir_image,
240
255
  stdout_mode=args.stdout_mode,
241
- use_blintdb=args.use_blintdb
256
+ use_blintdb=args.use_blintdb,
257
+ disassemble=args.disassemble,
258
+ custom_rules_dir=args.custom_rules_dir,
242
259
  )
243
260
  return blint_options
244
261
 
@@ -4,7 +4,7 @@ from dataclasses import dataclass, field
4
4
  import os
5
5
  import platform
6
6
  import re
7
- from typing import List
7
+ from typing import List, Optional
8
8
  from appdirs import user_data_dir
9
9
 
10
10
  ARCH = platform.machine()
@@ -14,60 +14,9 @@ SYSTEM = platform.system().lower()
14
14
  ignore_directories = [
15
15
  ".git",
16
16
  ".svn",
17
- ".mvn",
18
- ".idea",
19
- "backup",
20
- "docs",
21
- "tests",
22
- "test",
23
- "report",
24
- "reports",
25
- "node_modules",
26
- ".terraform",
27
- ".serverless",
28
- "venv",
29
- "examples",
30
- "tutorials",
31
- "samples",
32
- "migrations",
33
- "db_migrations",
34
- "unittests",
35
- "unittests_legacy",
36
- "stubs",
37
- "mock",
38
- "mocks",
39
17
  ]
40
18
  ignore_files = [
41
- ".pyc",
42
- ".gz",
43
- ".tar",
44
- ".tar.gz",
45
- ".tar.xz",
46
- ".tar",
47
- ".log",
48
- ".tmp",
49
- ".d.ts",
50
- ".min.js",
51
- ".min.css",
52
- ".eslintrc.js",
53
- ".babelrc.js",
54
- ".spec.js",
55
- ".spec.ts",
56
- ".component.spec.js",
57
- ".component.spec.ts",
58
- ".data.js",
59
- ".data.ts",
60
- ".bundle.js",
61
- ".snap",
62
- ".pb.go",
63
- ".tests.py",
64
- ".vdb",
65
- ".txt",
66
- ".strings",
67
- ".nib",
68
- ".nupkg",
69
- ".pak",
70
- ".xml"
19
+ ".ds_store",
71
20
  ]
72
21
  strings_allowlist = {
73
22
  "()",
@@ -1175,7 +1124,9 @@ secrets_regex = {
1175
1124
  re.compile(r'(?:\s|=|:|"|^)AP[\dABCDEF][a-zA-Z0-9]{8,}'),
1176
1125
  ],
1177
1126
  "aws": [
1178
- re.compile(r"(A3T[A-Z0-9]|AKIA|AGPA|AIDA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16}"),
1127
+ re.compile(
1128
+ r"(A3T[A-Z0-9]|AKIA|AGPA|AIDA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16}"
1129
+ ),
1179
1130
  re.compile(r"""(?i)aws(.{0,20})?['"][0-9a-zA-Z/+]{40}['"]"""),
1180
1131
  re.compile(
1181
1132
  r"""amzn.mws.[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}"""
@@ -1190,7 +1141,8 @@ secrets_regex = {
1190
1141
  re.compile(r"[0-9a-z]+.execute-api.[0-9a-z.\-_]+.amazonaws.com"),
1191
1142
  ],
1192
1143
  "github": [
1193
- re.compile(r"""(?i)github.{0,3}(token|api|key).{0,10}?([0-9a-zA-Z]{35,40})""")],
1144
+ re.compile(r"""(?i)github.{0,3}(token|api|key).{0,10}?([0-9a-zA-Z]{35,40})""")
1145
+ ],
1194
1146
  "slack": [re.compile(r"""xox[baprs]-([0-9a-zA-Z]{10,48})?""")],
1195
1147
  "EC": [re.compile(r"""-----BEGIN EC PRIVATE KEY-----""")],
1196
1148
  "DSA": [re.compile(r"""-----BEGIN DSA PRIVATE KEY-----""")],
@@ -1226,7 +1178,9 @@ secrets_regex = {
1226
1178
  "dynatrace": [re.compile(r"""dt0[a-zA-Z][0-9]{2}\.[A-Z0-9]{24}\.[A-Z0-9]{64}""")],
1227
1179
  "url": [
1228
1180
  re.compile(r"""(http(s)?|s3)://"""),
1229
- re.compile(r"""[a-zA-Z]{3,10}://[^/\s:@]{3,20}:[^/\s:@]{3,20}@.{1,100}["'\s]"""),
1181
+ re.compile(
1182
+ r"""[a-zA-Z]{3,10}://[^/\s:@]{3,20}:[^/\s:@]{3,20}@.{1,100}["'\s]"""
1183
+ ),
1230
1184
  re.compile(
1231
1185
  r"(ftp|jdbc:mysql)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]"
1232
1186
  ),
@@ -1298,6 +1252,7 @@ class BlintOptions:
1298
1252
  src_dir_boms (list): Directory containing pre-build and build sboms.
1299
1253
  use_blintdb (bool): Flag indicating whether or not to utilize blint-db
1300
1254
  """
1255
+
1301
1256
  deep_mode: bool = False
1302
1257
  exports_prefix: List = field(default_factory=list)
1303
1258
  fuzzy: bool = False
@@ -1314,6 +1269,8 @@ class BlintOptions:
1314
1269
  src_dir_image: List = field(default_factory=list)
1315
1270
  stdout_mode: bool = False
1316
1271
  use_blintdb: bool = False
1272
+ disassemble: bool = False
1273
+ custom_rules_dir: Optional[str] = None
1317
1274
 
1318
1275
  def __post_init__(self):
1319
1276
  if not self.src_dir_image and not (self.sbom_mode and self.src_dir_boms):
@@ -1324,11 +1281,15 @@ class BlintOptions:
1324
1281
  if self.stdout_mode:
1325
1282
  self.sbom_output = sys.stdout
1326
1283
  elif not self.sbom_output:
1327
- self.sbom_output = os.path.join(self.reports_dir, "bom-post-build.cdx.json")
1284
+ self.sbom_output = os.path.join(
1285
+ self.reports_dir, "sbom-binary-postbuild.cdx.json"
1286
+ )
1328
1287
  self.sbom_output_dir = os.path.join(self.reports_dir)
1329
1288
  elif os.path.isdir(self.sbom_output):
1330
1289
  self.sbom_output_dir = self.sbom_output
1331
- self.sbom_output = os.path.join(self.sbom_output, "bom-post-build.cdx.json")
1290
+ self.sbom_output = os.path.join(
1291
+ self.sbom_output, "sbom-binary-postbuild.cdx.json"
1292
+ )
1332
1293
  else:
1333
1294
  self.sbom_output_dir = os.path.dirname(self.sbom_output)
1334
1295
 
@@ -1359,7 +1320,7 @@ PII_WORDS = (
1359
1320
  "Calendar",
1360
1321
  "AgentStatus",
1361
1322
  "LastLoginTime",
1362
- "BankAccount"
1323
+ "BankAccount",
1363
1324
  )
1364
1325
 
1365
1326
  # Some symbols to look for in a first-stage payload
@@ -1401,18 +1362,117 @@ FIRST_STAGE_WORDS = (
1401
1362
  "loaderx86.dll",
1402
1363
  "ZwProtectVirtualMemory",
1403
1364
  "shlwapi.dll",
1404
- "DeleteCriticalSection"
1365
+ "DeleteCriticalSection",
1405
1366
  )
1406
1367
 
1407
1368
  # Setting blintdb
1408
- BLINTDB_HOME = os.getenv("BLINTDB_HOME", user_data_dir("blintdb"))
1369
+ BLINTDB_HOME = os.getenv("BLINTDB_HOME")
1370
+ if not BLINTDB_HOME:
1371
+ if os.getenv("RUNNER_TEMP"):
1372
+ BLINTDB_HOME = os.path.join(os.environ["RUNNER_TEMP"], "blintdb")
1373
+ else:
1374
+ BLINTDB_HOME = user_data_dir("blintdb")
1375
+ os.makedirs(BLINTDB_HOME, exist_ok=True)
1376
+
1409
1377
  BLINTDB_LOC = os.path.join(BLINTDB_HOME, "blint.db")
1410
1378
 
1411
- BLINTDB_IMAGE_URL = os.getenv("BLINTDB_IMAGE_URL",
1412
- "ghcr.io/appthreat/blintdb-vcpkg-darwin-arm64:v1" if SYSTEM == "darwin" else "ghcr.io/appthreat/blintdb-vcpkg:v1")
1379
+ BLINTDB_IMAGE_URL = os.getenv(
1380
+ "BLINTDB_IMAGE_URL",
1381
+ "ghcr.io/appthreat/blintdb-vcpkg-darwin-arm64:v1"
1382
+ if SYSTEM == "darwin"
1383
+ else "ghcr.io/appthreat/blintdb-vcpkg:v1",
1384
+ )
1413
1385
  BLINTDB_REFRESH = os.getenv("BLINTDB_REFRESH", False)
1414
1386
  if BLINTDB_REFRESH in ["true", "True", "1"]:
1415
1387
  BLINTDB_REFRESH = True
1416
1388
 
1417
1389
  SYMBOLS_LOOKUP_BATCH_LEN = get_int_from_env("SYMBOLS_LOOKUP_BATCH_LEN", 32000)
1418
1390
  MIN_MATCH_SCORE = get_int_from_env("MIN_MATCH_SCORE", 10)
1391
+
1392
+ SYSCALL_INDICATORS = ['syscall', 'int 0x80', 'sysenter', 'svc #', 'smc #', 'ecall']
1393
+ SECURITY_INDICATORS = ['endbr64', 'endbr32', 'setssbsy', 'clrssbsy', 'enqcmd', 'enqpad', 'hint #0x7e', 'hint #0x7f', 'pacibsp', 'paciasp', 'autibsp', 'autiasp', 'pacib1', 'pacibz', 'paciasp', 'paciasz', 'autib1', 'autibz', 'autiasp', 'autiaz', 'gmi', 'irg', 'subg', 'addg', 'ldg', 'stg', 'stzg', 'st2g', 'st3g', 'st4g']
1394
+ CRYPTO_INDICATORS = [
1395
+ 'aesenc', 'aesenclast', 'aesdec', 'aesdeclast', 'aesimc', 'aeskeygenassist',
1396
+ 'sha1rnds4', 'sha1nexte', 'sha1msg1', 'sha1msg2', 'sha256rnds2', 'sha256msg1', 'sha256msg2',
1397
+ 'aes', 'sha1', 'sha2', 'sm3', 'sm4',
1398
+ 'sha1c', 'sha1p', 'sha1m', 'sha256h', 'sha256h2', 'sha256su0', 'sha256su1',
1399
+ 'npxor', 'vpxor', 'vpxord', 'vpxorq',
1400
+ 'pshufb', 'vpshufb',
1401
+ 'pclmulqdq', 'vpclmulqdq',
1402
+ 'movdqa', 'movdqu', 'vmovdqa', 'vmovdqu',
1403
+ 'padd', 'psub', 'pmul',
1404
+ 'psll', 'psrl', 'psra',
1405
+ 'vpaddd', 'vpsubd', 'vpmulld',
1406
+ ]
1407
+ GPU_INDICATORS = [
1408
+ 'glbind', 'glvertex', 'glcolor', 'glbegin', 'glend', 'glenable', 'gldisable', 'glget', 'glset', 'glload', 'glsave', 'gluniform', 'gluseprogram', 'glattachshader', 'gldraw', 'glclear', 'glviewport', 'glmatrix', 'glpushmatrix', 'glpopmatrix',
1409
+ 'cuda', 'cuinit', 'cucontext', 'cudriver', 'cugpu', 'cudevice', 'cumem', 'cuptr', 'cukernel', 'culaunch', 'cugrid', 'cublock', 'cuthread', 'cufree', 'cucopy',
1410
+ 'clgetplatform', 'clgetdevice', 'clcreatecontext', 'clcreatecommandqueue', 'clcreateshared', 'clcreatekernel', 'clsetkernelarg', 'clenqueuendrange', 'clfinish', 'clrelease', 'clbuildprogram',
1411
+ 'd3d', 'd3d11', 'd3d12', 'create', 'device', 'swapchain', 'rendertarget', 'shaders', 'ps_', 'vs_', 'gs_', 'cs_', 'hs_', 'ds_',
1412
+ 'vk', 'vkcreate', 'vkdestroy', 'vkallocate', 'vkfree', 'vkqueue', 'vksubmit', 'vkwait', 'vkacquire', 'vkpresent', 'vkcmd', 'vkbegin', 'vkend', 'vkbind', 'vkdraw', 'vkdispatch', 'vkcopy', 'vkblit', 'vkclear', 'vkfill', 'vkupdate',
1413
+ 'mtl', 'metal', 'mtldevice', 'mtlcommand', 'mtlrender', 'mtlcompute', 'mtlbuffer', 'mtltexture', 'mtlfunction', 'mtllibrary', 'mtlencoder', 'mtlpass',
1414
+ 'gpu', 'compute', 'shader', 'vertex', 'fragment', 'pixel', 'kernel', 'workgroup', 'local', 'global', 'buffer', 'texture', 'surface',
1415
+ ]
1416
+
1417
+ IMPLICIT_REGS_X86 = {
1418
+ 'mul': {'read': {'ax', 'eax', 'rax'}, 'write': {'dx', 'ax', 'edx', 'eax', 'rdx', 'rax'}},
1419
+ 'imul': {'read': {'ax', 'eax', 'rax'}, 'write': {'dx', 'ax', 'edx', 'eax', 'rdx', 'rax'}}, # For one-operand form
1420
+ 'div': {'read': {'dx', 'ax', 'edx', 'eax', 'rdx', 'rax'}, 'write': {'ax', 'dx', 'eax', 'edx', 'rax', 'rdx'}},
1421
+ 'idiv': {'read': {'dx', 'ax', 'edx', 'eax', 'rdx', 'rax'}, 'write': {'ax', 'dx', 'eax', 'edx', 'rax', 'rdx'}},
1422
+ 'cbw': {'read': {'al'}, 'write': {'ah'}},
1423
+ 'cwde': {'read': {'ax'}, 'write': {'eax'}},
1424
+ 'cdqe': {'read': {'eax'}, 'write': 'rax'},
1425
+ 'cwd': {'read': {'ax'}, 'write': {'dx'}},
1426
+ 'cdq': {'read': {'eax'}, 'write': {'edx'}},
1427
+ 'cqo': {'read': {'rax'}, 'write': {'rdx'}},
1428
+ 'movsb': {'read': {'rsi'}, 'write': {'rdi'}},
1429
+ 'movsw': {'read': {'rsi'}, 'write': {'rdi'}},
1430
+ 'movsd': {'read': {'rsi'}, 'write': {'rdi'}},
1431
+ 'movsq': {'read': {'rsi'}, 'write': {'rdi'}},
1432
+ 'stosb': {'write': {'rdi'}},
1433
+ 'stosw': {'write': {'rdi'}},
1434
+ 'stosd': {'write': {'rdi'}},
1435
+ 'stosq': {'write': {'rdi'}},
1436
+ 'scasb': {'read': {'rdi', 'al'}},
1437
+ 'scasw': {'read': {'rdi', 'ax'}},
1438
+ 'scasd': {'read': {'rdi', 'eax'}},
1439
+ 'scasq': {'read': {'rdi', 'rax'}},
1440
+ 'cmpsb': {'read': {'rsi', 'rdi'}},
1441
+ 'cmpsw': {'read': {'rsi', 'rdi'}},
1442
+ 'cmpsd': {'read': {'rsi', 'rdi'}},
1443
+ 'cmpsq': {'read': {'rsi', 'rdi'}},
1444
+ 'pusha': {'write': {'ax', 'cx', 'dx', 'bx', 'sp', 'bp', 'si', 'di'}},
1445
+ 'pushad': {'write': {'eax', 'ecx', 'edx', 'ebx', 'esp', 'ebp', 'esi', 'edi'}},
1446
+ 'popa': {'read': {'di', 'si', 'bp', 'sp', 'bx', 'dx', 'cx', 'ax'}},
1447
+ 'popad': {'read': {'edi', 'esi', 'ebp', 'esp', 'ebx', 'edx', 'ecx', 'eax'}},
1448
+ 'cpuid': {'read': {'eax'}, 'write': {'eax', 'ebx', 'ecx', 'edx'}},
1449
+ 'syscall':{'read': {'rcx', 'r11'}, 'write': {'rcx', 'r11'}},
1450
+ 'sysenter':{'read': {'eax', 'ebx', 'ecx', 'edx', 'esi', 'edi', 'ebp'}, 'write': set()},
1451
+ }
1452
+
1453
+ IMPLICIT_REGS_X64 = {
1454
+ 'mul': {'read': {'rax'}, 'write': {'rdx', 'rax'}},
1455
+ 'imul': {'read': {'rax'}, 'write': {'rdx', 'rax'}},
1456
+ 'div': {'read': {'rdx', 'rax'}, 'write': {'rax', 'rdx'}},
1457
+ 'idiv': {'read': {'rdx', 'rax'}, 'write': {'rax', 'rdx'}},
1458
+ 'cdqe': {'read': {'eax'}, 'write': {'rax'}},
1459
+ 'cqo': {'read': {'rax'}, 'write': {'rdx'}},
1460
+ 'movsb': {'read': {'rsi'}, 'write': {'rdi'}},
1461
+ 'movsw': {'read': {'rsi'}, 'write': {'rdi'}},
1462
+ 'movsd': {'read': {'rsi'}, 'write': {'rdi'}},
1463
+ 'movsq': {'read': {'rsi'}, 'write': {'rdi'}},
1464
+ 'stosb': {'write': {'rdi'}},
1465
+ 'stosw': {'write': {'rdi'}},
1466
+ 'stosd': {'write': {'rdi'}},
1467
+ 'stosq': {'write': {'rdi'}},
1468
+ 'scasb': {'read': {'rdi', 'al'}},
1469
+ 'scasw': {'read': {'rdi', 'ax'}},
1470
+ 'scasd': {'read': {'rdi', 'eax'}},
1471
+ 'scasq': {'read': {'rdi', 'rax'}},
1472
+ 'cmpsb': {'read': {'rsi', 'rdi'}},
1473
+ 'cmpsw': {'read': {'rsi', 'rdi'}},
1474
+ 'cmpsd': {'read': {'rsi', 'rdi'}},
1475
+ 'cmpsq': {'read': {'rsi', 'rdi'}},
1476
+ 'cpuid': {'read': {'eax', 'ecx'}, 'write': {'eax', 'ebx', 'ecx', 'edx'}},
1477
+ 'syscall':{'read': {'rcx', 'r11'}, 'write': {'rcx', 'r11'}},
1478
+ }
@@ -0,0 +1,132 @@
1
+ ---
2
+ group: FUNCTION_REVIEWS
3
+ exe_type: [PE32, PE64, genericbinary, ELF, MachO]
4
+ rules:
5
+ - id: CRYPTO_BEHAVIOR
6
+ title: Function with Cryptographic Behavior
7
+ summary: Function exhibits behavior commonly found in cryptographic routines.
8
+ description: This function contains a high number of bitwise/shift/rotate instructions and uses SIMD registers, which is a strong indicator of cryptographic operations.
9
+ check_type: function_analysis
10
+ - id: INDIRECT_EXECUTION
11
+ title: Function with Indirect Execution
12
+ summary: Function uses indirect calls or jumps (e.g., call rax), a common technique in malware.
13
+ description: Indirect control flow can be used to hide malicious functionality or implement complex logic like virtual function calls.
14
+ check_type: function_flag
15
+ check_field: has_indirect_call
16
+ - id: SYSTEM_CALL_USAGE
17
+ title: Function with Direct System Call
18
+ summary: Function contains direct system call instructions (e.g., syscall).
19
+ description: Direct system calls can be used to bypass standard library wrappers (libc) and are often seen in malware and shellcode.
20
+ check_type: function_flag
21
+ check_field: has_system_call
22
+ - id: ANTI_DISASSEMBLY_TRICKS
23
+ title: Function with Potential Anti-Disassembly
24
+ summary: Function has a very low instruction count but contains jumps, potentially indicating an obfuscated thunk.
25
+ description: Very small functions that do nothing but jump can be used to thwart linear sweep disassemblers or hide the true control flow.
26
+ check_type: function_analysis
27
+ - id: HIGH_ENTROPY_INDIRECT_CALL
28
+ title: Function with High Entropy Indirect Call Target
29
+ summary: Function performs indirect calls using a register whose value appears to be calculated or obfuscated.
30
+ description: Indirect calls where the target is derived from complex calculations (e.g., arithmetic, shifts, XORs on constants or other registers) are common in malware for anti-analysis and hiding control flow.
31
+ check_type: function_analysis
32
+ - id: POTENTIAL_STACK_STRING
33
+ title: Function Manipulates Potential Stack Strings
34
+ summary: Function performs many moves and stores, possibly constructing strings on the stack.
35
+ description: Malware sometimes constructs API names or other strings directly on the stack before passing them to functions like GetProcAddress.
36
+ check_type: function_analysis
37
+ - id: SUSPICIOUS_MEMORY_ALLOC
38
+ title: Function Allocates Memory and Jumps/Executes
39
+ summary: Function allocates memory (e.g., VirtualAlloc) and then potentially jumps to or executes code within that memory.
40
+ description: This pattern is common in shellcode loaders and packers where decrypted/decoded code is allocated dynamically and then executed.
41
+ check_type: function_analysis
42
+ - id: HIGH_REGISTER_USAGE
43
+ title: Function with High Register Usage
44
+ summary: Function reads or writes a very high number of unique registers.
45
+ description: Functions performing cryptographic operations or heavy obfuscation often manipulate many registers simultaneously. Checks `unique_regs_read_count` or `unique_regs_written_count` in `instruction_metrics`.
46
+ check_type: function_metric
47
+ check_field: instruction_metrics.unique_regs_read_count
48
+ operator: ">"
49
+ threshold: 25
50
+ - id: HIGH_XOR_USAGE
51
+ title: Function with High XOR Instruction Count
52
+ summary: Function contains a disproportionately high number of XOR instructions.
53
+ description: XOR instructions are common in obfuscation techniques and cryptographic routines. Checks `xor_count` in `instruction_metrics`.
54
+ check_type: function_metric
55
+ check_field: instruction_metrics.xor_count
56
+ operator: ">"
57
+ threshold: 50
58
+ - id: HIGH_SHIFT_USAGE
59
+ title: Function with High Shift/Rotate Instruction Count
60
+ summary: Function contains a disproportionately high number of shift or rotate instructions.
61
+ description: Shift and rotate instructions are characteristic of many cryptographic and hashing algorithms. Checks `shift_count` in `instruction_metrics`.
62
+ check_type: function_metric
63
+ check_field: instruction_metrics.shift_count
64
+ operator: ">"
65
+ threshold: 25
66
+ - id: POTENTIAL_ANTI_DEBUG
67
+ title: Function Contains Potential Anti-Debugging Checks
68
+ summary: Function contains patterns commonly used for anti-debugging.
69
+ description: This could involve checking specific registers, calling specific APIs (if resolved later), or using instructions like rdtsc for timing.
70
+ check_type: function_analysis
71
+ - id: HIGH_SIMD_USAGE
72
+ title: Function with High SIMD/Vector Instruction Usage
73
+ summary: Function uses a significant number of SIMD (SSE, AVX, etc.) instructions.
74
+ description: SIMD instructions are often used for performance in cryptographic routines or data processing. Checks `simd_fpu_count` in `instruction_metrics`.
75
+ check_type: function_metric
76
+ check_field: instruction_metrics.simd_fpu_count
77
+ operator: ">"
78
+ threshold: 30
79
+ - id: COMPLEX_CONTROL_FLOW
80
+ title: Function with Complex Control Flow
81
+ summary: Function contains a high number of conditional jumps, indicating complex logic or obfuscation.
82
+ description: A high `conditional_jump_count` in `instruction_metrics` can suggest complex control flow, often used for obfuscation.
83
+ check_type: function_metric
84
+ check_field: instruction_metrics.conditional_jump_count
85
+ operator: ">"
86
+ threshold: 50
87
+ - id: POTENTIAL_IAT_MANIPULATION
88
+ title: Function Writes to Potential Import Address Table
89
+ summary: Function writes data to memory locations that might correspond to the Import Address Table (IAT).
90
+ description: Malware sometimes modifies the IAT to hook API calls or bypass standard library functions.
91
+ check_type: function_analysis
92
+ - id: UNUSUAL_CALLING_CONVENTION
93
+ title: Function Potentially Violates Standard Calling Convention
94
+ summary: Function modifies registers typically preserved by the calling convention without apparent restoration.
95
+ description: Functions that modify callee-saved registers (like rbp, rbx, r12-r15 on x64) without saving them on the stack might be implementing hooks, trampolines, or other non-standard logic.
96
+ check_type: function_analysis
97
+ - id: POTENTIAL_SHELLCODE_CHARS
98
+ title: Function Exhibits Potential Shellcode Characteristics
99
+ summary: Function combines several indicators common in shellcode (e.g., syscalls, indirect calls, high register usage).
100
+ description: A meta-rule combining flags like `has_system_call`, `has_indirect_call`, high `instruction_metrics.conditional_jump_count`, and low `instruction_count` might indicate shellcode-like behavior.
101
+ check_type: function_analysis
102
+ - id: LOOP_WITH_SELF_MODIFY_HINT
103
+ title: Function Loop with Potential Self-Modification Indicators
104
+ summary: Function contains a loop and also writes to memory (potential self-modifying code).
105
+ description: A combination of `has_loop` and instructions that write to general memory locations (not just stack or known local variables) could be a hint.
106
+ check_type: function_analysis
107
+ - id: HIGH_ARITHMETIC_USAGE
108
+ title: Function with High Arithmetic Instruction Count
109
+ summary: Function contains a disproportionately high number of arithmetic/logical instructions (e.g., add, sub, imul, and, or).
110
+ description: High usage of arithmetic instructions can be a sign of cryptographic algorithms or complex mathematical computations often found in malware. Checks `arith_count` in `instruction_metrics`.
111
+ check_type: function_metric
112
+ check_field: instruction_metrics.arith_count
113
+ operator: ">"
114
+ threshold: 50
115
+ - id: DYNAMIC_API_RESOLUTION_HINT
116
+ title: Function Shows Hints of Dynamic API Resolution
117
+ summary: Function manipulates strings (potential API names) and makes indirect calls.
118
+ description: Combines potential stack string construction (`POTENTIAL_STACK_STRING` logic) or string manipulation with indirect calls (`has_indirect_call`), suggesting dynamic API resolution.
119
+ check_type: function_analysis
120
+ - id: HIGH_JUMP_USAGE
121
+ title: Function with High Unconditional Jump Count
122
+ summary: Function contains a disproportionately high number of unconditional jump instructions.
123
+ description: High `jump_count` in `instruction_metrics` might indicate obfuscation techniques or the implementation of jump tables, common in packed or obfuscated code.
124
+ check_type: function_metric
125
+ check_field: instruction_metrics.jump_count
126
+ operator: ">"
127
+ threshold: 50
128
+ - id: POTENTIAL_ROP_GADGET
129
+ title: Function Resembles a Potential ROP Gadget
130
+ summary: Function is very small, performs minimal operations, and ends with a return.
131
+ description: Short functions (e.g., < 10 instructions) that read registers/stack, perform simple operations, and end with `ret` might be ROP gadgets used in exploits.
132
+ check_type: function_analysis