blint 2.2.1__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.1 → blint-2.2.2}/PKG-INFO +1 -1
  2. {blint-2.2.1 → blint-2.2.2}/blint/binary.py +68 -54
  3. {blint-2.2.1 → blint-2.2.2}/blint/config.py +6 -2
  4. {blint-2.2.1 → blint-2.2.2}/blint/data/annotations/review_exe_go.yml +47 -5
  5. {blint-2.2.1 → blint-2.2.2}/pyproject.toml +1 -1
  6. {blint-2.2.1 → blint-2.2.2}/LICENSE +0 -0
  7. {blint-2.2.1 → blint-2.2.2}/README.md +0 -0
  8. {blint-2.2.1 → blint-2.2.2}/blint/__init__.py +0 -0
  9. {blint-2.2.1 → blint-2.2.2}/blint/analysis.py +0 -0
  10. {blint-2.2.1 → blint-2.2.2}/blint/android.py +0 -0
  11. {blint-2.2.1 → blint-2.2.2}/blint/checks.py +0 -0
  12. {blint-2.2.1 → blint-2.2.2}/blint/cli.py +0 -0
  13. {blint-2.2.1 → blint-2.2.2}/blint/cyclonedx/README.md +0 -0
  14. {blint-2.2.1 → blint-2.2.2}/blint/cyclonedx/__init__.py +0 -0
  15. {blint-2.2.1 → blint-2.2.2}/blint/cyclonedx/spdx.py +0 -0
  16. {blint-2.2.1 → blint-2.2.2}/blint/cyclonedx/spec.py +0 -0
  17. {blint-2.2.1 → blint-2.2.2}/blint/data/__init__.py +0 -0
  18. {blint-2.2.1 → blint-2.2.2}/blint/data/annotations/__init__.py +0 -0
  19. {blint-2.2.1 → blint-2.2.2}/blint/data/annotations/review_entries_generic.yml +0 -0
  20. {blint-2.2.1 → blint-2.2.2}/blint/data/annotations/review_entries_pe.yml +0 -0
  21. {blint-2.2.1 → blint-2.2.2}/blint/data/annotations/review_imports_pe.yml +0 -0
  22. {blint-2.2.1 → blint-2.2.2}/blint/data/annotations/review_methods_generic.yml +0 -0
  23. {blint-2.2.1 → blint-2.2.2}/blint/data/annotations/review_methods_mips.yml +0 -0
  24. {blint-2.2.1 → blint-2.2.2}/blint/data/annotations/review_monero_generic.yml +0 -0
  25. {blint-2.2.1 → blint-2.2.2}/blint/data/annotations/review_monero_go.yml +0 -0
  26. {blint-2.2.1 → blint-2.2.2}/blint/data/annotations/review_monero_rust.yml +0 -0
  27. {blint-2.2.1 → blint-2.2.2}/blint/data/annotations/review_rootkits_win.yml +0 -0
  28. {blint-2.2.1 → blint-2.2.2}/blint/data/annotations/review_symbols_antiforensic.yml +0 -0
  29. {blint-2.2.1 → blint-2.2.2}/blint/data/annotations/review_symbols_generic.yml +0 -0
  30. {blint-2.2.1 → blint-2.2.2}/blint/data/annotations/review_symbols_hooka.yml +0 -0
  31. {blint-2.2.1 → blint-2.2.2}/blint/data/annotations/review_symbols_macho.yml +0 -0
  32. {blint-2.2.1 → blint-2.2.2}/blint/data/annotations/review_symbols_rust.yml +0 -0
  33. {blint-2.2.1 → blint-2.2.2}/blint/data/rules.yml +0 -0
  34. {blint-2.2.1 → blint-2.2.2}/blint/logger.py +0 -0
  35. {blint-2.2.1 → blint-2.2.2}/blint/sbom.py +0 -0
  36. {blint-2.2.1 → blint-2.2.2}/blint/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: blint
3
- Version: 2.2.1
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
@@ -11,7 +11,13 @@ import lief
11
11
 
12
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:
@@ -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
@@ -798,8 +813,7 @@ def add_elf_metadata(exe_file, metadata, parsed_obj):
798
813
  metadata["symtab_symbols"], exe_type = parse_symbols(symtab_symbols)
799
814
  rdata_section = parsed_obj.get_section(".rodata")
800
815
  text_section = parsed_obj.get_section(".text")
801
- if not metadata["symtab_symbols"]:
802
- add_elf_rdata_symbols(metadata, rdata_section, text_section)
816
+ add_rdata_symbols(metadata, rdata_section, text_section, parsed_obj.sections)
803
817
  if exe_type:
804
818
  metadata["exe_type"] = exe_type
805
819
  metadata["dynamic_symbols"], exe_type = parse_symbols(parsed_obj.dynamic_symbols)
@@ -1126,7 +1140,7 @@ def add_pe_metadata(exe_file: str, metadata: dict, parsed_obj: lief.PE.Binary):
1126
1140
  else:
1127
1141
  text_section = section
1128
1142
  if rdata_section or text_section:
1129
- add_pe_rdata_symbols(metadata, rdata_section, text_section)
1143
+ add_rdata_symbols(metadata, rdata_section, text_section, parsed_obj.sections)
1130
1144
  metadata["exports"] = parse_pe_exports(parsed_obj.get_export())
1131
1145
  metadata["functions"] = parse_functions(parsed_obj.functions)
1132
1146
  metadata["ctor_functions"] = parse_functions(parsed_obj.ctor_functions)
@@ -1180,13 +1194,13 @@ def add_pe_header_data(metadata, parsed_obj):
1180
1194
  metadata["initial_relative_cs"] = dos_header.initial_relative_cs
1181
1195
  metadata["address_relocation_table"] = ADDRESS_FMT.format(
1182
1196
  dos_header.addressof_relocation_table
1183
- )
1197
+ ).strip()
1184
1198
  metadata["overlay_number"] = dos_header.overlay_number
1185
1199
  metadata["oem_id"] = dos_header.oem_id
1186
1200
  metadata["oem_info"] = dos_header.oem_info
1187
1201
  metadata["address_new_exeheader"] = ADDRESS_FMT.format(
1188
1202
  dos_header.addressof_new_exeheader
1189
- )
1203
+ ).strip()
1190
1204
  metadata["characteristics"] = ", ".join(
1191
1205
  [str(chara).rsplit(".", maxsplit=1)[-1] for chara in header.characteristics_list]
1192
1206
  )
@@ -1231,7 +1245,9 @@ def add_pe_optional_headers(metadata, optional_header):
1231
1245
  metadata["sizeof_code"] = optional_header.sizeof_code
1232
1246
  metadata["sizeof_initialized_data"] = optional_header.sizeof_initialized_data
1233
1247
  metadata["sizeof_uninitialized_data"] = optional_header.sizeof_uninitialized_data
1234
- metadata["addressof_entrypoint"] = ADDRESS_FMT.format(optional_header.addressof_entrypoint)
1248
+ metadata["addressof_entrypoint"] = ADDRESS_FMT.format(
1249
+ optional_header.addressof_entrypoint
1250
+ ).strip()
1235
1251
  metadata["baseof_code"] = optional_header.baseof_code
1236
1252
  metadata["baseof_data"] = optional_header.baseof_data
1237
1253
  metadata["imagebase"] = optional_header.imagebase
@@ -1256,13 +1272,14 @@ def add_pe_optional_headers(metadata, optional_header):
1256
1272
  return metadata
1257
1273
 
1258
1274
 
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.
1275
+ def add_rdata_symbols(metadata, rdata_section, text_section, sections):
1276
+ """Adds rdata symbols to the metadata dictionary.
1261
1277
 
1262
1278
  Args:
1263
1279
  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.
1280
+ rdata_section: .rdata section of the binary.
1281
+ text_section: .text section of the binary.
1282
+ sections: All sections for advanced analysis
1266
1283
 
1267
1284
  Returns:
1268
1285
  The updated metadata dictionary.
@@ -1273,32 +1290,50 @@ def add_pe_rdata_symbols(metadata, rdata_section: lief.PE.Section, text_section:
1273
1290
  first_stage_symbols = []
1274
1291
  for pii in PII_WORDS:
1275
1292
  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)):
1293
+ if (rdata_section and rdata_section.search_all(vari)) or (
1294
+ text_section and text_section.search_all(vari)
1295
+ ):
1277
1296
  pii_symbols.append(
1278
- {"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
+ )
1279
1304
  continue
1280
1305
  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)):
1306
+ if (rdata_section and rdata_section.search_all(sw)) or (
1307
+ text_section and text_section.search_all(sw)
1308
+ ):
1282
1309
  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)
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)
1293
1332
  if not metadata["symtab_symbols"]:
1294
1333
  metadata["symtab_symbols"] = []
1295
1334
  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)
1335
+ {"name": s, "type": "FILE", "is_function": False, "is_imported": True}
1336
+ for s in sorted(rdata_symbols)
1302
1337
  ]
1303
1338
  if pii_symbols:
1304
1339
  metadata["pii_symbols"] = pii_symbols
@@ -1307,27 +1342,6 @@ def add_pe_rdata_symbols(metadata, rdata_section: lief.PE.Section, text_section:
1307
1342
  return metadata
1308
1343
 
1309
1344
 
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
-
1331
1345
  def add_mach0_metadata(exe_file, metadata, parsed_obj):
1332
1346
  """Adds MachO metadata to the given metadata dictionary.
1333
1347
 
@@ -1279,7 +1279,8 @@ PII_WORDS = (
1279
1279
  "Gender",
1280
1280
  "Country",
1281
1281
  "Email",
1282
- "State",
1282
+ "Town",
1283
+ "County",
1283
1284
  "PostCode",
1284
1285
  "ZipCode",
1285
1286
  "SSN",
@@ -1292,7 +1293,8 @@ PII_WORDS = (
1292
1293
  "OTP",
1293
1294
  "Calendar",
1294
1295
  "AgentStatus",
1295
- "LastLoginTime"
1296
+ "LastLoginTime",
1297
+ "BankAccount"
1296
1298
  )
1297
1299
 
1298
1300
  # Some symbols to look for in a first-stage payload
@@ -1324,6 +1326,8 @@ FIRST_STAGE_WORDS = (
1324
1326
  "/usr/bin/poweroff",
1325
1327
  "/usr/sbin/halt",
1326
1328
  "/usr/bin/halt",
1329
+ "/proc/self/auxv",
1330
+ "/sys/kernel/mm/",
1327
1331
  "virtualboxemulunit",
1328
1332
  "virtualboximportunit",
1329
1333
  "virtualboxunit",
@@ -54,6 +54,7 @@ rules:
54
54
  - os.CreateTemp
55
55
  - os.NewFile
56
56
  - os.DirFS
57
+ - golang/src/os/file
57
58
  - id: OS_METHODS
58
59
  title: OS functions used
59
60
  summary: Can Execute OS commands
@@ -90,6 +91,10 @@ rules:
90
91
  - os/executable.go
91
92
  - os/executable_windows.go
92
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/
93
98
  - id: SYSCALL_METHODS
94
99
  title: Syscall functions used
95
100
  summary: Can perform system-level operations
@@ -154,6 +159,7 @@ rules:
154
159
  - syscall/syscall.go
155
160
  - syscall/syscall_windows.go
156
161
  - syscall/zsyscall_windows.go
162
+ - runtime/mem.go
157
163
  - id: WIN_SIGNAL_METHODS
158
164
  title: Windows Signal functions used
159
165
  summary: Can disable Windows Error Reporting
@@ -166,6 +172,15 @@ rules:
166
172
  - runtime/sys_windows_amd64.s
167
173
  - runtime/sys_x86.go
168
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
169
184
  - id: NET_METHODS
170
185
  title: Net functions used
171
186
  summary: Uses Network to send and receive data
@@ -231,6 +246,7 @@ rules:
231
246
  - net/net.go
232
247
  - net/netip/leaf_alts.go
233
248
  - net/netip/netip.go
249
+ - golang/src/net/
234
250
  - id: HTTP_METHODS
235
251
  title: HTTP server functions used
236
252
  summary: Can run an HTTP server
@@ -267,13 +283,15 @@ rules:
267
283
  - github.com/gorilla/websocket
268
284
  - github.com/gorilla/mux
269
285
  - id: MEM_METHODS
270
- title: HTTP server functions used
271
- summary: Can run an HTTP server
286
+ title: Memory module used
287
+ summary: Manipulates System Memory
272
288
  description: |
273
- Package http provides HTTP client and server implementations.
289
+ Memory module used.
274
290
  patterns:
275
- - http.ListenAndServe
276
-
291
+ - runtime/mem.go
292
+ - runtime/mem_linux.go
293
+ - runtime/memclr_amd64.s
294
+ - runtime/mcheckmark.go
277
295
  - id: HTTP_CLIENT_METHODS
278
296
  title: HTTP client functions used
279
297
  summary: Invokes HTTP service
@@ -361,6 +379,7 @@ rules:
361
379
  - zip.CreateRaw
362
380
  - archive/tar
363
381
  - github.com/ulikunitz/xz
382
+ - golang/src/compress
364
383
  - id: GIT_METHODS
365
384
  title: Git library used
366
385
  summary: Can perform Git Read and Write operations
@@ -402,6 +421,8 @@ rules:
402
421
  - crypto/crypto.go
403
422
  - crypto/subtle/xor.go
404
423
  - crypto/subtle/xor_amd64.s
424
+ - golang.org/x/crypto
425
+ - golang/src/crypto
405
426
  - id: SSH_METHODS
406
427
  title: ssh library used
407
428
  summary: Can perform SSH operations
@@ -513,3 +534,24 @@ rules:
513
534
  - x509.internal.macos.SecPolicyCopyProperties
514
535
  - x509.internal.macos.SecTrustSettingsCopyCertificates
515
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
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "blint"
3
- version = "2.2.1"
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
File without changes
File without changes
File without changes