blint 2.2.0__tar.gz → 2.2.2__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 (36) hide show
  1. {blint-2.2.0 → blint-2.2.2}/PKG-INFO +1 -1
  2. {blint-2.2.0 → blint-2.2.2}/blint/analysis.py +37 -9
  3. {blint-2.2.0 → blint-2.2.2}/blint/binary.py +90 -37
  4. {blint-2.2.0 → blint-2.2.2}/blint/config.py +48 -3
  5. {blint-2.2.0 → blint-2.2.2}/blint/data/annotations/review_exe_go.yml +48 -5
  6. {blint-2.2.0 → blint-2.2.2}/blint/data/annotations/review_imports_pe.yml +39 -0
  7. {blint-2.2.0 → blint-2.2.2}/blint/data/annotations/review_monero_go.yml +1 -0
  8. {blint-2.2.0 → blint-2.2.2}/blint/data/annotations/review_rootkits_win.yml +1 -1
  9. {blint-2.2.0 → blint-2.2.2}/blint/data/annotations/review_symbols_antiforensic.yml +18 -7
  10. {blint-2.2.0 → blint-2.2.2}/blint/data/annotations/review_symbols_hooka.yml +1 -0
  11. {blint-2.2.0 → blint-2.2.2}/blint/data/rules.yml +7 -0
  12. {blint-2.2.0 → blint-2.2.2}/blint/utils.py +2 -2
  13. {blint-2.2.0 → blint-2.2.2}/pyproject.toml +1 -1
  14. {blint-2.2.0 → blint-2.2.2}/LICENSE +0 -0
  15. {blint-2.2.0 → blint-2.2.2}/README.md +0 -0
  16. {blint-2.2.0 → blint-2.2.2}/blint/__init__.py +0 -0
  17. {blint-2.2.0 → blint-2.2.2}/blint/android.py +0 -0
  18. {blint-2.2.0 → blint-2.2.2}/blint/checks.py +0 -0
  19. {blint-2.2.0 → blint-2.2.2}/blint/cli.py +0 -0
  20. {blint-2.2.0 → blint-2.2.2}/blint/cyclonedx/README.md +0 -0
  21. {blint-2.2.0 → blint-2.2.2}/blint/cyclonedx/__init__.py +0 -0
  22. {blint-2.2.0 → blint-2.2.2}/blint/cyclonedx/spdx.py +0 -0
  23. {blint-2.2.0 → blint-2.2.2}/blint/cyclonedx/spec.py +0 -0
  24. {blint-2.2.0 → blint-2.2.2}/blint/data/__init__.py +0 -0
  25. {blint-2.2.0 → blint-2.2.2}/blint/data/annotations/__init__.py +0 -0
  26. {blint-2.2.0 → blint-2.2.2}/blint/data/annotations/review_entries_generic.yml +0 -0
  27. {blint-2.2.0 → blint-2.2.2}/blint/data/annotations/review_entries_pe.yml +0 -0
  28. {blint-2.2.0 → blint-2.2.2}/blint/data/annotations/review_methods_generic.yml +0 -0
  29. {blint-2.2.0 → blint-2.2.2}/blint/data/annotations/review_methods_mips.yml +0 -0
  30. {blint-2.2.0 → blint-2.2.2}/blint/data/annotations/review_monero_generic.yml +0 -0
  31. {blint-2.2.0 → blint-2.2.2}/blint/data/annotations/review_monero_rust.yml +0 -0
  32. {blint-2.2.0 → blint-2.2.2}/blint/data/annotations/review_symbols_generic.yml +0 -0
  33. {blint-2.2.0 → blint-2.2.2}/blint/data/annotations/review_symbols_macho.yml +0 -0
  34. {blint-2.2.0 → blint-2.2.2}/blint/data/annotations/review_symbols_rust.yml +0 -0
  35. {blint-2.2.0 → blint-2.2.2}/blint/logger.py +0 -0
  36. {blint-2.2.0 → blint-2.2.2}/blint/sbom.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: blint
3
- Version: 2.2.0
3
+ Version: 2.2.2
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
@@ -21,7 +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
+ from blint.config import FIRST_STAGE_WORDS, PII_WORDS, get_int_from_env
25
25
  from blint.logger import LOG, console
26
26
  from blint.utils import (create_findings_table, is_fuzzable_name, print_findings_table)
27
27
 
@@ -54,12 +54,20 @@ review_methods_dict = defaultdict(list)
54
54
  review_symbols_dict = defaultdict(list)
55
55
  review_imports_dict = defaultdict(list)
56
56
  review_entries_dict = defaultdict(list)
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
+ 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
+ }
63
71
 
64
72
  # Debug mode
65
73
  DEBUG_MODE = os.getenv("SCAN_DEBUG_MODE") == "debug"
@@ -309,7 +317,10 @@ def print_reviews_table(reviews, files):
309
317
  def json_serializer(obj):
310
318
  """JSON serializer to help serialize problematic types such as bytes"""
311
319
  if isinstance(obj, bytes):
312
- return obj.decode('utf-8')
320
+ try:
321
+ return obj.decode('utf-8')
322
+ except UnicodeDecodeError:
323
+ return ""
313
324
 
314
325
  return obj
315
326
 
@@ -494,7 +505,7 @@ class ReviewRunner:
494
505
  or self.review_entries_list
495
506
  ):
496
507
  return self._review_lists(metadata)
497
- return {}
508
+ return self._review_loader_symbols(metadata)
498
509
 
499
510
  def _review_lists(self, metadata):
500
511
  """
@@ -516,6 +527,7 @@ class ReviewRunner:
516
527
  if self.review_entries_list:
517
528
  self._review_entries(metadata)
518
529
  self._review_pii(metadata)
530
+ self._review_loader_symbols(metadata)
519
531
  return self.results
520
532
 
521
533
  def _review_imports(self, metadata):
@@ -562,6 +574,22 @@ class ReviewRunner:
562
574
  results["PII_READ"].append({"pattern": e, "function": e})
563
575
  self.results |= results
564
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
+
565
593
  def _review_symbols_exe(self, metadata):
566
594
  """
567
595
  Reviews symbols in the metadata.
@@ -9,9 +9,15 @@ import orjson
9
9
 
10
10
  import lief
11
11
 
12
- from blint.config import PII_WORDS, get_float_from_env, get_int_from_env
12
+ from blint.config import FIRST_STAGE_WORDS, PII_WORDS, get_float_from_env, get_int_from_env
13
13
  from blint.logger import DEBUG, LOG
14
- from blint.utils import camel_to_snake, calculate_entropy, check_secret, cleanup_dict_lief_errors, decode_base64
14
+ from blint.utils import (
15
+ camel_to_snake,
16
+ calculate_entropy,
17
+ check_secret,
18
+ cleanup_dict_lief_errors,
19
+ decode_base64,
20
+ )
15
21
 
16
22
  SYMBOLIC_FOUND = True
17
23
  try:
@@ -270,7 +276,7 @@ def parse_strings(parsed_obj):
270
276
  if (entropy and (entropy > MIN_ENTROPY or len(s) > MIN_LENGTH)) or secret_type:
271
277
  strings_list.append(
272
278
  {
273
- "value": (decode_base64(s) if s.endswith("==") else s),
279
+ "value": decode_base64(s) if s.endswith("==") else s,
274
280
  "entropy": entropy,
275
281
  "secret_type": secret_type,
276
282
  }
@@ -453,7 +459,11 @@ def process_pe_resources(parsed_obj):
453
459
  "has_manifest": rm.has_manifest,
454
460
  "has_string_table": rm.has_string_table,
455
461
  "has_version": rm.has_version,
456
- "manifest": (rm.manifest.replace("\\xef\\xbb\\xbf", "").removeprefix("\ufeff") if rm.has_manifest else None),
462
+ "manifest": (
463
+ rm.manifest.replace("\\xef\\xbb\\xbf", "").removeprefix("\ufeff")
464
+ if rm.has_manifest
465
+ else None
466
+ ),
457
467
  "version_info": str(rm.version) if rm.has_version else None,
458
468
  "html": rm.html if rm.has_html else None,
459
469
  }
@@ -495,7 +505,9 @@ def process_pe_signature(parsed_obj):
495
505
  "serial_number": signer.serial_number.hex(),
496
506
  "issuer": str(signer.issuer),
497
507
  "digest_algorithm": str(signer.digest_algorithm).rsplit(".", maxsplit=1)[-1],
498
- "encryption_algorithm": str(signer.encryption_algorithm).rsplit(".", maxsplit=1)[-1],
508
+ "encryption_algorithm": str(signer.encryption_algorithm).rsplit(
509
+ ".", maxsplit=1
510
+ )[-1],
499
511
  "encrypted_digest": signer.encrypted_digest.hex(),
500
512
  }
501
513
  signers_list.append(signer_obj)
@@ -535,7 +547,10 @@ def parse_pe_authenticode(parsed_obj):
535
547
  if "version" in tmp_key:
536
548
  tmp_key = "version"
537
549
  value = tmp_a[1].strip()
538
- if value == "???":
550
+ if value in (
551
+ "???",
552
+ "???, ???",
553
+ ):
539
554
  value = "N/A"
540
555
  cert_signer_obj[tmp_key] = value
541
556
  authenticode["cert_signer"] = cert_signer_obj
@@ -788,7 +803,6 @@ def add_elf_metadata(exe_file, metadata, parsed_obj):
788
803
  metadata["has_runpath"] = False
789
804
  elif runpath:
790
805
  metadata["has_runpath"] = True
791
- # This is getting renamed to symtab_symbols in lief 0.15.0
792
806
  symtab_symbols = parsed_obj.symtab_symbols
793
807
  metadata["static"] = bool(symtab_symbols and not isinstance(symtab_symbols, lief.lief_errors))
794
808
  dynamic_entries = parsed_obj.dynamic_entries
@@ -797,6 +811,9 @@ def add_elf_metadata(exe_file, metadata, parsed_obj):
797
811
  metadata["notes"] = parse_notes(parsed_obj)
798
812
  metadata["strings"] = parse_strings(parsed_obj)
799
813
  metadata["symtab_symbols"], exe_type = parse_symbols(symtab_symbols)
814
+ rdata_section = parsed_obj.get_section(".rodata")
815
+ text_section = parsed_obj.get_section(".text")
816
+ add_rdata_symbols(metadata, rdata_section, text_section, parsed_obj.sections)
800
817
  if exe_type:
801
818
  metadata["exe_type"] = exe_type
802
819
  metadata["dynamic_symbols"], exe_type = parse_symbols(parsed_obj.dynamic_symbols)
@@ -1114,10 +1131,16 @@ def add_pe_metadata(exe_file: str, metadata: dict, parsed_obj: lief.PE.Binary):
1114
1131
  break
1115
1132
  rdata_section = parsed_obj.get_section(".rdata")
1116
1133
  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)
1134
+ # If there are no .rdata and .text section, then attempt to look for two alphanumeric sections
1135
+ if not rdata_section and not text_section:
1136
+ for section in parsed_obj.sections:
1137
+ if str(section.name).removeprefix(".").isalnum():
1138
+ if not rdata_section:
1139
+ rdata_section = section
1140
+ else:
1141
+ text_section = section
1142
+ if rdata_section or text_section:
1143
+ add_rdata_symbols(metadata, rdata_section, text_section, parsed_obj.sections)
1121
1144
  metadata["exports"] = parse_pe_exports(parsed_obj.get_export())
1122
1145
  metadata["functions"] = parse_functions(parsed_obj.functions)
1123
1146
  metadata["ctor_functions"] = parse_functions(parsed_obj.ctor_functions)
@@ -1171,13 +1194,13 @@ def add_pe_header_data(metadata, parsed_obj):
1171
1194
  metadata["initial_relative_cs"] = dos_header.initial_relative_cs
1172
1195
  metadata["address_relocation_table"] = ADDRESS_FMT.format(
1173
1196
  dos_header.addressof_relocation_table
1174
- )
1197
+ ).strip()
1175
1198
  metadata["overlay_number"] = dos_header.overlay_number
1176
1199
  metadata["oem_id"] = dos_header.oem_id
1177
1200
  metadata["oem_info"] = dos_header.oem_info
1178
1201
  metadata["address_new_exeheader"] = ADDRESS_FMT.format(
1179
1202
  dos_header.addressof_new_exeheader
1180
- )
1203
+ ).strip()
1181
1204
  metadata["characteristics"] = ", ".join(
1182
1205
  [str(chara).rsplit(".", maxsplit=1)[-1] for chara in header.characteristics_list]
1183
1206
  )
@@ -1222,7 +1245,9 @@ def add_pe_optional_headers(metadata, optional_header):
1222
1245
  metadata["sizeof_code"] = optional_header.sizeof_code
1223
1246
  metadata["sizeof_initialized_data"] = optional_header.sizeof_initialized_data
1224
1247
  metadata["sizeof_uninitialized_data"] = optional_header.sizeof_uninitialized_data
1225
- metadata["addressof_entrypoint"] = ADDRESS_FMT.format(optional_header.addressof_entrypoint)
1248
+ metadata["addressof_entrypoint"] = ADDRESS_FMT.format(
1249
+ optional_header.addressof_entrypoint
1250
+ ).strip()
1226
1251
  metadata["baseof_code"] = optional_header.baseof_code
1227
1252
  metadata["baseof_data"] = optional_header.baseof_data
1228
1253
  metadata["imagebase"] = optional_header.imagebase
@@ -1247,45 +1272,73 @@ def add_pe_optional_headers(metadata, optional_header):
1247
1272
  return metadata
1248
1273
 
1249
1274
 
1250
- def add_pe_rdata_symbols(metadata, rdata_section: lief.PE.Section):
1251
- """Adds PE rdata symbols to the metadata dictionary.
1275
+ def add_rdata_symbols(metadata, rdata_section, text_section, sections):
1276
+ """Adds rdata symbols to the metadata dictionary.
1252
1277
 
1253
1278
  Args:
1254
1279
  metadata: The dictionary to store the metadata.
1255
- rdata_section: .rdata section of the PE binary.
1280
+ rdata_section: .rdata section of the binary.
1281
+ text_section: .text section of the binary.
1282
+ sections: All sections for advanced analysis
1256
1283
 
1257
1284
  Returns:
1258
1285
  The updated metadata dictionary.
1259
1286
  """
1260
- if not rdata_section or not rdata_section.content:
1261
- return metadata
1287
+ file_extns_from_rdata = r".*\.(go|s|dll|exe|pdb)"
1262
1288
  rdata_symbols = set()
1263
1289
  pii_symbols = []
1290
+ first_stage_symbols = []
1264
1291
  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):
1292
+ for vari in (f"get{pii}", f"get_{pii}", f"get_{camel_to_snake(pii)}", f"Get{pii}"):
1293
+ if (rdata_section and rdata_section.search_all(vari)) or (
1294
+ text_section and text_section.search_all(vari)
1295
+ ):
1267
1296
  pii_symbols.append(
1268
- {"name": vari.lower(), "type": "FUNCTION", "is_function": True, "is_imported": False})
1297
+ {
1298
+ "name": vari.lower(),
1299
+ "type": "FUNCTION",
1300
+ "is_function": True,
1301
+ "is_imported": False,
1302
+ }
1303
+ )
1269
1304
  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)
1305
+ for sw in FIRST_STAGE_WORDS:
1306
+ if (rdata_section and rdata_section.search_all(sw)) or (
1307
+ text_section and text_section.search_all(sw)
1308
+ ):
1309
+ first_stage_symbols.append(
1310
+ {"name": sw, "type": "FUNCTION", "is_function": True, "is_imported": True}
1311
+ )
1312
+ # rdata and rodata can be technically anywhere
1313
+ # go binaries could have them under .gopclntab and .gosymtab for example
1314
+ # We attempt to search for symbols in every section.
1315
+ data_sections = []
1316
+ for section in sections:
1317
+ if str(section.name).removeprefix(".").isalnum():
1318
+ data_sections.append(section)
1319
+ for section in data_sections:
1320
+ str_content = (
1321
+ codecs.decode(section.content.tobytes("A"), encoding="utf-8", errors="ignore")
1322
+ if section and section.content
1323
+ else ""
1324
+ )
1325
+ for block in str_content.split(" "):
1326
+ if "runtime." in block or "internal/" in block or re.match(file_extns_from_rdata, block):
1327
+ if ".go" in block:
1328
+ metadata["exe_type"] = "gobinary"
1329
+ for asym in block.split("\x00"):
1330
+ if re.match(file_extns_from_rdata + "$", asym):
1331
+ rdata_symbols.add(asym)
1278
1332
  if not metadata["symtab_symbols"]:
1279
1333
  metadata["symtab_symbols"] = []
1280
1334
  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)
1335
+ {"name": s, "type": "FILE", "is_function": False, "is_imported": True}
1336
+ for s in sorted(rdata_symbols)
1287
1337
  ]
1288
- metadata["pii_symbols"] = pii_symbols
1338
+ if pii_symbols:
1339
+ metadata["pii_symbols"] = pii_symbols
1340
+ if first_stage_symbols:
1341
+ metadata["first_stage_symbols"] = first_stage_symbols
1289
1342
  return metadata
1290
1343
 
1291
1344
 
@@ -1230,7 +1230,7 @@ secrets_regex = {
1230
1230
  "email": [re.compile(r"(?<=mailto:)[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+.[a-zA-Z0-9.-]+")],
1231
1231
  "ip": [
1232
1232
  re.compile(
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])$"
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]+)?$"
1234
1234
  )
1235
1235
  ],
1236
1236
  }
@@ -1268,6 +1268,7 @@ def get_int_from_env(name, default):
1268
1268
  return int(get_float_from_env(name, default))
1269
1269
 
1270
1270
 
1271
+ # PII related symbols
1271
1272
  PII_WORDS = (
1272
1273
  "FirstName",
1273
1274
  "LastName",
@@ -1278,7 +1279,8 @@ PII_WORDS = (
1278
1279
  "Gender",
1279
1280
  "Country",
1280
1281
  "Email",
1281
- "State",
1282
+ "Town",
1283
+ "County",
1282
1284
  "PostCode",
1283
1285
  "ZipCode",
1284
1286
  "SSN",
@@ -1291,5 +1293,48 @@ PII_WORDS = (
1291
1293
  "OTP",
1292
1294
  "Calendar",
1293
1295
  "AgentStatus",
1294
- "LastLoginTime"
1296
+ "LastLoginTime",
1297
+ "BankAccount"
1298
+ )
1299
+
1300
+ # Some symbols to look for in a first-stage payload
1301
+ FIRST_STAGE_WORDS = (
1302
+ "System.ServiceProcess",
1303
+ "System.IO.Compression",
1304
+ "System.Reflection.Emit",
1305
+ "ICryptoTransform",
1306
+ "LoadAssembly",
1307
+ "GetEncodedData",
1308
+ "add_AssemblyResolve",
1309
+ "CreateDecryptor",
1310
+ "GetExecutingAssembly",
1311
+ "GetModules",
1312
+ "get_IsFamilyOrAssembly",
1313
+ "/proc/%d/cmdline",
1314
+ "/proc/%s/exe",
1315
+ "/proc/self/exe",
1316
+ "/proc/net/route",
1317
+ "/etc/resolv.conf",
1318
+ "/usr/lib/systemd/systemd",
1319
+ "/usr/compress/bin/",
1320
+ "/usr/libexec/openssh/sftp-server",
1321
+ "/usr/sbin/reboot",
1322
+ "/usr/bin/reboot",
1323
+ "/usr/sbin/shutdown",
1324
+ "/usr/bin/shutdown",
1325
+ "/usr/sbin/poweroff",
1326
+ "/usr/bin/poweroff",
1327
+ "/usr/sbin/halt",
1328
+ "/usr/bin/halt",
1329
+ "/proc/self/auxv",
1330
+ "/sys/kernel/mm/",
1331
+ "virtualboxemulunit",
1332
+ "virtualboximportunit",
1333
+ "virtualboxunit",
1334
+ "qvirtualboxglobalsunit",
1335
+ "Uvirtualboxdisasm",
1336
+ "loaderx86.dll",
1337
+ "ZwProtectVirtualMemory",
1338
+ "shlwapi.dll",
1339
+ "DeleteCriticalSection"
1295
1340
  )
@@ -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
@@ -53,6 +54,7 @@ rules:
53
54
  - os.CreateTemp
54
55
  - os.NewFile
55
56
  - os.DirFS
57
+ - golang/src/os/file
56
58
  - id: OS_METHODS
57
59
  title: OS functions used
58
60
  summary: Can Execute OS commands
@@ -89,6 +91,10 @@ rules:
89
91
  - os/executable.go
90
92
  - os/executable_windows.go
91
93
  - os/proc.go
94
+ - golang/src/io/pipe.go
95
+ - golang/src/runtime/cgo
96
+ - golang/src/runtime/fds_unix.go
97
+ - golang/src/runtime/internal/syscall/
92
98
  - id: SYSCALL_METHODS
93
99
  title: Syscall functions used
94
100
  summary: Can perform system-level operations
@@ -153,6 +159,7 @@ rules:
153
159
  - syscall/syscall.go
154
160
  - syscall/syscall_windows.go
155
161
  - syscall/zsyscall_windows.go
162
+ - runtime/mem.go
156
163
  - id: WIN_SIGNAL_METHODS
157
164
  title: Windows Signal functions used
158
165
  summary: Can disable Windows Error Reporting
@@ -165,6 +172,15 @@ rules:
165
172
  - runtime/sys_windows_amd64.s
166
173
  - runtime/sys_x86.go
167
174
  - runtime/syscall_windows.go
175
+ - id: OS_SIGNAL_METHODS
176
+ title: OS Signal module used
177
+ summary: Can trap OS signals
178
+ description: |
179
+ Package signal implements access to incoming signals. The functions in this package allow a program to change the way Go programs handle signals.
180
+ patterns:
181
+ - runtime/signal_amd64.go
182
+ - runtime/signal_linux_amd64.go
183
+ - runtime/signal_unix.go
168
184
  - id: NET_METHODS
169
185
  title: Net functions used
170
186
  summary: Uses Network to send and receive data
@@ -230,6 +246,7 @@ rules:
230
246
  - net/net.go
231
247
  - net/netip/leaf_alts.go
232
248
  - net/netip/netip.go
249
+ - golang/src/net/
233
250
  - id: HTTP_METHODS
234
251
  title: HTTP server functions used
235
252
  summary: Can run an HTTP server
@@ -266,13 +283,15 @@ rules:
266
283
  - github.com/gorilla/websocket
267
284
  - github.com/gorilla/mux
268
285
  - id: MEM_METHODS
269
- title: HTTP server functions used
270
- summary: Can run an HTTP server
286
+ title: Memory module used
287
+ summary: Manipulates System Memory
271
288
  description: |
272
- Package http provides HTTP client and server implementations.
289
+ Memory module used.
273
290
  patterns:
274
- - http.ListenAndServe
275
-
291
+ - runtime/mem.go
292
+ - runtime/mem_linux.go
293
+ - runtime/memclr_amd64.s
294
+ - runtime/mcheckmark.go
276
295
  - id: HTTP_CLIENT_METHODS
277
296
  title: HTTP client functions used
278
297
  summary: Invokes HTTP service
@@ -360,6 +379,7 @@ rules:
360
379
  - zip.CreateRaw
361
380
  - archive/tar
362
381
  - github.com/ulikunitz/xz
382
+ - golang/src/compress
363
383
  - id: GIT_METHODS
364
384
  title: Git library used
365
385
  summary: Can perform Git Read and Write operations
@@ -401,6 +421,8 @@ rules:
401
421
  - crypto/crypto.go
402
422
  - crypto/subtle/xor.go
403
423
  - crypto/subtle/xor_amd64.s
424
+ - golang.org/x/crypto
425
+ - golang/src/crypto
404
426
  - id: SSH_METHODS
405
427
  title: ssh library used
406
428
  summary: Can perform SSH operations
@@ -512,3 +534,24 @@ rules:
512
534
  - x509.internal.macos.SecPolicyCopyProperties
513
535
  - x509.internal.macos.SecTrustSettingsCopyCertificates
514
536
  - x509.internal.macos.SecTrustSettingsCopyTrustSettings
537
+ - id: MASSCAN_MODULE
538
+ title: Detect Masscan module
539
+ summary: Can Perform port scans
540
+ description: |
541
+ Masscan is an Internet-scale port scanner. It can scan the entire Internet in under 5 minutes, transmitting 10 million packets per second, from a single machine.
542
+ patterns:
543
+ - massTool/mass.go
544
+ - masscan.go
545
+ - masscan.NewScanner
546
+ - masscan.SetParamTargets
547
+ - masscan.SetParamPorts
548
+ - masscan.SetParamWait
549
+ - masscan.Run
550
+ - id: FTP_MODULE
551
+ title: Detect FTP module
552
+ summary: Can Perform FTP operations
553
+ description: |
554
+ Known FTP modules are used.
555
+ patterns:
556
+ - ftp.go
557
+ - github.com/jlaffaye/ftp
@@ -41,6 +41,11 @@ rules:
41
41
  - CreateSocketHandle
42
42
  - CreateThread
43
43
  - CreateThreadpool
44
+ - GetCurrentThread
45
+ - GetThreadLocale
46
+ - ExitProcess
47
+ - FreeLibrary
48
+ - ExitThread
44
49
  - id: PROCESS_STATUS_API
45
50
  title: Process status api used
46
51
  summary: Queries about processes and device drivers
@@ -464,6 +469,8 @@ rules:
464
469
  - CreateHardLink
465
470
  - BackupEventLog
466
471
  - CreateFileMapping
472
+ - SetFileAttributes
473
+ - SetFilePointer
467
474
  - id: WIN_BCRYPT_API
468
475
  title: Win bcrypt api functions used
469
476
  summary: Can Encrypt Files
@@ -1973,6 +1980,14 @@ rules:
1973
1980
  description: |
1974
1981
  Shell Windows API allows applications to access functions provided by the operating system shell, and to change and enhance it.
1975
1982
  patterns:
1983
+ - DllInstall
1984
+ - GetProcessReference
1985
+ - ParseURLA
1986
+ - ParseURLW
1987
+ - PathFindFileName
1988
+ - PathFindOnPath
1989
+ - PathIsSystemFolder
1990
+ - PathIsUNCServerShare
1976
1991
  - FindExecutableA
1977
1992
  - FindExecutableW
1978
1993
  - InitNetworkAddressControl
@@ -1994,6 +2009,30 @@ rules:
1994
2009
  - GetManagedApplications
1995
2010
  - InstallApplication
1996
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
1997
2036
  - id: KERNEL_API
1998
2037
  title: Kernel api functions used
1999
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,7 @@ text: Review for Windows rootkits
3
3
  group: METHOD_REVIEWS
4
4
  exe_type:
5
5
  - x86_64-executable
6
+ - x86_64-exec
6
7
  - PE32
7
8
  - PE64
8
9
  rules:
@@ -67,7 +68,6 @@ rules:
67
68
  - BeIsStringNull
68
69
  - BeIsStringTerminated
69
70
  - BeUnSupportedFunction
70
-
71
71
  - id: NIDHOGG
72
72
  title: Detect Nidhogg
73
73
  summary: Provides Tools for Gaining Privileged Access and Injecting Malicious Code
@@ -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: |
@@ -174,6 +180,7 @@
174
180
  - genericbinary
175
181
  - gobinary
176
182
  - x86_64-executable
183
+ - x86_64-exec
177
184
  - id: CHECK_TRUST_INFO
178
185
  title: Requires Elevated Execution
179
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.2.0"
3
+ version = "2.2.2"
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"
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
File without changes