blint 2.1.8__tar.gz → 2.2.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 (37) hide show
  1. {blint-2.1.8 → blint-2.2.0}/PKG-INFO +5 -4
  2. {blint-2.1.8 → blint-2.2.0}/README.md +1 -0
  3. {blint-2.1.8 → blint-2.2.0}/blint/analysis.py +26 -3
  4. {blint-2.1.8 → blint-2.2.0}/blint/binary.py +90 -43
  5. {blint-2.1.8 → blint-2.2.0}/blint/cli.py +2 -0
  6. {blint-2.1.8 → blint-2.2.0}/blint/config.py +58 -0
  7. {blint-2.1.8 → blint-2.2.0}/blint/data/annotations/review_exe_go.yml +67 -0
  8. {blint-2.1.8 → blint-2.2.0}/blint/data/annotations/review_imports_pe.yml +143 -9
  9. {blint-2.1.8 → blint-2.2.0}/blint/data/annotations/review_rootkits_win.yml +2 -2
  10. {blint-2.1.8 → blint-2.2.0}/blint/data/annotations/review_symbols_macho.yml +28 -0
  11. {blint-2.1.8 → blint-2.2.0}/blint/data/rules.yml +1 -0
  12. {blint-2.1.8 → blint-2.2.0}/pyproject.toml +10 -10
  13. blint-2.1.8/blint/data/annotations/review_monero_rust +0 -31
  14. {blint-2.1.8 → blint-2.2.0}/LICENSE +0 -0
  15. {blint-2.1.8 → blint-2.2.0}/blint/__init__.py +0 -0
  16. {blint-2.1.8 → blint-2.2.0}/blint/android.py +0 -0
  17. {blint-2.1.8 → blint-2.2.0}/blint/checks.py +0 -0
  18. {blint-2.1.8 → blint-2.2.0}/blint/cyclonedx/README.md +0 -0
  19. {blint-2.1.8 → blint-2.2.0}/blint/cyclonedx/__init__.py +0 -0
  20. {blint-2.1.8 → blint-2.2.0}/blint/cyclonedx/spdx.py +0 -0
  21. {blint-2.1.8 → blint-2.2.0}/blint/cyclonedx/spec.py +0 -0
  22. {blint-2.1.8 → blint-2.2.0}/blint/data/__init__.py +0 -0
  23. {blint-2.1.8 → blint-2.2.0}/blint/data/annotations/__init__.py +0 -0
  24. {blint-2.1.8 → blint-2.2.0}/blint/data/annotations/review_entries_generic.yml +0 -0
  25. {blint-2.1.8 → blint-2.2.0}/blint/data/annotations/review_entries_pe.yml +0 -0
  26. {blint-2.1.8 → blint-2.2.0}/blint/data/annotations/review_methods_generic.yml +0 -0
  27. {blint-2.1.8 → blint-2.2.0}/blint/data/annotations/review_methods_mips.yml +0 -0
  28. {blint-2.1.8 → blint-2.2.0}/blint/data/annotations/review_monero_generic.yml +0 -0
  29. {blint-2.1.8 → blint-2.2.0}/blint/data/annotations/review_monero_go.yml +0 -0
  30. {blint-2.1.8 → blint-2.2.0}/blint/data/annotations/review_monero_rust.yml +0 -0
  31. {blint-2.1.8 → blint-2.2.0}/blint/data/annotations/review_symbols_antiforensic.yml +0 -0
  32. {blint-2.1.8 → blint-2.2.0}/blint/data/annotations/review_symbols_generic.yml +0 -0
  33. {blint-2.1.8 → blint-2.2.0}/blint/data/annotations/review_symbols_hooka.yml +0 -0
  34. {blint-2.1.8 → blint-2.2.0}/blint/data/annotations/review_symbols_rust.yml +0 -0
  35. {blint-2.1.8 → blint-2.2.0}/blint/logger.py +0 -0
  36. {blint-2.1.8 → blint-2.2.0}/blint/sbom.py +0 -0
  37. {blint-2.1.8 → blint-2.2.0}/blint/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: blint
3
- Version: 2.1.8
3
+ Version: 2.2.0
4
4
  Summary: Linter and SBOM generator for binary files.
5
5
  Home-page: https://github.com/OWASP-dep-scan/blint
6
6
  License: MIT
@@ -22,9 +22,9 @@ Classifier: Topic :: Utilities
22
22
  Requires-Dist: PyYAML (>=6.0.1,<7.0.0)
23
23
  Requires-Dist: ar (>=0.9.1,<0.10.0)
24
24
  Requires-Dist: defusedxml (>=0.7.1,<0.8.0)
25
- Requires-Dist: lief (>=0.14.1,<0.15.0)
26
- Requires-Dist: orjson (>=3.10.3,<4.0.0)
27
- Requires-Dist: pydantic[email] (>=2.6.0,<3.0.0)
25
+ Requires-Dist: lief (>=0.15.1,<0.16.0)
26
+ Requires-Dist: orjson (>=3.10.6,<4.0.0)
27
+ Requires-Dist: pydantic[email] (>=2.8.2,<3.0.0)
28
28
  Requires-Dist: rich (>=13.7.1,<14.0.0)
29
29
  Requires-Dist: symbolic (==10.2.1)
30
30
  Project-URL: CI, https://github.com/AppThreat/blint/actions
@@ -154,6 +154,7 @@ The following binaries are supported:
154
154
  - Android (apk/aab)
155
155
  - Dotnet executable binaries
156
156
  - Go binaries
157
+ - Rust binaries
157
158
 
158
159
  ```shell
159
160
  blint sbom -i /path/to/go-binaries -o bom.json --deep
@@ -121,6 +121,7 @@ The following binaries are supported:
121
121
  - Android (apk/aab)
122
122
  - Dotnet executable binaries
123
123
  - Go binaries
124
+ - Rust binaries
124
125
 
125
126
  ```shell
126
127
  blint sbom -i /path/to/go-binaries -o bom.json --deep
@@ -21,6 +21,7 @@ from blint.checks import (check_nx, check_pie,
21
21
  check_virtual_size, check_authenticode,
22
22
  check_dll_characteristics, check_codesign,
23
23
  check_trust_info)
24
+ from blint.config import PII_WORDS, get_int_from_env
24
25
  from blint.logger import LOG, console
25
26
  from blint.utils import (create_findings_table, is_fuzzable_name, print_findings_table)
26
27
 
@@ -53,13 +54,18 @@ review_methods_dict = defaultdict(list)
53
54
  review_symbols_dict = defaultdict(list)
54
55
  review_imports_dict = defaultdict(list)
55
56
  review_entries_dict = defaultdict(list)
56
- review_rules_cache = {}
57
+ review_rules_cache = {"PII_READ": {
58
+ "title": "Detect PII Read Operations",
59
+ "summary": "Can Retrieve Sensitive PII data",
60
+ "description": "Contains logic to retrieve sensitive data such as names, email, passwords etc.",
61
+ "patterns": PII_WORDS
62
+ }}
57
63
 
58
64
  # Debug mode
59
65
  DEBUG_MODE = os.getenv("SCAN_DEBUG_MODE") == "debug"
60
66
 
61
67
  # No of evidences per category
62
- EVIDENCE_LIMIT = 5
68
+ EVIDENCE_LIMIT = get_int_from_env("EVIDENCE_LIMIT", 5)
63
69
 
64
70
 
65
71
  def get_resource(package, resource):
@@ -425,7 +431,7 @@ class AnalysisRunner:
425
431
  if finding := run_checks(f, metadata):
426
432
  self.findings += finding
427
433
  # Perform symbol reviews
428
- if no_reviews:
434
+ if not no_reviews:
429
435
  self.do_review(exe_name, f, metadata)
430
436
  # Suggest fuzzable targets
431
437
  if suggest_fuzzables and (fuzzdata := run_prefuzz(metadata)):
@@ -509,6 +515,7 @@ class ReviewRunner:
509
515
  self._review_imports(metadata)
510
516
  if self.review_entries_list:
511
517
  self._review_entries(metadata)
518
+ self._review_pii(metadata)
512
519
  return self.results
513
520
 
514
521
  def _review_imports(self, metadata):
@@ -539,6 +546,22 @@ class ReviewRunner:
539
546
  LOG.debug(f"Reviewing {len(entries_list)} dynamic entries")
540
547
  self.run_review_methods_symbols(self.review_entries_list, entries_list)
541
548
 
549
+ def _review_pii(self, metadata):
550
+ """
551
+ Reviews pii symbols.
552
+
553
+ Args:
554
+ metadata (dict): The metadata to review.
555
+
556
+ Returns:
557
+ dict: The results of the review.
558
+ """
559
+ entries_list = [f.get("name", "") for f in metadata.get("pii_symbols", [])]
560
+ results = defaultdict(list)
561
+ for e in entries_list[0:EVIDENCE_LIMIT]:
562
+ results["PII_READ"].append({"pattern": e, "function": e})
563
+ self.results |= results
564
+
542
565
  def _review_symbols_exe(self, metadata):
543
566
  """
544
567
  Reviews symbols in the metadata.
@@ -1,6 +1,7 @@
1
1
  # pylint: disable=too-many-lines,consider-using-f-string
2
2
  import codecs
3
3
  import contextlib
4
+ import re
4
5
  import sys
5
6
  from typing import Tuple
6
7
  import zlib
@@ -8,8 +9,9 @@ import orjson
8
9
 
9
10
  import lief
10
11
 
12
+ from blint.config import PII_WORDS, get_float_from_env, get_int_from_env
11
13
  from blint.logger import DEBUG, LOG
12
- from blint.utils import calculate_entropy, check_secret, cleanup_dict_lief_errors, decode_base64
14
+ from blint.utils import camel_to_snake, calculate_entropy, check_secret, cleanup_dict_lief_errors, decode_base64
13
15
 
14
16
  SYMBOLIC_FOUND = True
15
17
  try:
@@ -18,8 +20,8 @@ try:
18
20
  except OSError:
19
21
  SYMBOLIC_FOUND = False
20
22
 
21
- MIN_ENTROPY = 0.39
22
- MIN_LENGTH = 80
23
+ MIN_ENTROPY = get_float_from_env("SECRET_MIN_ENTROPY", 0.39)
24
+ MIN_LENGTH = get_int_from_env("SECRET_MIN_LENGTH", 80)
23
25
 
24
26
  # Enable lief logging in debug mode
25
27
  if LOG.level != DEBUG:
@@ -93,11 +95,11 @@ def is_shared_library(parsed_obj):
93
95
  if not parsed_obj:
94
96
  return False
95
97
  if parsed_obj.format == lief.Binary.FORMATS.ELF:
96
- return parsed_obj.header.file_type == lief.ELF.E_TYPE.DYNAMIC
98
+ return parsed_obj.header.file_type == lief.ELF.Header.FILE_TYPE.DYN
97
99
  if parsed_obj.format == lief.Binary.FORMATS.PE:
98
100
  return parsed_obj.header.has_characteristic(lief.PE.Header.CHARACTERISTICS.DLL)
99
101
  if parsed_obj.format == lief.Binary.FORMATS.MACHO:
100
- return parsed_obj.header.file_type == lief.MachO.FILE_TYPES.DYLIB
102
+ return parsed_obj.header.file_type == lief.MachO.Header.FILE_TYPE.DYLIB
101
103
  return False
102
104
 
103
105
 
@@ -205,16 +207,16 @@ def parse_relro(parsed_obj):
205
207
  Returns:
206
208
  str: The RELRO protection level of the binary object.
207
209
  """
208
- test_stmt = parsed_obj.get(lief.ELF.SEGMENT_TYPES.GNU_RELRO)
210
+ test_stmt = parsed_obj.get(lief.ELF.Segment.TYPE.GNU_RELRO)
209
211
  if isinstance(test_stmt, lief.lief_errors):
210
212
  return "no"
211
- dynamic_tags = parsed_obj.get(lief.ELF.DYNAMIC_TAGS.FLAGS)
213
+ dynamic_tags = parsed_obj.get(lief.ELF.DynamicEntry.TAG.FLAGS)
212
214
  bind_now, now = False, False
213
- if dynamic_tags and not isinstance(dynamic_tags, lief.lief_errors):
214
- bind_now = lief.ELF.DYNAMIC_FLAGS.BIND_NOW in dynamic_tags
215
- dynamic_tags = parsed_obj.get(lief.ELF.DYNAMIC_TAGS.FLAGS_1)
216
- if dynamic_tags and not isinstance(dynamic_tags, lief.lief_errors):
217
- now = lief.ELF.DYNAMIC_FLAGS_1.NOW in dynamic_tags
215
+ if dynamic_tags and isinstance(dynamic_tags, lief.ELF.DynamicEntryFlags):
216
+ bind_now = lief.ELF.DynamicEntryFlags.FLAG.BIND_NOW in dynamic_tags
217
+ dynamic_tags = parsed_obj.get(lief.ELF.DynamicEntry.TAG.FLAGS_1)
218
+ if dynamic_tags and isinstance(dynamic_tags, lief.ELF.DynamicEntryFlags):
219
+ now = lief.ELF.DynamicEntryFlags.FLAG.NOW in dynamic_tags
218
220
  return "full" if bind_now or now else "partial"
219
221
 
220
222
 
@@ -451,7 +453,7 @@ def process_pe_resources(parsed_obj):
451
453
  "has_manifest": rm.has_manifest,
452
454
  "has_string_table": rm.has_string_table,
453
455
  "has_version": rm.has_version,
454
- "manifest": (rm.manifest.replace("\\xef\\xbb\\xbf", "") if rm.has_manifest else None),
456
+ "manifest": (rm.manifest.replace("\\xef\\xbb\\xbf", "").removeprefix("\ufeff") if rm.has_manifest else None),
455
457
  "version_info": str(rm.version) if rm.has_version else None,
456
458
  "html": rm.html if rm.has_html else None,
457
459
  }
@@ -479,10 +481,10 @@ def process_pe_signature(parsed_obj):
479
481
  ci = sig.content_info
480
482
  signature_obj = {
481
483
  "version": sig.version,
482
- "digest_algorithm": str(sig.digest_algorithm),
484
+ "digest_algorithm": str(sig.digest_algorithm).rsplit(".", maxsplit=1)[-1],
483
485
  "content_info": {
484
486
  "content_type": lief.PE.oid_to_string(ci.content_type),
485
- "digest_algorithm": str(ci.digest_algorithm),
487
+ "digest_algorithm": str(ci.digest_algorithm).rsplit(".", maxsplit=1)[-1],
486
488
  "digest": ci.digest.hex(),
487
489
  },
488
490
  }
@@ -492,8 +494,8 @@ def process_pe_signature(parsed_obj):
492
494
  "version": signer.version,
493
495
  "serial_number": signer.serial_number.hex(),
494
496
  "issuer": str(signer.issuer),
495
- "digest_algorithm": str(signer.digest_algorithm),
496
- "encryption_algorithm": str(signer.encryption_algorithm),
497
+ "digest_algorithm": str(signer.digest_algorithm).rsplit(".", maxsplit=1)[-1],
498
+ "encryption_algorithm": str(signer.encryption_algorithm).rsplit(".", maxsplit=1)[-1],
497
499
  "encrypted_digest": signer.encrypted_digest.hex(),
498
500
  }
499
501
  signers_list.append(signer_obj)
@@ -520,9 +522,7 @@ def parse_pe_authenticode(parsed_obj):
520
522
  "sha256_hash": parsed_obj.authentihash_sha256.hex(*sep),
521
523
  "sha512_hash": parsed_obj.authentihash_sha512.hex(*sep),
522
524
  "sha1_hash": parsed_obj.authentihash(lief.PE.ALGORITHMS.SHA_1).hex(*sep),
523
- "verification_flags": str(parsed_obj.verify_signature()).replace(
524
- "VERIFICATION_FLAGS.", ""
525
- ),
525
+ "verification_flags": str(parsed_obj.verify_signature()).rsplit(".", maxsplit=1)[-1],
526
526
  }
527
527
  if signatures := parsed_obj.signatures:
528
528
  if not isinstance(signatures, lief.lief_errors) and signatures[0].signers:
@@ -534,7 +534,10 @@ def parse_pe_authenticode(parsed_obj):
534
534
  tmp_key = tmp_a[0].strip().replace(" ", "_")
535
535
  if "version" in tmp_key:
536
536
  tmp_key = "version"
537
- cert_signer_obj[tmp_key] = tmp_a[1].strip()
537
+ value = tmp_a[1].strip()
538
+ if value == "???":
539
+ value = "N/A"
540
+ cert_signer_obj[tmp_key] = value
538
541
  authenticode["cert_signer"] = cert_signer_obj
539
542
  return authenticode
540
543
  except (AttributeError, IndexError, KeyError, TypeError) as e:
@@ -561,11 +564,7 @@ def parse_pe_symbols(symbols):
561
564
  if not symbol:
562
565
  continue
563
566
  try:
564
- if symbol.section_number <= 0:
565
- section_nb_str = str(lief.PE.SYMBOL_SECTION_NUMBER(symbol.section_number)).rsplit(
566
- ".", maxsplit=1
567
- )[-1]
568
- elif symbol.section and symbol.section.name:
567
+ if symbol.section and symbol.section.name:
569
568
  section_nb_str = symbol.section.name
570
569
  else:
571
570
  section_nb_str = "section<{:d}>".format(symbol.section_number)
@@ -586,9 +585,7 @@ def parse_pe_symbols(symbols):
586
585
  "storage_class": str(symbol.storage_class).rsplit(".", maxsplit=1)[-1],
587
586
  }
588
587
  )
589
- except (IndexError, AttributeError, ValueError) as e:
590
- LOG.debug(f"Caught {type(e)}: {e} while parsing {symbol}.")
591
- except RuntimeError:
588
+ except (IndexError, AttributeError, ValueError, RuntimeError):
592
589
  pass
593
590
  return symbols_list, exe_type
594
591
 
@@ -780,26 +777,26 @@ def add_elf_metadata(exe_file, metadata, parsed_obj):
780
777
  metadata["has_canary"] = True
781
778
  break
782
779
  # rpath check
783
- rpath = parsed_obj.get(lief.ELF.DYNAMIC_TAGS.RPATH)
780
+ rpath = parsed_obj.get(lief.ELF.DynamicEntry.TAG.RPATH)
784
781
  if isinstance(rpath, lief.lief_errors):
785
782
  metadata["has_rpath"] = False
786
783
  elif rpath:
787
784
  metadata["has_rpath"] = True
788
785
  # runpath check
789
- runpath = parsed_obj.get(lief.ELF.DYNAMIC_TAGS.RUNPATH)
786
+ runpath = parsed_obj.get(lief.ELF.DynamicEntry.TAG.RUNPATH)
790
787
  if isinstance(runpath, lief.lief_errors):
791
788
  metadata["has_runpath"] = False
792
789
  elif runpath:
793
790
  metadata["has_runpath"] = True
794
791
  # This is getting renamed to symtab_symbols in lief 0.15.0
795
- static_symbols = parsed_obj.static_symbols
796
- metadata["static"] = bool(static_symbols and not isinstance(static_symbols, lief.lief_errors))
792
+ symtab_symbols = parsed_obj.symtab_symbols
793
+ metadata["static"] = bool(symtab_symbols and not isinstance(symtab_symbols, lief.lief_errors))
797
794
  dynamic_entries = parsed_obj.dynamic_entries
798
795
  metadata = add_elf_dynamic_entries(dynamic_entries, metadata)
799
796
  metadata = add_elf_symbols(metadata, parsed_obj)
800
797
  metadata["notes"] = parse_notes(parsed_obj)
801
798
  metadata["strings"] = parse_strings(parsed_obj)
802
- metadata["symtab_symbols"], exe_type = parse_symbols(static_symbols)
799
+ metadata["symtab_symbols"], exe_type = parse_symbols(symtab_symbols)
803
800
  if exe_type:
804
801
  metadata["exe_type"] = exe_type
805
802
  metadata["dynamic_symbols"], exe_type = parse_symbols(parsed_obj.dynamic_symbols)
@@ -893,13 +890,13 @@ def add_elf_dynamic_entries(dynamic_entries, metadata):
893
890
  if isinstance(dynamic_entries, lief.lief_errors):
894
891
  return metadata
895
892
  for entry in dynamic_entries:
896
- if entry.tag == lief.ELF.DYNAMIC_TAGS.NULL:
893
+ if entry.tag == lief.ELF.DynamicEntry.TAG.NULL:
897
894
  continue
898
895
  if entry.tag in [
899
- lief.ELF.DYNAMIC_TAGS.SONAME,
900
- lief.ELF.DYNAMIC_TAGS.NEEDED,
901
- lief.ELF.DYNAMIC_TAGS.RUNPATH,
902
- lief.ELF.DYNAMIC_TAGS.RPATH,
896
+ lief.ELF.DynamicEntry.TAG.SONAME,
897
+ lief.ELF.DynamicEntry.TAG.NEEDED,
898
+ lief.ELF.DynamicEntry.TAG.RUNPATH,
899
+ lief.ELF.DynamicEntry.TAG.RPATH,
903
900
  ]:
904
901
  metadata["dynamic_entries"].append(
905
902
  {
@@ -923,7 +920,7 @@ def determine_elf_flags(header):
923
920
  A string representing the ELF flags.
924
921
  """
925
922
  eflags_str = ""
926
- if header.machine_type == lief.ELF.ARCH.ARM:
923
+ if header.machine_type == lief.ELF.ARCH.ARM and hasattr(header, "arm_flags_list"):
927
924
  eflags_str = " - ".join(
928
925
  [str(s).rsplit(".", maxsplit=1)[-1] for s in header.arm_flags_list]
929
926
  )
@@ -994,7 +991,7 @@ def parse_go_buildinfo(
994
991
  deps = {}
995
992
  build_info_str: str = ""
996
993
  # Look for specific buildinfo sections for ELF and MachO binaries
997
- build_info: lief.Section = None
994
+ build_info: lief.Section | None = None
998
995
  if isinstance(parsed_obj, lief.ELF.Binary):
999
996
  build_info = parsed_obj.get_section(".go.buildinfo")
1000
997
  elif isinstance(parsed_obj, lief.MachO.Binary):
@@ -1095,6 +1092,8 @@ def add_pe_metadata(exe_file: str, metadata: dict, parsed_obj: lief.PE.Binary):
1095
1092
  metadata["is_reproducible_build"] = parsed_obj.is_reproducible_build
1096
1093
  metadata["virtual_size"] = parsed_obj.virtual_size
1097
1094
  metadata["has_nx"] = parsed_obj.has_nx
1095
+ metadata["imphash_pefile"] = lief.PE.get_imphash(parsed_obj, lief.PE.IMPHASH_MODE.PEFILE)
1096
+ metadata["imphash_lief"] = lief.PE.get_imphash(parsed_obj, lief.PE.IMPHASH_MODE.LIEF)
1098
1097
  metadata = add_pe_header_data(metadata, parsed_obj)
1099
1098
  metadata["data_directories"] = parse_pe_data(parsed_obj)
1100
1099
  metadata["authenticode"] = parse_pe_authenticode(parsed_obj)
@@ -1113,6 +1112,12 @@ def add_pe_metadata(exe_file: str, metadata: dict, parsed_obj: lief.PE.Binary):
1113
1112
  if e["name"] == "ntoskrnl.exe":
1114
1113
  metadata["is_driver"] = True
1115
1114
  break
1115
+ rdata_section = parsed_obj.get_section(".rdata")
1116
+ text_section = parsed_obj.get_section(".text")
1117
+ if not rdata_section and text_section:
1118
+ rdata_section = text_section
1119
+ if (not metadata["symtab_symbols"] or metadata["exe_type"] != "gobinary") and rdata_section:
1120
+ add_pe_rdata_symbols(metadata, rdata_section)
1116
1121
  metadata["exports"] = parse_pe_exports(parsed_obj.get_export())
1117
1122
  metadata["functions"] = parse_functions(parsed_obj.functions)
1118
1123
  metadata["ctor_functions"] = parse_functions(parsed_obj.ctor_functions)
@@ -1242,6 +1247,48 @@ def add_pe_optional_headers(metadata, optional_header):
1242
1247
  return metadata
1243
1248
 
1244
1249
 
1250
+ def add_pe_rdata_symbols(metadata, rdata_section: lief.PE.Section):
1251
+ """Adds PE rdata symbols to the metadata dictionary.
1252
+
1253
+ Args:
1254
+ metadata: The dictionary to store the metadata.
1255
+ rdata_section: .rdata section of the PE binary.
1256
+
1257
+ Returns:
1258
+ The updated metadata dictionary.
1259
+ """
1260
+ if not rdata_section or not rdata_section.content:
1261
+ return metadata
1262
+ rdata_symbols = set()
1263
+ pii_symbols = []
1264
+ for pii in PII_WORDS:
1265
+ for vari in (f"get{pii}", f"get_{camel_to_snake(pii)}"):
1266
+ if rdata_section.search_all(vari):
1267
+ pii_symbols.append(
1268
+ {"name": vari.lower(), "type": "FUNCTION", "is_function": True, "is_imported": False})
1269
+ continue
1270
+ str_content = codecs.decode(rdata_section.content.tobytes("A"), encoding="utf-8", errors="ignore")
1271
+ for block in str_content.split(" "):
1272
+ if "runtime." in block or "internal/" in block or ".go" in block or ".dll" in block:
1273
+ if ".go" in block:
1274
+ metadata["exe_type"] = "gobinary"
1275
+ for asym in block.split("\x00"):
1276
+ if re.match(r".*\.(go|s|dll)$", asym):
1277
+ rdata_symbols.add(asym)
1278
+ if not metadata["symtab_symbols"]:
1279
+ metadata["symtab_symbols"] = []
1280
+ metadata["symtab_symbols"] += [
1281
+ {
1282
+ "name": s,
1283
+ "type": "FILE",
1284
+ "is_function": False,
1285
+ "is_imported": True
1286
+ } for s in sorted(rdata_symbols)
1287
+ ]
1288
+ metadata["pii_symbols"] = pii_symbols
1289
+ return metadata
1290
+
1291
+
1245
1292
  def add_mach0_metadata(exe_file, metadata, parsed_obj):
1246
1293
  """Adds MachO metadata to the given metadata dictionary.
1247
1294
 
@@ -1289,7 +1336,7 @@ def add_mach0_metadata(exe_file, metadata, parsed_obj):
1289
1336
  return metadata
1290
1337
 
1291
1338
 
1292
- def add_mach0_commands(metadata, parsed_obj):
1339
+ def add_mach0_commands(metadata, parsed_obj: lief.MachO.Binary):
1293
1340
  """Extracts MachO commands metadata from the parsed object and adds it to the metadata.
1294
1341
 
1295
1342
  Args:
@@ -1307,7 +1354,6 @@ def add_mach0_commands(metadata, parsed_obj):
1307
1354
  metadata["has_thread_command"] = not isinstance(
1308
1355
  parsed_obj.thread_command, lief.lief_errors
1309
1356
  )
1310
-
1311
1357
  return metadata
1312
1358
 
1313
1359
 
@@ -1416,6 +1462,7 @@ def add_mach0_header_data(exe_file, metadata, parsed_obj):
1416
1462
  header = parsed_obj.header
1417
1463
  flags_str = ", ".join([str(s).rsplit(".", maxsplit=1)[-1] for s in header.flags_list])
1418
1464
  metadata["magic"] = str(header.magic).rsplit(".", maxsplit=1)[-1]
1465
+ metadata["is_neural_model"] = header.magic == lief.MachO.MACHO_TYPES.NEURAL_MODEL
1419
1466
  metadata["cpu_type"] = str(header.cpu_type).rsplit(".", maxsplit=1)[-1]
1420
1467
  metadata["cpu_subtype"] = header.cpu_subtype
1421
1468
  metadata["file_type"] = str(header.file_type).rsplit(".", maxsplit=1)[-1]
@@ -185,6 +185,8 @@ def main():
185
185
  else:
186
186
  if args.sbom_output:
187
187
  sbom_output = args.sbom_output
188
+ if os.path.isdir(sbom_output):
189
+ sbom_output = os.path.join(sbom_output, "bom.json")
188
190
  else:
189
191
  sbom_output = os.path.join(os.getcwd(), "bom.json")
190
192
  sbom_output_dir = os.path.dirname(sbom_output)
@@ -1,4 +1,5 @@
1
1
  # pylint: disable=too-many-lines
2
+ import os
2
3
  import re
3
4
 
4
5
  # Default ignore list
@@ -1235,3 +1236,60 @@ secrets_regex = {
1235
1236
  }
1236
1237
 
1237
1238
  SYMBOL_DELIMITER = "~~"
1239
+
1240
+
1241
+ def get_float_from_env(name, default):
1242
+ """
1243
+ Retrieves a value from an environment variable and converts it to a
1244
+ float. If the value cannot be converted to a float, it returns the
1245
+ default value provided.
1246
+
1247
+ :param name:
1248
+ :param default:
1249
+ :return:
1250
+ """
1251
+ value = os.getenv(name.upper(), default)
1252
+ try:
1253
+ value = float(value)
1254
+ except ValueError:
1255
+ value = default
1256
+ return value
1257
+
1258
+
1259
+ def get_int_from_env(name, default):
1260
+ """
1261
+ Retrieves a value from an environment variable and converts it to an
1262
+ integer. If the value cannot be converted to an integer, it returns the
1263
+ default value provided.
1264
+
1265
+ :param name:
1266
+ :param default:
1267
+ """
1268
+ return int(get_float_from_env(name, default))
1269
+
1270
+
1271
+ PII_WORDS = (
1272
+ "FirstName",
1273
+ "LastName",
1274
+ "Phone",
1275
+ "Manager",
1276
+ "City",
1277
+ "Location",
1278
+ "Gender",
1279
+ "Country",
1280
+ "Email",
1281
+ "State",
1282
+ "PostCode",
1283
+ "ZipCode",
1284
+ "SSN",
1285
+ "MobilePhone",
1286
+ "Photo",
1287
+ "HomePhone",
1288
+ "Address",
1289
+ "Card",
1290
+ "PinCode",
1291
+ "OTP",
1292
+ "Calendar",
1293
+ "AgentStatus",
1294
+ "LastLoginTime"
1295
+ )
@@ -85,6 +85,10 @@ rules:
85
85
  - syscall.ForkExecPipe
86
86
  - execabs.Command
87
87
  - execabs.CommandContext
88
+ - os/exec_windows.go
89
+ - os/executable.go
90
+ - os/executable_windows.go
91
+ - os/proc.go
88
92
  - id: SYSCALL_METHODS
89
93
  title: Syscall functions used
90
94
  summary: Can perform system-level operations
@@ -130,6 +134,37 @@ rules:
130
134
  - syscall.Sysinfo
131
135
  - syscall.UnixCredentials
132
136
  - syscall.Unmount
137
+ - runtime/syscall_windows.go
138
+ - runtime/cgocall.go
139
+ - w32/functions_windows.go
140
+ - windows/security_windows.go
141
+ - windows/dll_windows.go
142
+ - windows/syscall.go
143
+ - windows/syscall_windows.go
144
+ - windows/zsyscall_windows.go
145
+ - runtime/mem_windows.go
146
+ - runtime/memclr_amd64.s
147
+ - runtime/memmove_amd64.s
148
+ - runtime/netpoll.go
149
+ - runtime/netpoll_windows.go
150
+ - runtime/os_windows.go
151
+ - runtime/proc.go
152
+ - syscall/dll_windows.go
153
+ - syscall/syscall.go
154
+ - syscall/syscall_windows.go
155
+ - syscall/zsyscall_windows.go
156
+ - id: WIN_SIGNAL_METHODS
157
+ title: Windows Signal functions used
158
+ summary: Can disable Windows Error Reporting
159
+ description: |
160
+ Module signal_windows contains methods to disable Error Reporting.
161
+ patterns:
162
+ - runtime/signal_windows.go
163
+ - runtime/sigqueue.go
164
+ - runtime/symtab.go
165
+ - runtime/sys_windows_amd64.s
166
+ - runtime/sys_x86.go
167
+ - runtime/syscall_windows.go
133
168
  - id: NET_METHODS
134
169
  title: Net functions used
135
170
  summary: Uses Network to send and receive data
@@ -188,6 +223,13 @@ rules:
188
223
  - net.ReadMsgUnix
189
224
  - net.ListenUnix
190
225
  - net.AcceptUnix
226
+ - net/hook_windows.go
227
+ - net/interface.go
228
+ - net/ip.go
229
+ - net/lookup.go
230
+ - net/net.go
231
+ - net/netip/leaf_alts.go
232
+ - net/netip/netip.go
191
233
  - id: HTTP_METHODS
192
234
  title: HTTP server functions used
193
235
  summary: Can run an HTTP server
@@ -223,6 +265,14 @@ rules:
223
265
  - github.com/lucas-clemente/quic-go
224
266
  - github.com/gorilla/websocket
225
267
  - github.com/gorilla/mux
268
+ - id: MEM_METHODS
269
+ title: HTTP server functions used
270
+ summary: Can run an HTTP server
271
+ description: |
272
+ Package http provides HTTP client and server implementations.
273
+ patterns:
274
+ - http.ListenAndServe
275
+
226
276
  - id: HTTP_CLIENT_METHODS
227
277
  title: HTTP client functions used
228
278
  summary: Invokes HTTP service
@@ -337,6 +387,20 @@ rules:
337
387
  - crypto/md4
338
388
  - crypto/md5
339
389
  - crypto/sha1
390
+ - id: CRYPTO_MODULES
391
+ title: Cryptographic modules used
392
+ summary: Uses Crypto Module
393
+ description: |
394
+ Standard go crypto modules used.
395
+ patterns:
396
+ - crypto/aes/asm_amd64.s
397
+ - crypto/aes/block.go
398
+ - crypto/aes/cipher.go
399
+ - crypto/aes/cipher_asm.go
400
+ - crypto/cipher/cbc.go
401
+ - crypto/crypto.go
402
+ - crypto/subtle/xor.go
403
+ - crypto/subtle/xor_amd64.s
340
404
  - id: SSH_METHODS
341
405
  title: ssh library used
342
406
  summary: Can perform SSH operations
@@ -397,6 +461,9 @@ rules:
397
461
  This implementation is designed to minimize heap allocations and avoid unnecessary packing and unpacking as much as possible.
398
462
  patterns:
399
463
  - golang.org/x/net/dns/dnsmessage
464
+ - net/addrselect.go
465
+ - net/dnsclient_unix.go
466
+ - dnsmessage/message.go
400
467
  - id: C_C_LIB
401
468
  title: Command and Control Framework used
402
469
  summary: Can Attack Devices
@@ -6,6 +6,7 @@ url:
6
6
  exe_type:
7
7
  - PE32
8
8
  - PE64
9
+ - gobinary
9
10
  binary_type: PE
10
11
  rules:
11
12
  - id: WIN32_PROCESS_API
@@ -31,6 +32,7 @@ rules:
31
32
  - OpenThreadToken
32
33
  - SetProcessMitigationPolicy
33
34
  - SetThreadToken
35
+ - SetThreadContext
34
36
  - SetProcessShutdownParameters
35
37
  - OpenSemaphore
36
38
  - VirtualAllocEx
@@ -39,6 +41,87 @@ rules:
39
41
  - CreateSocketHandle
40
42
  - CreateThread
41
43
  - CreateThreadpool
44
+ - id: PROCESS_STATUS_API
45
+ title: Process status api used
46
+ summary: Queries about processes and device drivers
47
+ description: |
48
+ The process status application programming interface (PSAPI) is a helper library that makes it easier for you to obtain information about processes and device drivers.
49
+ patterns:
50
+ - EmptyWorkingSet
51
+ - EnumDeviceDrivers
52
+ - EnumPageFiles
53
+ - EnumProcesses
54
+ - EnumProcessModules
55
+ - EnumProcessModulesEx
56
+ - GetDeviceDriverBaseName
57
+ - GetDeviceDriverFileName
58
+ - GetMappedFileName
59
+ - GetModuleBaseName
60
+ - GetModuleFileNameEx
61
+ - GetModuleInformation
62
+ - GetPerformanceInfo
63
+ - GetProcessImageFileName
64
+ - GetProcessMemoryInfo
65
+ - GetWsChanges
66
+ - GetWsChangesEx
67
+ - InitializeProcessForWsWatch
68
+ - QueryWorkingSet
69
+ - QueryWorkingSetEx
70
+ - id: WER_API
71
+ title: Windows Error Reporting api used
72
+ summary: Manipulates Windows Error Reporting
73
+ description: |
74
+ The error reporting feature enables users to notify Microsoft of application faults, kernel faults, unresponsive applications, and other application specific problems. Developers can register with Windows Desktop Application Program to get information about the problems customers are experiencing with their applications and help customers fix these problems. Developers can also use Application Recovery and Restart to ensure that customers do not lose data when their application crashes and allow users to quickly return to their tasks.
75
+ patterns:
76
+ - AddERExcludedApplication
77
+ - WerAddExcludedApplication
78
+ - WerRegisterAdditionalProcess
79
+ - WerRegisterAppLocalDump
80
+ - WerRegisterExcludedMemoryBlock
81
+ - WerRegisterFile
82
+ - WerRegisterMemoryBlock
83
+ - WerRegisterRuntimeExceptionModule
84
+ - WerRemoveExcludedApplication
85
+ - WerReportCloseHandle
86
+ - WerReportSubmit
87
+ - WerStoreGetFirstReportKey
88
+ - WerStoreGetNextReportKey
89
+ - WerStoreQueryReportMetadataV2
90
+ - WerUnregister
91
+ - id: MEMORY_API
92
+ title: Windows Memory api used
93
+ summary: Manipulates System Memory
94
+ description: |
95
+ Windows Memory API.
96
+ patterns:
97
+ - AllocateUserPhysical
98
+ - CreateFileMapping
99
+ - CreateMemoryResourceNotification
100
+ - DiscardVirtualMemory
101
+ - FreeUserPhysicalPages
102
+ - GetMemoryErrorHandlingCapabilities
103
+ - GetProcessWorkingSetSize
104
+ - GetWriteWatch
105
+ - MapUserPhysicalPages
106
+ - MapViewOfFile
107
+ - OfferVirtualMemory
108
+ - OpenFileMapping
109
+ - PrefetchVirtualMemory
110
+ - QueryMemoryResourceNotification
111
+ - QueryVirtualMemoryInformation
112
+ - ReadProcessMemory
113
+ - ReclaimVirtualMemory
114
+ - RegisterBadMemoryNotification
115
+ - ResetWriteWatch
116
+ - SetProcessWorkingSet
117
+ - SetSystemFileCacheSize
118
+ - UnmapViewOfFile
119
+ - UnregisterBadMemoryNotification
120
+ - VirtualAlloc
121
+ - VirtualFree
122
+ - VirtualProtect
123
+ - VirtualQuery
124
+ - WriteProcessMemory
42
125
  - id: CRYPT_XML_API
43
126
  title: Security sensitive crypt xml functions used
44
127
  summary: Uses Crypt XML API
@@ -881,22 +964,73 @@ rules:
881
964
  - AppendMenu
882
965
  - BlockInput
883
966
  - BroadcastSystemMessage
967
+ - CalculatePopupWindowPosition
968
+ - CallWindowProc
969
+ - ChangeClipboardChain
970
+ - ChangeDisplaySettings
971
+ - ChangeWindowMessageFilter
972
+ - CheckMenuItem
973
+ - ChildWindowFromPoint
974
+ - ClipCursor
975
+ - CloseTouchInputHandle
976
+ - CloseWindow
977
+ - CreateAcceleratorTable
978
+ - CreateDesktop
979
+ - CreateDialog
884
980
  - CloseDesktop
885
981
  - CreateMenu
982
+ - CreatePopupMenu
983
+ - CreateWindow
886
984
  - EmptyClipboard
985
+ - EnableWindow
986
+ - EnumDisplayMonitors
987
+ - EnumDisplayDevices
988
+ - EnumDesktopWindows
989
+ - EnumDesktops
990
+ - EnumChildWindows
991
+ - GetCurrentProcessId
992
+ - GetProcessWindowStation
993
+ - GetEnvironmentStrings
994
+ - GetThreadDesktop
995
+ - GetUserObjectInformation
996
+ - SetProcessWindowStation
997
+ - SetThreadDesktop
998
+ - SetUserObjectInformation
999
+ - SwitchDesktop
887
1000
  - FindWindow
1001
+ - GetActiveWindow
1002
+ - GetAltTabInfo
1003
+ - GetCapture
1004
+ - GetClipboardData
1005
+ - GetClipboardFormat
1006
+ - GetLastActivePopup
1007
+ - GetLastInputInfo
1008
+ - GetMenu
1009
+ - GetMonitorInfo
1010
+ - GetOpenClipboardWindow
1011
+ - GetSystemMetrics
1012
+ - GetSystemMenu
1013
+ - GetTopWindow
1014
+ - GetTouchInputInfo
888
1015
  - LockWorkStation
889
1016
  - OpenClipboard
890
1017
  - OpenInputDesktop
891
- - PeekMessageA
892
- - PeekMessageW
893
- - CreateDialogA
894
- - CreateDialogW
895
- - CreateWindowA
896
- - CreateWindowW
897
- - CreateWindowExA
898
- - CreateWindowExW
899
- - CreateWindowStation
1018
+ - PeekMessage
1019
+ - id: WIN_LOADER_API
1020
+ title: Win Loader api functions used
1021
+ summary: Loads dll dynamically
1022
+ description: |
1023
+ Windows Loader API functions.
1024
+ patterns:
1025
+ - AddDllDirectory
1026
+ - DisableThreadLibraryCalls
1027
+ - EnumResourceLanguages
1028
+ - FreeLibrary
1029
+ - GetModuleFileName
1030
+ - GetModuleHandle
1031
+ - GetProcAddress
1032
+ - RemoveDllDirectory
1033
+ - SetDefaultDllDirectories
900
1034
  - id: WIN_LOGON_API
901
1035
  title: Win Logon api functions used
902
1036
  summary: Performs Winlogon calls
@@ -3,6 +3,8 @@ text: Review for Windows rootkits
3
3
  group: METHOD_REVIEWS
4
4
  exe_type:
5
5
  - x86_64-executable
6
+ - PE32
7
+ - PE64
6
8
  rules:
7
9
  - id: BANSHEE
8
10
  title: Detect Banshee
@@ -174,5 +176,3 @@ rules:
174
176
  - ProcessSignature.SignerType
175
177
  - PsRoutinesList
176
178
  - ShellcodeInformation
177
-
178
-
@@ -611,3 +611,31 @@ rules:
611
611
  - SecPolicyGetTypeID
612
612
  - SecPolicyCreateWithProperties
613
613
  - SecPolicyCopyProperties
614
+ - id: IMAGE_SNAP_API
615
+ title: Image Snap API functions used
616
+ summary: Capture Images from iSight and other video sources
617
+ description: |
618
+ ImageSnap is a Public Domain command-line tool that lets you capture still images from an iSight or other video source.
619
+ patterns:
620
+ - ImageSnap defaultVideoDevice
621
+ - ImageSnap saveSingleSnapshotFrom
622
+ - ImageSnap setUpSessionWithDevice
623
+ - ImageSnap getReadyToTakePicture
624
+ - ImageSnap takeSnapshotWithFilename
625
+ - ImageSnap captureSession
626
+ - ImageSnap captureDeviceInput
627
+ - ImageSnap captureStillImageOutput
628
+ - ImageSnap currentImageBuffer
629
+ - ImageSnap videoConnection
630
+ - id: AVFOUNDATION_API
631
+ title: AVFoundation functions used
632
+ summary: Work with audiovisual assets, control device cameras, process audio, and configure system audio interactions
633
+ description: |
634
+ AVFoundation combines several major technology areas that together encompass a wide range of tasks for inspecting, playing, capturing, and processing audiovisual media on Apple platforms.
635
+ patterns:
636
+ - AVFoundation::_
637
+ - AVCaptureSession
638
+ - AVMediaTypeMuxed
639
+ - AVMediaTypeVideo
640
+ - AVVideoCodecJPEG
641
+ - AVVideoCodecKey
@@ -162,6 +162,7 @@
162
162
  - PE32
163
163
  - PE64
164
164
  - dotnetbinary
165
+ - gobinary
165
166
  - id: CHECK_CODESIGN
166
167
  title: Missing Code Signing
167
168
  description: |
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "blint"
3
- version = "2.1.8"
3
+ version = "2.2.0"
4
4
  description = "Linter and SBOM generator for binary files."
5
5
  authors = ["Prabhu Subramanian <prabhu@appthreat.com>", "Caroline Russell <caroline@appthreat.dev>"]
6
6
  license = "MIT"
@@ -29,22 +29,22 @@ blint = 'blint.cli:main'
29
29
 
30
30
  [tool.poetry.dependencies]
31
31
  python = ">=3.10,<3.13"
32
- lief = "^0.14.1"
32
+ lief = "^0.15.1"
33
33
  rich = "^13.7.1"
34
34
  PyYAML = "^6.0.1"
35
35
  defusedxml = "^0.7.1"
36
- pydantic = {version = "^2.6.0", extras = ["email"]}
37
- orjson = "^3.10.3"
36
+ pydantic = {version = "^2.8.2", extras = ["email"]}
37
+ orjson = "^3.10.6"
38
38
  symbolic = "10.2.1"
39
39
  ar = "^0.9.1"
40
40
 
41
41
  [tool.poetry.group.dev.dependencies]
42
- pytest = "^8.0.0"
43
- black = "^24.0.0"
44
- flake8 = "^7.0.0"
45
- pylint = "^3.0.0"
46
- pytest-cov = "^4.0.0"
47
- pyinstaller = "^6.3.0"
42
+ pytest = "^8.3.2"
43
+ black = "^24.4.2"
44
+ flake8 = "^7.1.0"
45
+ pylint = "^3.2.6"
46
+ pytest-cov = "^4.1.0"
47
+ pyinstaller = "^6.9.0"
48
48
 
49
49
  [tool.black]
50
50
  line-length = 99
@@ -1,31 +0,0 @@
1
- ---
2
- text: Review for Monero identified in a binary produced by cargo build
3
- group: SYMBOL_REVIEWS
4
- exe_type: genericbinary
5
- rules:
6
- - id: MONERO_API_RUST
7
- title: Detect monero API
8
- summary:
9
- description: |
10
- Monero is a cryptocurrency focused on private and censorship-resistant transactions.
11
- patterns:
12
- - blockdata::block::Block
13
- - blockdata::block::BlockHeader
14
- - blockdata::transaction::OwnedTxOut
15
- - blockdata::transaction::Transaction
16
- - blockdata::transaction::TransactionPrefix
17
- - blockdata::transaction::TxIn
18
- - blockdata::transaction::TxOut
19
- - consensus_encode
20
- - consensus_decode
21
- - cryptonote::hash::Hash
22
- - monero::blockdata::transaction::Transaction
23
- - monero::consensus::encode::deserialize
24
- - monero::util::key
25
- - Network::Mainnet
26
- - Network::Stagenet
27
- - util::amount::SignedAmount
28
- - MONERO_MUL_FACTOR
29
- - consensus::encode::Encodable
30
- - TxOutTarget
31
- - tx_pubkey
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes