blint 2.1.9__tar.gz → 2.2.1__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.9 → blint-2.2.1}/PKG-INFO +5 -4
  2. {blint-2.1.9 → blint-2.2.1}/README.md +1 -0
  3. {blint-2.1.9 → blint-2.2.1}/blint/analysis.py +55 -4
  4. {blint-2.1.9 → blint-2.2.1}/blint/binary.py +131 -45
  5. {blint-2.1.9 → blint-2.2.1}/blint/cli.py +2 -0
  6. {blint-2.1.9 → blint-2.2.1}/blint/config.py +100 -1
  7. {blint-2.1.9 → blint-2.2.1}/blint/data/annotations/review_exe_go.yml +68 -0
  8. {blint-2.1.9 → blint-2.2.1}/blint/data/annotations/review_imports_pe.yml +182 -9
  9. {blint-2.1.9 → blint-2.2.1}/blint/data/annotations/review_monero_go.yml +1 -0
  10. {blint-2.1.9 → blint-2.2.1}/blint/data/annotations/review_rootkits_win.yml +3 -3
  11. {blint-2.1.9 → blint-2.2.1}/blint/data/annotations/review_symbols_antiforensic.yml +18 -7
  12. {blint-2.1.9 → blint-2.2.1}/blint/data/annotations/review_symbols_hooka.yml +1 -0
  13. {blint-2.1.9 → blint-2.2.1}/blint/data/rules.yml +8 -0
  14. {blint-2.1.9 → blint-2.2.1}/blint/utils.py +2 -2
  15. {blint-2.1.9 → blint-2.2.1}/pyproject.toml +10 -10
  16. blint-2.1.9/blint/data/annotations/review_monero_rust +0 -31
  17. {blint-2.1.9 → blint-2.2.1}/LICENSE +0 -0
  18. {blint-2.1.9 → blint-2.2.1}/blint/__init__.py +0 -0
  19. {blint-2.1.9 → blint-2.2.1}/blint/android.py +0 -0
  20. {blint-2.1.9 → blint-2.2.1}/blint/checks.py +0 -0
  21. {blint-2.1.9 → blint-2.2.1}/blint/cyclonedx/README.md +0 -0
  22. {blint-2.1.9 → blint-2.2.1}/blint/cyclonedx/__init__.py +0 -0
  23. {blint-2.1.9 → blint-2.2.1}/blint/cyclonedx/spdx.py +0 -0
  24. {blint-2.1.9 → blint-2.2.1}/blint/cyclonedx/spec.py +0 -0
  25. {blint-2.1.9 → blint-2.2.1}/blint/data/__init__.py +0 -0
  26. {blint-2.1.9 → blint-2.2.1}/blint/data/annotations/__init__.py +0 -0
  27. {blint-2.1.9 → blint-2.2.1}/blint/data/annotations/review_entries_generic.yml +0 -0
  28. {blint-2.1.9 → blint-2.2.1}/blint/data/annotations/review_entries_pe.yml +0 -0
  29. {blint-2.1.9 → blint-2.2.1}/blint/data/annotations/review_methods_generic.yml +0 -0
  30. {blint-2.1.9 → blint-2.2.1}/blint/data/annotations/review_methods_mips.yml +0 -0
  31. {blint-2.1.9 → blint-2.2.1}/blint/data/annotations/review_monero_generic.yml +0 -0
  32. {blint-2.1.9 → blint-2.2.1}/blint/data/annotations/review_monero_rust.yml +0 -0
  33. {blint-2.1.9 → blint-2.2.1}/blint/data/annotations/review_symbols_generic.yml +0 -0
  34. {blint-2.1.9 → blint-2.2.1}/blint/data/annotations/review_symbols_macho.yml +0 -0
  35. {blint-2.1.9 → blint-2.2.1}/blint/data/annotations/review_symbols_rust.yml +0 -0
  36. {blint-2.1.9 → blint-2.2.1}/blint/logger.py +0 -0
  37. {blint-2.1.9 → blint-2.2.1}/blint/sbom.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: blint
3
- Version: 2.1.9
3
+ Version: 2.2.1
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 FIRST_STAGE_WORDS, 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,26 @@ 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 = {
58
+ "PII_READ": {
59
+ "title": "Detect PII Read Operations",
60
+ "summary": "Can Retrieve Sensitive PII data",
61
+ "description": "Contains logic to retrieve sensitive data such as names, email, passwords etc.",
62
+ "patterns": PII_WORDS
63
+ },
64
+ "LOADER_SYMBOLS": {
65
+ "title": "Detect Initial Loader",
66
+ "summary": "Behaves like a loader",
67
+ "description": "The binary behaves like a loader by downloading and executing additional payloads.",
68
+ "patterns": FIRST_STAGE_WORDS
69
+ },
70
+ }
57
71
 
58
72
  # Debug mode
59
73
  DEBUG_MODE = os.getenv("SCAN_DEBUG_MODE") == "debug"
60
74
 
61
75
  # No of evidences per category
62
- EVIDENCE_LIMIT = 5
76
+ EVIDENCE_LIMIT = get_int_from_env("EVIDENCE_LIMIT", 5)
63
77
 
64
78
 
65
79
  def get_resource(package, resource):
@@ -303,7 +317,10 @@ def print_reviews_table(reviews, files):
303
317
  def json_serializer(obj):
304
318
  """JSON serializer to help serialize problematic types such as bytes"""
305
319
  if isinstance(obj, bytes):
306
- return obj.decode('utf-8')
320
+ try:
321
+ return obj.decode('utf-8')
322
+ except UnicodeDecodeError:
323
+ return ""
307
324
 
308
325
  return obj
309
326
 
@@ -488,7 +505,7 @@ class ReviewRunner:
488
505
  or self.review_entries_list
489
506
  ):
490
507
  return self._review_lists(metadata)
491
- return {}
508
+ return self._review_loader_symbols(metadata)
492
509
 
493
510
  def _review_lists(self, metadata):
494
511
  """
@@ -509,6 +526,8 @@ class ReviewRunner:
509
526
  self._review_imports(metadata)
510
527
  if self.review_entries_list:
511
528
  self._review_entries(metadata)
529
+ self._review_pii(metadata)
530
+ self._review_loader_symbols(metadata)
512
531
  return self.results
513
532
 
514
533
  def _review_imports(self, metadata):
@@ -539,6 +558,38 @@ class ReviewRunner:
539
558
  LOG.debug(f"Reviewing {len(entries_list)} dynamic entries")
540
559
  self.run_review_methods_symbols(self.review_entries_list, entries_list)
541
560
 
561
+ def _review_pii(self, metadata):
562
+ """
563
+ Reviews pii symbols.
564
+
565
+ Args:
566
+ metadata (dict): The metadata to review.
567
+
568
+ Returns:
569
+ dict: The results of the review.
570
+ """
571
+ entries_list = [f.get("name", "") for f in metadata.get("pii_symbols", [])]
572
+ results = defaultdict(list)
573
+ for e in entries_list[0:EVIDENCE_LIMIT]:
574
+ results["PII_READ"].append({"pattern": e, "function": e})
575
+ self.results |= results
576
+
577
+ def _review_loader_symbols(self, metadata):
578
+ """
579
+ Reviews loader symbols.
580
+
581
+ Args:
582
+ metadata (dict): The metadata to review.
583
+
584
+ Returns:
585
+ dict: The results of the review.
586
+ """
587
+ entries_list = [f.get("name", "") for f in metadata.get("first_stage_symbols", [])]
588
+ results = defaultdict(list)
589
+ for e in entries_list[0:EVIDENCE_LIMIT]:
590
+ results["LOADER_SYMBOLS"].append({"pattern": e, "function": e})
591
+ self.results |= results
592
+
542
593
  def _review_symbols_exe(self, metadata):
543
594
  """
544
595
  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 FIRST_STAGE_WORDS, 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
 
@@ -268,7 +270,7 @@ def parse_strings(parsed_obj):
268
270
  if (entropy and (entropy > MIN_ENTROPY or len(s) > MIN_LENGTH)) or secret_type:
269
271
  strings_list.append(
270
272
  {
271
- "value": (decode_base64(s) if s.endswith("==") else s),
273
+ "value": decode_base64(s) if s.endswith("==") else s,
272
274
  "entropy": entropy,
273
275
  "secret_type": secret_type,
274
276
  }
@@ -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,29 @@ 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
- # 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))
791
+ symtab_symbols = parsed_obj.symtab_symbols
792
+ metadata["static"] = bool(symtab_symbols and not isinstance(symtab_symbols, lief.lief_errors))
797
793
  dynamic_entries = parsed_obj.dynamic_entries
798
794
  metadata = add_elf_dynamic_entries(dynamic_entries, metadata)
799
795
  metadata = add_elf_symbols(metadata, parsed_obj)
800
796
  metadata["notes"] = parse_notes(parsed_obj)
801
797
  metadata["strings"] = parse_strings(parsed_obj)
802
- metadata["symtab_symbols"], exe_type = parse_symbols(static_symbols)
798
+ metadata["symtab_symbols"], exe_type = parse_symbols(symtab_symbols)
799
+ rdata_section = parsed_obj.get_section(".rodata")
800
+ text_section = parsed_obj.get_section(".text")
801
+ if not metadata["symtab_symbols"]:
802
+ add_elf_rdata_symbols(metadata, rdata_section, text_section)
803
803
  if exe_type:
804
804
  metadata["exe_type"] = exe_type
805
805
  metadata["dynamic_symbols"], exe_type = parse_symbols(parsed_obj.dynamic_symbols)
@@ -893,13 +893,13 @@ def add_elf_dynamic_entries(dynamic_entries, metadata):
893
893
  if isinstance(dynamic_entries, lief.lief_errors):
894
894
  return metadata
895
895
  for entry in dynamic_entries:
896
- if entry.tag == lief.ELF.DYNAMIC_TAGS.NULL:
896
+ if entry.tag == lief.ELF.DynamicEntry.TAG.NULL:
897
897
  continue
898
898
  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,
899
+ lief.ELF.DynamicEntry.TAG.SONAME,
900
+ lief.ELF.DynamicEntry.TAG.NEEDED,
901
+ lief.ELF.DynamicEntry.TAG.RUNPATH,
902
+ lief.ELF.DynamicEntry.TAG.RPATH,
903
903
  ]:
904
904
  metadata["dynamic_entries"].append(
905
905
  {
@@ -923,7 +923,7 @@ def determine_elf_flags(header):
923
923
  A string representing the ELF flags.
924
924
  """
925
925
  eflags_str = ""
926
- if header.machine_type == lief.ELF.ARCH.ARM:
926
+ if header.machine_type == lief.ELF.ARCH.ARM and hasattr(header, "arm_flags_list"):
927
927
  eflags_str = " - ".join(
928
928
  [str(s).rsplit(".", maxsplit=1)[-1] for s in header.arm_flags_list]
929
929
  )
@@ -994,7 +994,7 @@ def parse_go_buildinfo(
994
994
  deps = {}
995
995
  build_info_str: str = ""
996
996
  # Look for specific buildinfo sections for ELF and MachO binaries
997
- build_info: lief.Section = None
997
+ build_info: lief.Section | None = None
998
998
  if isinstance(parsed_obj, lief.ELF.Binary):
999
999
  build_info = parsed_obj.get_section(".go.buildinfo")
1000
1000
  elif isinstance(parsed_obj, lief.MachO.Binary):
@@ -1095,6 +1095,8 @@ def add_pe_metadata(exe_file: str, metadata: dict, parsed_obj: lief.PE.Binary):
1095
1095
  metadata["is_reproducible_build"] = parsed_obj.is_reproducible_build
1096
1096
  metadata["virtual_size"] = parsed_obj.virtual_size
1097
1097
  metadata["has_nx"] = parsed_obj.has_nx
1098
+ metadata["imphash_pefile"] = lief.PE.get_imphash(parsed_obj, lief.PE.IMPHASH_MODE.PEFILE)
1099
+ metadata["imphash_lief"] = lief.PE.get_imphash(parsed_obj, lief.PE.IMPHASH_MODE.LIEF)
1098
1100
  metadata = add_pe_header_data(metadata, parsed_obj)
1099
1101
  metadata["data_directories"] = parse_pe_data(parsed_obj)
1100
1102
  metadata["authenticode"] = parse_pe_authenticode(parsed_obj)
@@ -1113,6 +1115,18 @@ def add_pe_metadata(exe_file: str, metadata: dict, parsed_obj: lief.PE.Binary):
1113
1115
  if e["name"] == "ntoskrnl.exe":
1114
1116
  metadata["is_driver"] = True
1115
1117
  break
1118
+ rdata_section = parsed_obj.get_section(".rdata")
1119
+ text_section = parsed_obj.get_section(".text")
1120
+ # If there are no .rdata and .text section, then attempt to look for two alphanumeric sections
1121
+ if not rdata_section and not text_section:
1122
+ for section in parsed_obj.sections:
1123
+ if str(section.name).removeprefix(".").isalnum():
1124
+ if not rdata_section:
1125
+ rdata_section = section
1126
+ else:
1127
+ text_section = section
1128
+ if rdata_section or text_section:
1129
+ add_pe_rdata_symbols(metadata, rdata_section, text_section)
1116
1130
  metadata["exports"] = parse_pe_exports(parsed_obj.get_export())
1117
1131
  metadata["functions"] = parse_functions(parsed_obj.functions)
1118
1132
  metadata["ctor_functions"] = parse_functions(parsed_obj.ctor_functions)
@@ -1242,6 +1256,78 @@ def add_pe_optional_headers(metadata, optional_header):
1242
1256
  return metadata
1243
1257
 
1244
1258
 
1259
+ def add_pe_rdata_symbols(metadata, rdata_section: lief.PE.Section, text_section: lief.PE.Section):
1260
+ """Adds PE rdata symbols to the metadata dictionary.
1261
+
1262
+ Args:
1263
+ metadata: The dictionary to store the metadata.
1264
+ rdata_section: .rdata section of the PE binary.
1265
+ text_section: .text section of the PE binary.
1266
+
1267
+ Returns:
1268
+ The updated metadata dictionary.
1269
+ """
1270
+ file_extns_from_rdata = r".*\.(go|s|dll|exe|pdb)"
1271
+ rdata_symbols = set()
1272
+ pii_symbols = []
1273
+ first_stage_symbols = []
1274
+ for pii in PII_WORDS:
1275
+ for vari in (f"get{pii}", f"get_{pii}", f"get_{camel_to_snake(pii)}", f"Get{pii}"):
1276
+ if (rdata_section and rdata_section.search_all(vari)) or (text_section and text_section.search_all(vari)):
1277
+ pii_symbols.append(
1278
+ {"name": vari.lower(), "type": "FUNCTION", "is_function": True, "is_imported": False})
1279
+ continue
1280
+ for sw in FIRST_STAGE_WORDS:
1281
+ if (rdata_section and rdata_section.search_all(sw)) or (text_section and text_section.search_all(sw)):
1282
+ first_stage_symbols.append(
1283
+ {"name": sw, "type": "FUNCTION", "is_function": True, "is_imported": True})
1284
+ str_content = codecs.decode(rdata_section.content.tobytes("A"), encoding="utf-8",
1285
+ errors="ignore") if rdata_section and rdata_section.content else ""
1286
+ for block in str_content.split(" "):
1287
+ if "runtime." in block or "internal/" in block or re.match(file_extns_from_rdata, block):
1288
+ if ".go" in block:
1289
+ metadata["exe_type"] = "gobinary"
1290
+ for asym in block.split("\x00"):
1291
+ if re.match(file_extns_from_rdata + "$", asym):
1292
+ rdata_symbols.add(asym)
1293
+ if not metadata["symtab_symbols"]:
1294
+ metadata["symtab_symbols"] = []
1295
+ metadata["symtab_symbols"] += [
1296
+ {
1297
+ "name": s,
1298
+ "type": "FILE",
1299
+ "is_function": False,
1300
+ "is_imported": True
1301
+ } for s in sorted(rdata_symbols)
1302
+ ]
1303
+ if pii_symbols:
1304
+ metadata["pii_symbols"] = pii_symbols
1305
+ if first_stage_symbols:
1306
+ metadata["first_stage_symbols"] = first_stage_symbols
1307
+ return metadata
1308
+
1309
+
1310
+ def add_elf_rdata_symbols(metadata, rdata_section: lief.PE.Section, text_section: lief.PE.Section):
1311
+ """Adds ELF rdata symbols to the metadata dictionary.
1312
+
1313
+ Args:
1314
+ metadata: The dictionary to store the metadata.
1315
+ rdata_section: .data section of the ELF binary.
1316
+ text_section: .text section of the ELF binary.
1317
+
1318
+ Returns:
1319
+ The updated metadata dictionary.
1320
+ """
1321
+ first_stage_symbols = []
1322
+ for sw in FIRST_STAGE_WORDS:
1323
+ if (rdata_section and rdata_section.search_all(sw)) or (text_section and text_section.search_all(sw)):
1324
+ first_stage_symbols.append(
1325
+ {"name": sw, "type": "FUNCTION", "is_function": True, "is_imported": True})
1326
+ if first_stage_symbols:
1327
+ metadata["first_stage_symbols"] = first_stage_symbols
1328
+ return metadata
1329
+
1330
+
1245
1331
  def add_mach0_metadata(exe_file, metadata, parsed_obj):
1246
1332
  """Adds MachO metadata to the given metadata dictionary.
1247
1333
 
@@ -1289,7 +1375,7 @@ def add_mach0_metadata(exe_file, metadata, parsed_obj):
1289
1375
  return metadata
1290
1376
 
1291
1377
 
1292
- def add_mach0_commands(metadata, parsed_obj):
1378
+ def add_mach0_commands(metadata, parsed_obj: lief.MachO.Binary):
1293
1379
  """Extracts MachO commands metadata from the parsed object and adds it to the metadata.
1294
1380
 
1295
1381
  Args:
@@ -1307,7 +1393,6 @@ def add_mach0_commands(metadata, parsed_obj):
1307
1393
  metadata["has_thread_command"] = not isinstance(
1308
1394
  parsed_obj.thread_command, lief.lief_errors
1309
1395
  )
1310
-
1311
1396
  return metadata
1312
1397
 
1313
1398
 
@@ -1416,6 +1501,7 @@ def add_mach0_header_data(exe_file, metadata, parsed_obj):
1416
1501
  header = parsed_obj.header
1417
1502
  flags_str = ", ".join([str(s).rsplit(".", maxsplit=1)[-1] for s in header.flags_list])
1418
1503
  metadata["magic"] = str(header.magic).rsplit(".", maxsplit=1)[-1]
1504
+ metadata["is_neural_model"] = header.magic == lief.MachO.MACHO_TYPES.NEURAL_MODEL
1419
1505
  metadata["cpu_type"] = str(header.cpu_type).rsplit(".", maxsplit=1)[-1]
1420
1506
  metadata["cpu_subtype"] = header.cpu_subtype
1421
1507
  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
@@ -1229,9 +1230,107 @@ secrets_regex = {
1229
1230
  "email": [re.compile(r"(?<=mailto:)[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+.[a-zA-Z0-9.-]+")],
1230
1231
  "ip": [
1231
1232
  re.compile(
1232
- r"^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9]).){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])$"
1233
+ r"^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9]).){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])(:[0-9]+)?$"
1233
1234
  )
1234
1235
  ],
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 related symbols
1272
+ PII_WORDS = (
1273
+ "FirstName",
1274
+ "LastName",
1275
+ "Phone",
1276
+ "Manager",
1277
+ "City",
1278
+ "Location",
1279
+ "Gender",
1280
+ "Country",
1281
+ "Email",
1282
+ "State",
1283
+ "PostCode",
1284
+ "ZipCode",
1285
+ "SSN",
1286
+ "MobilePhone",
1287
+ "Photo",
1288
+ "HomePhone",
1289
+ "Address",
1290
+ "Card",
1291
+ "PinCode",
1292
+ "OTP",
1293
+ "Calendar",
1294
+ "AgentStatus",
1295
+ "LastLoginTime"
1296
+ )
1297
+
1298
+ # Some symbols to look for in a first-stage payload
1299
+ FIRST_STAGE_WORDS = (
1300
+ "System.ServiceProcess",
1301
+ "System.IO.Compression",
1302
+ "System.Reflection.Emit",
1303
+ "ICryptoTransform",
1304
+ "LoadAssembly",
1305
+ "GetEncodedData",
1306
+ "add_AssemblyResolve",
1307
+ "CreateDecryptor",
1308
+ "GetExecutingAssembly",
1309
+ "GetModules",
1310
+ "get_IsFamilyOrAssembly",
1311
+ "/proc/%d/cmdline",
1312
+ "/proc/%s/exe",
1313
+ "/proc/self/exe",
1314
+ "/proc/net/route",
1315
+ "/etc/resolv.conf",
1316
+ "/usr/lib/systemd/systemd",
1317
+ "/usr/compress/bin/",
1318
+ "/usr/libexec/openssh/sftp-server",
1319
+ "/usr/sbin/reboot",
1320
+ "/usr/bin/reboot",
1321
+ "/usr/sbin/shutdown",
1322
+ "/usr/bin/shutdown",
1323
+ "/usr/sbin/poweroff",
1324
+ "/usr/bin/poweroff",
1325
+ "/usr/sbin/halt",
1326
+ "/usr/bin/halt",
1327
+ "virtualboxemulunit",
1328
+ "virtualboximportunit",
1329
+ "virtualboxunit",
1330
+ "qvirtualboxglobalsunit",
1331
+ "Uvirtualboxdisasm",
1332
+ "loaderx86.dll",
1333
+ "ZwProtectVirtualMemory",
1334
+ "shlwapi.dll",
1335
+ "DeleteCriticalSection"
1336
+ )
@@ -4,6 +4,7 @@ group: EXE_REVIEWS
4
4
  exe_type:
5
5
  - gobinary
6
6
  - x86_64-executable
7
+ - x86_64-exec
7
8
  rules:
8
9
  - id: FILE_IOUTIL
9
10
  title: IO util functions used
@@ -85,6 +86,10 @@ rules:
85
86
  - syscall.ForkExecPipe
86
87
  - execabs.Command
87
88
  - execabs.CommandContext
89
+ - os/exec_windows.go
90
+ - os/executable.go
91
+ - os/executable_windows.go
92
+ - os/proc.go
88
93
  - id: SYSCALL_METHODS
89
94
  title: Syscall functions used
90
95
  summary: Can perform system-level operations
@@ -130,6 +135,37 @@ rules:
130
135
  - syscall.Sysinfo
131
136
  - syscall.UnixCredentials
132
137
  - syscall.Unmount
138
+ - runtime/syscall_windows.go
139
+ - runtime/cgocall.go
140
+ - w32/functions_windows.go
141
+ - windows/security_windows.go
142
+ - windows/dll_windows.go
143
+ - windows/syscall.go
144
+ - windows/syscall_windows.go
145
+ - windows/zsyscall_windows.go
146
+ - runtime/mem_windows.go
147
+ - runtime/memclr_amd64.s
148
+ - runtime/memmove_amd64.s
149
+ - runtime/netpoll.go
150
+ - runtime/netpoll_windows.go
151
+ - runtime/os_windows.go
152
+ - runtime/proc.go
153
+ - syscall/dll_windows.go
154
+ - syscall/syscall.go
155
+ - syscall/syscall_windows.go
156
+ - syscall/zsyscall_windows.go
157
+ - id: WIN_SIGNAL_METHODS
158
+ title: Windows Signal functions used
159
+ summary: Can disable Windows Error Reporting
160
+ description: |
161
+ Module signal_windows contains methods to disable Error Reporting.
162
+ patterns:
163
+ - runtime/signal_windows.go
164
+ - runtime/sigqueue.go
165
+ - runtime/symtab.go
166
+ - runtime/sys_windows_amd64.s
167
+ - runtime/sys_x86.go
168
+ - runtime/syscall_windows.go
133
169
  - id: NET_METHODS
134
170
  title: Net functions used
135
171
  summary: Uses Network to send and receive data
@@ -188,6 +224,13 @@ rules:
188
224
  - net.ReadMsgUnix
189
225
  - net.ListenUnix
190
226
  - net.AcceptUnix
227
+ - net/hook_windows.go
228
+ - net/interface.go
229
+ - net/ip.go
230
+ - net/lookup.go
231
+ - net/net.go
232
+ - net/netip/leaf_alts.go
233
+ - net/netip/netip.go
191
234
  - id: HTTP_METHODS
192
235
  title: HTTP server functions used
193
236
  summary: Can run an HTTP server
@@ -223,6 +266,14 @@ rules:
223
266
  - github.com/lucas-clemente/quic-go
224
267
  - github.com/gorilla/websocket
225
268
  - github.com/gorilla/mux
269
+ - id: MEM_METHODS
270
+ title: HTTP server functions used
271
+ summary: Can run an HTTP server
272
+ description: |
273
+ Package http provides HTTP client and server implementations.
274
+ patterns:
275
+ - http.ListenAndServe
276
+
226
277
  - id: HTTP_CLIENT_METHODS
227
278
  title: HTTP client functions used
228
279
  summary: Invokes HTTP service
@@ -337,6 +388,20 @@ rules:
337
388
  - crypto/md4
338
389
  - crypto/md5
339
390
  - crypto/sha1
391
+ - id: CRYPTO_MODULES
392
+ title: Cryptographic modules used
393
+ summary: Uses Crypto Module
394
+ description: |
395
+ Standard go crypto modules used.
396
+ patterns:
397
+ - crypto/aes/asm_amd64.s
398
+ - crypto/aes/block.go
399
+ - crypto/aes/cipher.go
400
+ - crypto/aes/cipher_asm.go
401
+ - crypto/cipher/cbc.go
402
+ - crypto/crypto.go
403
+ - crypto/subtle/xor.go
404
+ - crypto/subtle/xor_amd64.s
340
405
  - id: SSH_METHODS
341
406
  title: ssh library used
342
407
  summary: Can perform SSH operations
@@ -397,6 +462,9 @@ rules:
397
462
  This implementation is designed to minimize heap allocations and avoid unnecessary packing and unpacking as much as possible.
398
463
  patterns:
399
464
  - golang.org/x/net/dns/dnsmessage
465
+ - net/addrselect.go
466
+ - net/dnsclient_unix.go
467
+ - dnsmessage/message.go
400
468
  - id: C_C_LIB
401
469
  title: Command and Control Framework used
402
470
  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,92 @@ rules:
39
41
  - CreateSocketHandle
40
42
  - CreateThread
41
43
  - CreateThreadpool
44
+ - GetCurrentThread
45
+ - GetThreadLocale
46
+ - ExitProcess
47
+ - FreeLibrary
48
+ - ExitThread
49
+ - id: PROCESS_STATUS_API
50
+ title: Process status api used
51
+ summary: Queries about processes and device drivers
52
+ description: |
53
+ 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.
54
+ patterns:
55
+ - EmptyWorkingSet
56
+ - EnumDeviceDrivers
57
+ - EnumPageFiles
58
+ - EnumProcesses
59
+ - EnumProcessModules
60
+ - EnumProcessModulesEx
61
+ - GetDeviceDriverBaseName
62
+ - GetDeviceDriverFileName
63
+ - GetMappedFileName
64
+ - GetModuleBaseName
65
+ - GetModuleFileNameEx
66
+ - GetModuleInformation
67
+ - GetPerformanceInfo
68
+ - GetProcessImageFileName
69
+ - GetProcessMemoryInfo
70
+ - GetWsChanges
71
+ - GetWsChangesEx
72
+ - InitializeProcessForWsWatch
73
+ - QueryWorkingSet
74
+ - QueryWorkingSetEx
75
+ - id: WER_API
76
+ title: Windows Error Reporting api used
77
+ summary: Manipulates Windows Error Reporting
78
+ description: |
79
+ 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.
80
+ patterns:
81
+ - AddERExcludedApplication
82
+ - WerAddExcludedApplication
83
+ - WerRegisterAdditionalProcess
84
+ - WerRegisterAppLocalDump
85
+ - WerRegisterExcludedMemoryBlock
86
+ - WerRegisterFile
87
+ - WerRegisterMemoryBlock
88
+ - WerRegisterRuntimeExceptionModule
89
+ - WerRemoveExcludedApplication
90
+ - WerReportCloseHandle
91
+ - WerReportSubmit
92
+ - WerStoreGetFirstReportKey
93
+ - WerStoreGetNextReportKey
94
+ - WerStoreQueryReportMetadataV2
95
+ - WerUnregister
96
+ - id: MEMORY_API
97
+ title: Windows Memory api used
98
+ summary: Manipulates System Memory
99
+ description: |
100
+ Windows Memory API.
101
+ patterns:
102
+ - AllocateUserPhysical
103
+ - CreateFileMapping
104
+ - CreateMemoryResourceNotification
105
+ - DiscardVirtualMemory
106
+ - FreeUserPhysicalPages
107
+ - GetMemoryErrorHandlingCapabilities
108
+ - GetProcessWorkingSetSize
109
+ - GetWriteWatch
110
+ - MapUserPhysicalPages
111
+ - MapViewOfFile
112
+ - OfferVirtualMemory
113
+ - OpenFileMapping
114
+ - PrefetchVirtualMemory
115
+ - QueryMemoryResourceNotification
116
+ - QueryVirtualMemoryInformation
117
+ - ReadProcessMemory
118
+ - ReclaimVirtualMemory
119
+ - RegisterBadMemoryNotification
120
+ - ResetWriteWatch
121
+ - SetProcessWorkingSet
122
+ - SetSystemFileCacheSize
123
+ - UnmapViewOfFile
124
+ - UnregisterBadMemoryNotification
125
+ - VirtualAlloc
126
+ - VirtualFree
127
+ - VirtualProtect
128
+ - VirtualQuery
129
+ - WriteProcessMemory
42
130
  - id: CRYPT_XML_API
43
131
  title: Security sensitive crypt xml functions used
44
132
  summary: Uses Crypt XML API
@@ -381,6 +469,8 @@ rules:
381
469
  - CreateHardLink
382
470
  - BackupEventLog
383
471
  - CreateFileMapping
472
+ - SetFileAttributes
473
+ - SetFilePointer
384
474
  - id: WIN_BCRYPT_API
385
475
  title: Win bcrypt api functions used
386
476
  summary: Can Encrypt Files
@@ -881,22 +971,73 @@ rules:
881
971
  - AppendMenu
882
972
  - BlockInput
883
973
  - BroadcastSystemMessage
974
+ - CalculatePopupWindowPosition
975
+ - CallWindowProc
976
+ - ChangeClipboardChain
977
+ - ChangeDisplaySettings
978
+ - ChangeWindowMessageFilter
979
+ - CheckMenuItem
980
+ - ChildWindowFromPoint
981
+ - ClipCursor
982
+ - CloseTouchInputHandle
983
+ - CloseWindow
984
+ - CreateAcceleratorTable
985
+ - CreateDesktop
986
+ - CreateDialog
884
987
  - CloseDesktop
885
988
  - CreateMenu
989
+ - CreatePopupMenu
990
+ - CreateWindow
886
991
  - EmptyClipboard
992
+ - EnableWindow
993
+ - EnumDisplayMonitors
994
+ - EnumDisplayDevices
995
+ - EnumDesktopWindows
996
+ - EnumDesktops
997
+ - EnumChildWindows
998
+ - GetCurrentProcessId
999
+ - GetProcessWindowStation
1000
+ - GetEnvironmentStrings
1001
+ - GetThreadDesktop
1002
+ - GetUserObjectInformation
1003
+ - SetProcessWindowStation
1004
+ - SetThreadDesktop
1005
+ - SetUserObjectInformation
1006
+ - SwitchDesktop
887
1007
  - FindWindow
1008
+ - GetActiveWindow
1009
+ - GetAltTabInfo
1010
+ - GetCapture
1011
+ - GetClipboardData
1012
+ - GetClipboardFormat
1013
+ - GetLastActivePopup
1014
+ - GetLastInputInfo
1015
+ - GetMenu
1016
+ - GetMonitorInfo
1017
+ - GetOpenClipboardWindow
1018
+ - GetSystemMetrics
1019
+ - GetSystemMenu
1020
+ - GetTopWindow
1021
+ - GetTouchInputInfo
888
1022
  - LockWorkStation
889
1023
  - OpenClipboard
890
1024
  - OpenInputDesktop
891
- - PeekMessageA
892
- - PeekMessageW
893
- - CreateDialogA
894
- - CreateDialogW
895
- - CreateWindowA
896
- - CreateWindowW
897
- - CreateWindowExA
898
- - CreateWindowExW
899
- - CreateWindowStation
1025
+ - PeekMessage
1026
+ - id: WIN_LOADER_API
1027
+ title: Win Loader api functions used
1028
+ summary: Loads dll dynamically
1029
+ description: |
1030
+ Windows Loader API functions.
1031
+ patterns:
1032
+ - AddDllDirectory
1033
+ - DisableThreadLibraryCalls
1034
+ - EnumResourceLanguages
1035
+ - FreeLibrary
1036
+ - GetModuleFileName
1037
+ - GetModuleHandle
1038
+ - GetProcAddress
1039
+ - RemoveDllDirectory
1040
+ - SetDefaultDllDirectories
900
1041
  - id: WIN_LOGON_API
901
1042
  title: Win Logon api functions used
902
1043
  summary: Performs Winlogon calls
@@ -1839,6 +1980,14 @@ rules:
1839
1980
  description: |
1840
1981
  Shell Windows API allows applications to access functions provided by the operating system shell, and to change and enhance it.
1841
1982
  patterns:
1983
+ - DllInstall
1984
+ - GetProcessReference
1985
+ - ParseURLA
1986
+ - ParseURLW
1987
+ - PathFindFileName
1988
+ - PathFindOnPath
1989
+ - PathIsSystemFolder
1990
+ - PathIsUNCServerShare
1842
1991
  - FindExecutableA
1843
1992
  - FindExecutableW
1844
1993
  - InitNetworkAddressControl
@@ -1860,6 +2009,30 @@ rules:
1860
2009
  - GetManagedApplications
1861
2010
  - InstallApplication
1862
2011
  - UninstallApplication
2012
+ - SHCreateThread
2013
+ - SHCreateStreamOnFile
2014
+ - SHOpenRegStream
2015
+ - SHRegCreateUSKey
2016
+ - SHQueryValueEx
2017
+ - SHQueryInfoKey
2018
+ - UrlCreateFromPath
2019
+ - PathMatchSpec
2020
+ - SHBindToFolderIDListParent
2021
+ - SHBrowseForFolder
2022
+ - SHCreateDefaultContextMenu
2023
+ - SHCreateShellItem
2024
+ - SHFormatDrive
2025
+ - SHGetDesktopFolder
2026
+ - SHGetFolderPath
2027
+ - SHGetFolderPathAndSubDir
2028
+ - SHGetKnownFolder
2029
+ - SHGetSpecialFolderLocation
2030
+ - SHILCreateFromPath
2031
+ - SHPathPrepareForWrite
2032
+ - SHSetKnownFolderPath
2033
+ - SignalFileOpen
2034
+ - Win32DeleteFile
2035
+ - shlwapi.dll
1863
2036
  - id: KERNEL_API
1864
2037
  title: Kernel api functions used
1865
2038
  summary: Manipulates Windows Kernel & Drivers
@@ -4,6 +4,7 @@ group: SYMBOL_REVIEWS
4
4
  exe_type:
5
5
  - gobinary
6
6
  - x86_64-executable
7
+ - x86_64-exec
7
8
  rules:
8
9
  - id: MONERO_API_GO
9
10
  title: Detect use of Monero wallet
@@ -3,6 +3,9 @@ text: Review for Windows rootkits
3
3
  group: METHOD_REVIEWS
4
4
  exe_type:
5
5
  - x86_64-executable
6
+ - x86_64-exec
7
+ - PE32
8
+ - PE64
6
9
  rules:
7
10
  - id: BANSHEE
8
11
  title: Detect Banshee
@@ -65,7 +68,6 @@ rules:
65
68
  - BeIsStringNull
66
69
  - BeIsStringTerminated
67
70
  - BeUnSupportedFunction
68
-
69
71
  - id: NIDHOGG
70
72
  title: Detect Nidhogg
71
73
  summary: Provides Tools for Gaining Privileged Access and Injecting Malicious Code
@@ -174,5 +176,3 @@ rules:
174
176
  - ProcessSignature.SignerType
175
177
  - PsRoutinesList
176
178
  - ShellcodeInformation
177
-
178
-
@@ -4,6 +4,7 @@ group: SYMBOL_REVIEWS
4
4
  exe_type:
5
5
  - genericbinary
6
6
  - x86_64-executable
7
+ - x86_64-exec
7
8
  - gobinary
8
9
  - PE32
9
10
  - PE64
@@ -29,7 +30,6 @@ rules:
29
30
  - MeltFile
30
31
  - SysmonUnload
31
32
  - _RtlAdjustPrivilege
32
-
33
33
  - id: PUPY
34
34
  title: Pupy Post-Exploitation Framework
35
35
  summary: Detect Erasing of Evidence of Exploitation
@@ -129,9 +129,20 @@ rules:
129
129
  - pupycompile
130
130
  - pupygen
131
131
  - run_pupy
132
-
133
-
134
-
135
-
136
-
137
-
132
+ - id: RAW_NET_ACCESS
133
+ title: Raw Network API
134
+ summary: Detect use of Network API
135
+ description: |
136
+ Low-level network and dns API functions are used to prevent detection.
137
+ patterns:
138
+ - opennameservers.c
139
+ - closenameservers.c
140
+ - read_etc_hosts_r.c
141
+ - dnslookup.c
142
+ - __read_etc_hosts_r
143
+ - __open_nameservers
144
+ - getRandomIP
145
+ - __libc_connect
146
+ - __GI_gethostbyname2_r
147
+ - gethostbyname.c
148
+ - connect.c
@@ -4,6 +4,7 @@ group: SYMBOL_REVIEWS
4
4
  exe_type:
5
5
  - gobinary
6
6
  - x86_64-executable
7
+ - x86_64-exec
7
8
  - genericbinary
8
9
  rules:
9
10
  - id: HOOKA
@@ -13,6 +13,7 @@
13
13
  exe_types:
14
14
  - genericbinary
15
15
  - x86_64-executable
16
+ - x86_64-exec
16
17
  - gobinary
17
18
  - PE32
18
19
  - PE64
@@ -34,6 +35,7 @@
34
35
  exe_types:
35
36
  - genericbinary
36
37
  - x86_64-executable
38
+ - x86_64-exec
37
39
  - gobinary
38
40
  - PE32
39
41
  - PE64
@@ -61,6 +63,7 @@
61
63
  exe_types:
62
64
  - genericbinary
63
65
  - x86_64-executable
66
+ - x86_64-exec
64
67
  - gobinary
65
68
  - mips-executable
66
69
  - id: CHECK_CANARY
@@ -79,6 +82,7 @@
79
82
  exe_types:
80
83
  - genericbinary
81
84
  - x86_64-executable
85
+ - x86_64-exec
82
86
  - dotnetbinary
83
87
  - mips-executable
84
88
  - id: CHECK_RPATH
@@ -123,6 +127,7 @@
123
127
  - gobinary
124
128
  - dotnetbinary
125
129
  - x86_64-executable
130
+ - x86_64-exec
126
131
  - id: CHECK_AUTHENTICODE
127
132
  title: Missing Authenticode
128
133
  description: |
@@ -138,6 +143,7 @@
138
143
  - gobinary
139
144
  - dotnetbinary
140
145
  - x86_64-executable
146
+ - x86_64-exec
141
147
  - id: CHECK_DLL_CHARACTERISTICS
142
148
  title: Missing dll Security Characteristics
143
149
  description: |
@@ -162,6 +168,7 @@
162
168
  - PE32
163
169
  - PE64
164
170
  - dotnetbinary
171
+ - gobinary
165
172
  - id: CHECK_CODESIGN
166
173
  title: Missing Code Signing
167
174
  description: |
@@ -173,6 +180,7 @@
173
180
  - genericbinary
174
181
  - gobinary
175
182
  - x86_64-executable
183
+ - x86_64-exec
176
184
  - id: CHECK_TRUST_INFO
177
185
  title: Requires Elevated Execution
178
186
  description: |
@@ -12,7 +12,7 @@ from pathlib import Path
12
12
 
13
13
  from ar import Archive
14
14
  import lief
15
- from defusedxml.ElementTree import fromstring
15
+ from defusedxml.ElementTree import fromstring, ParseError
16
16
  from rich import box
17
17
  from rich.table import Table
18
18
 
@@ -322,7 +322,7 @@ def parse_pe_manifest(manifest):
322
322
  for ele in child.iter():
323
323
  attribs_dict[ele.tag.rpartition("}")[-1]] = ele.attrib
324
324
  return attribs_dict
325
- except (TypeError, AttributeError, IndexError) as e:
325
+ except (TypeError, AttributeError, IndexError, ParseError) as e:
326
326
  LOG.debug(f"Caught {type(e)}: {e} while parsing PE manifest.")
327
327
  return {}
328
328
 
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "blint"
3
- version = "2.1.9"
3
+ version = "2.2.1"
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