blint 3.0.0__tar.gz → 3.0.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.
- {blint-3.0.0 → blint-3.0.2}/PKG-INFO +2 -2
- {blint-3.0.0 → blint-3.0.2}/README.md +1 -1
- {blint-3.0.0 → blint-3.0.2}/blint/cli.py +3 -1
- {blint-3.0.0 → blint-3.0.2}/blint/config.py +71 -2
- {blint-3.0.0 → blint-3.0.2}/blint/lib/binary.py +65 -49
- {blint-3.0.0 → blint-3.0.2}/blint/lib/disassembler.py +366 -170
- {blint-3.0.0 → blint-3.0.2}/blint/lib/utils.py +4 -0
- {blint-3.0.0 → blint-3.0.2}/pyproject.toml +1 -1
- {blint-3.0.0 → blint-3.0.2}/LICENSE +0 -0
- {blint-3.0.0 → blint-3.0.2}/blint/__init__.py +0 -0
- {blint-3.0.0 → blint-3.0.2}/blint/cyclonedx/README.md +0 -0
- {blint-3.0.0 → blint-3.0.2}/blint/cyclonedx/__init__.py +0 -0
- {blint-3.0.0 → blint-3.0.2}/blint/cyclonedx/spdx.py +0 -0
- {blint-3.0.0 → blint-3.0.2}/blint/cyclonedx/spec.py +0 -0
- {blint-3.0.0 → blint-3.0.2}/blint/data/__init__.py +0 -0
- {blint-3.0.0 → blint-3.0.2}/blint/data/annotations/__init__.py +0 -0
- {blint-3.0.0 → blint-3.0.2}/blint/data/annotations/review_entries_generic.yml +0 -0
- {blint-3.0.0 → blint-3.0.2}/blint/data/annotations/review_entries_pe.yml +0 -0
- {blint-3.0.0 → blint-3.0.2}/blint/data/annotations/review_exe_go.yml +0 -0
- {blint-3.0.0 → blint-3.0.2}/blint/data/annotations/review_functions_generic.yml +0 -0
- {blint-3.0.0 → blint-3.0.2}/blint/data/annotations/review_imports_pe.yml +0 -0
- {blint-3.0.0 → blint-3.0.2}/blint/data/annotations/review_methods_generic.yml +0 -0
- {blint-3.0.0 → blint-3.0.2}/blint/data/annotations/review_methods_mips.yml +0 -0
- {blint-3.0.0 → blint-3.0.2}/blint/data/annotations/review_monero_generic.yml +0 -0
- {blint-3.0.0 → blint-3.0.2}/blint/data/annotations/review_monero_go.yml +0 -0
- {blint-3.0.0 → blint-3.0.2}/blint/data/annotations/review_monero_rust.yml +0 -0
- {blint-3.0.0 → blint-3.0.2}/blint/data/annotations/review_rootkits_win.yml +0 -0
- {blint-3.0.0 → blint-3.0.2}/blint/data/annotations/review_symbols_antiforensic.yml +0 -0
- {blint-3.0.0 → blint-3.0.2}/blint/data/annotations/review_symbols_generic.yml +0 -0
- {blint-3.0.0 → blint-3.0.2}/blint/data/annotations/review_symbols_hooka.yml +0 -0
- {blint-3.0.0 → blint-3.0.2}/blint/data/annotations/review_symbols_macho.yml +0 -0
- {blint-3.0.0 → blint-3.0.2}/blint/data/annotations/review_symbols_rust.yml +0 -0
- {blint-3.0.0 → blint-3.0.2}/blint/data/rules.yml +0 -0
- {blint-3.0.0 → blint-3.0.2}/blint/db.py +0 -0
- {blint-3.0.0 → blint-3.0.2}/blint/lib/__init__.py +0 -0
- {blint-3.0.0 → blint-3.0.2}/blint/lib/analysis.py +0 -0
- {blint-3.0.0 → blint-3.0.2}/blint/lib/android.py +0 -0
- {blint-3.0.0 → blint-3.0.2}/blint/lib/checks.py +0 -0
- {blint-3.0.0 → blint-3.0.2}/blint/lib/runners.py +0 -0
- {blint-3.0.0 → blint-3.0.2}/blint/lib/sbom.py +0 -0
- {blint-3.0.0 → blint-3.0.2}/blint/logger.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: blint
|
|
3
|
-
Version: 3.0.
|
|
3
|
+
Version: 3.0.2
|
|
4
4
|
Summary: Linter and SBOM generator for binary files.
|
|
5
5
|
License-Expression: MIT
|
|
6
6
|
License-File: LICENSE
|
|
@@ -43,7 +43,7 @@ Description-Content-Type: text/markdown
|
|
|
43
43
|
|
|
44
44
|
# BLint
|
|
45
45
|
|
|
46
|
-
<img src="./blint.png" width="
|
|
46
|
+
<img src="./blint.png" width="200" height="auto" />
|
|
47
47
|
|
|
48
48
|
BLint is a Binary Linter that checks the security properties and capabilities of your executables. It is powered by [lief](https://github.com/lief-project/LIEF). Since version 2, blint can also generate Software Bill-of-Materials (SBOM) for supported binaries.
|
|
49
49
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# BLint
|
|
2
2
|
|
|
3
|
-
<img src="./blint.png" width="
|
|
3
|
+
<img src="./blint.png" width="200" height="auto" />
|
|
4
4
|
|
|
5
5
|
BLint is a Binary Linter that checks the security properties and capabilities of your executables. It is powered by [lief](https://github.com/lief-project/LIEF). Since version 2, blint can also generate Software Bill-of-Materials (SBOM) for supported binaries.
|
|
6
6
|
|
|
@@ -130,7 +130,7 @@ def build_parser():
|
|
|
130
130
|
"--src",
|
|
131
131
|
dest="src_dir_image",
|
|
132
132
|
action="extend",
|
|
133
|
-
default=[
|
|
133
|
+
default=[],
|
|
134
134
|
nargs="+",
|
|
135
135
|
help="Source directories, container images or binary files. Defaults to current directory.",
|
|
136
136
|
)
|
|
@@ -238,6 +238,8 @@ def handle_args():
|
|
|
238
238
|
args = build_args()
|
|
239
239
|
if not args.no_banner and args.subcommand_name != "sbom":
|
|
240
240
|
print(BLINT_LOGO)
|
|
241
|
+
if not args.src_dir_image:
|
|
242
|
+
args.src_dir_image = [os.getcwd()]
|
|
241
243
|
blint_options = BlintOptions(
|
|
242
244
|
deep_mode=args.deep_mode,
|
|
243
245
|
exports_prefix=args.exports_prefix,
|
|
@@ -1402,14 +1402,14 @@ CRYPTO_INDICATORS = [
|
|
|
1402
1402
|
'movdqa', 'movdqu', 'vmovdqa', 'vmovdqu',
|
|
1403
1403
|
'padd', 'psub', 'pmul',
|
|
1404
1404
|
'psll', 'psrl', 'psra',
|
|
1405
|
-
'vpaddd', 'vpsubd', 'vpmulld',
|
|
1405
|
+
'vpaddd', 'vpsubd', 'vpmulld', 'pmaddwd'
|
|
1406
1406
|
]
|
|
1407
1407
|
GPU_INDICATORS = [
|
|
1408
1408
|
'glbind', 'glvertex', 'glcolor', 'glbegin', 'glend', 'glenable', 'gldisable', 'glget', 'glset', 'glload', 'glsave', 'gluniform', 'gluseprogram', 'glattachshader', 'gldraw', 'glclear', 'glviewport', 'glmatrix', 'glpushmatrix', 'glpopmatrix',
|
|
1409
1409
|
'cuda', 'cuinit', 'cucontext', 'cudriver', 'cugpu', 'cudevice', 'cumem', 'cuptr', 'cukernel', 'culaunch', 'cugrid', 'cublock', 'cuthread', 'cufree', 'cucopy',
|
|
1410
1410
|
'clgetplatform', 'clgetdevice', 'clcreatecontext', 'clcreatecommandqueue', 'clcreateshared', 'clcreatekernel', 'clsetkernelarg', 'clenqueuendrange', 'clfinish', 'clrelease', 'clbuildprogram',
|
|
1411
1411
|
'd3d', 'd3d11', 'd3d12', 'create', 'device', 'swapchain', 'rendertarget', 'shaders', 'ps_', 'vs_', 'gs_', 'cs_', 'hs_', 'ds_',
|
|
1412
|
-
'
|
|
1412
|
+
'vkcreate', 'vkdestroy', 'vkallocate', 'vkfree', 'vkqueue', 'vksubmit', 'vkwait', 'vkacquire', 'vkpresent', 'vkcmd', 'vkbegin', 'vkend', 'vkbind', 'vkdraw', 'vkdispatch', 'vkcopy', 'vkblit', 'vkclear', 'vkfill', 'vkupdate',
|
|
1413
1413
|
'mtl', 'metal', 'mtldevice', 'mtlcommand', 'mtlrender', 'mtlcompute', 'mtlbuffer', 'mtltexture', 'mtlfunction', 'mtllibrary', 'mtlencoder', 'mtlpass',
|
|
1414
1414
|
'gpu', 'compute', 'shader', 'vertex', 'fragment', 'pixel', 'kernel', 'workgroup', 'local', 'global', 'buffer', 'texture', 'surface',
|
|
1415
1415
|
]
|
|
@@ -1476,3 +1476,72 @@ IMPLICIT_REGS_X64 = {
|
|
|
1476
1476
|
'cpuid': {'read': {'eax', 'ecx'}, 'write': {'eax', 'ebx', 'ecx', 'edx'}},
|
|
1477
1477
|
'syscall':{'read': {'rcx', 'r11'}, 'write': {'rcx', 'r11'}},
|
|
1478
1478
|
}
|
|
1479
|
+
|
|
1480
|
+
IMPLICIT_REGS_ARM64 = {
|
|
1481
|
+
'bl': {'write': {'x30'}},
|
|
1482
|
+
'blr': {'write': {'x30'}},
|
|
1483
|
+
'ret': {'read': {'x30'}},
|
|
1484
|
+
'mrs': {'write': {'x0'}},
|
|
1485
|
+
'msr': {'read': {'x0'}},
|
|
1486
|
+
'svc': {'read': {'x0', 'x1', 'x2', 'x3', 'x4', 'x5', 'x8'}, 'write': {'x0'}},
|
|
1487
|
+
'hvc': {'read': {'x0', 'x1', 'x2', 'x3', 'x4', 'x5', 'x8'}, 'write': {'x0'}},
|
|
1488
|
+
'smc': {'read': {'x0', 'x1', 'x2', 'x3', 'x4', 'x5', 'x8'}, 'write': {'x0'}},
|
|
1489
|
+
'brk': {'read': {'x0'}},
|
|
1490
|
+
}
|
|
1491
|
+
|
|
1492
|
+
# https://github.com/AsahiLinux/docs/blob/main/docs/hw/cpu/apple-instructions.md
|
|
1493
|
+
APPLE_PROPRIETARY_INSTRUCTION_RANGES = {
|
|
1494
|
+
"AMX": (0x00201000, 0x002012df),
|
|
1495
|
+
"WKDM": (0x00200800, 0x00200cff),
|
|
1496
|
+
"GuardedMode": (0x00201400, 0x00201420),
|
|
1497
|
+
"AddressTranslation": (0x00201440, 0x00201440),
|
|
1498
|
+
"SyncBarrier": (0x00201460, 0x00201463),
|
|
1499
|
+
}
|
|
1500
|
+
|
|
1501
|
+
APPLE_PROPRIETARY_SREGS = {
|
|
1502
|
+
"GXF_CONTROL": {
|
|
1503
|
+
"S3_6_C15_C1_2",
|
|
1504
|
+
"S3_6_C15_C8_1",
|
|
1505
|
+
},
|
|
1506
|
+
"SPRR_CONTROL": {
|
|
1507
|
+
"S3_6_C15_C1_0",
|
|
1508
|
+
"S3_6_C15_C1_5",
|
|
1509
|
+
"S3_6_C15_C1_6",
|
|
1510
|
+
},
|
|
1511
|
+
"PAC_KEYS": {
|
|
1512
|
+
"S3_4_C15_C1_0",
|
|
1513
|
+
"S3_4_C15_C1_1",
|
|
1514
|
+
},
|
|
1515
|
+
"JIT_HARDENING": {
|
|
1516
|
+
"S3_4_C15_C2_6",
|
|
1517
|
+
"S3_4_C15_C2_7",
|
|
1518
|
+
},
|
|
1519
|
+
"PERF_COUNTERS": {
|
|
1520
|
+
"S3_1_C15_C0_0",
|
|
1521
|
+
"S3_1_C15_C1_0",
|
|
1522
|
+
"S3_1_C15_C2_0",
|
|
1523
|
+
"S3_1_C15_C3_0",
|
|
1524
|
+
"S3_1_C15_C4_0",
|
|
1525
|
+
"S3_1_C15_C5_0",
|
|
1526
|
+
"S3_1_C15_C6_0",
|
|
1527
|
+
"S3_1_C15_C13_0",
|
|
1528
|
+
"S3_2_C15_C0_0",
|
|
1529
|
+
"S3_2_C15_C1_0",
|
|
1530
|
+
"S3_2_C15_C2_0",
|
|
1531
|
+
"S3_2_C15_C3_0",
|
|
1532
|
+
"S3_2_C15_C4_0",
|
|
1533
|
+
"S3_2_C15_C5_0",
|
|
1534
|
+
"S3_2_C15_C6_0",
|
|
1535
|
+
"S3_2_C15_C7_0",
|
|
1536
|
+
"S3_2_C15_C9_0",
|
|
1537
|
+
"S3_2_C15_C10_0",
|
|
1538
|
+
},
|
|
1539
|
+
"IPI_CONTROL": {
|
|
1540
|
+
"S3_5_C15_C1_1",
|
|
1541
|
+
"S3_5_C15_C3_1",
|
|
1542
|
+
},
|
|
1543
|
+
"VIRTUALIZATION": {
|
|
1544
|
+
"S3_5_C15_C1_2",
|
|
1545
|
+
"S3_5_C15_C1_3",
|
|
1546
|
+
},
|
|
1547
|
+
}
|
|
@@ -19,6 +19,7 @@ from blint.lib.utils import (
|
|
|
19
19
|
cleanup_dict_lief_errors,
|
|
20
20
|
decode_base64,
|
|
21
21
|
demangle_symbolic_name,
|
|
22
|
+
enum_to_str,
|
|
22
23
|
)
|
|
23
24
|
from blint.lib.disassembler import disassemble_functions
|
|
24
25
|
|
|
@@ -98,7 +99,7 @@ def extract_note_data(idx, note):
|
|
|
98
99
|
if note.type == lief.ELF.Note.TYPE.GNU_BUILD_ID:
|
|
99
100
|
build_id = description_str.replace(" ", "")
|
|
100
101
|
type_str = note.type
|
|
101
|
-
type_str =
|
|
102
|
+
type_str = enum_to_str(type_str)
|
|
102
103
|
note_details = ""
|
|
103
104
|
sdk_version = ""
|
|
104
105
|
ndk_version = ""
|
|
@@ -183,7 +184,7 @@ def parse_functions(functions):
|
|
|
183
184
|
func_list = []
|
|
184
185
|
with contextlib.suppress(AttributeError, TypeError):
|
|
185
186
|
for idx, f in enumerate(functions):
|
|
186
|
-
if f.name
|
|
187
|
+
if f.name or f.address:
|
|
187
188
|
cleaned_name = demangle_symbolic_name(f.name)
|
|
188
189
|
func_list.append(
|
|
189
190
|
{
|
|
@@ -258,10 +259,10 @@ def parse_symbols(symbols):
|
|
|
258
259
|
symbols_list.append(
|
|
259
260
|
{
|
|
260
261
|
"name": symbol_name,
|
|
261
|
-
"type":
|
|
262
|
+
"type": enum_to_str(symbol.type),
|
|
262
263
|
"value": symbol.value,
|
|
263
|
-
"visibility":
|
|
264
|
-
"binding":
|
|
264
|
+
"visibility": enum_to_str(symbol.visibility),
|
|
265
|
+
"binding": enum_to_str(symbol.binding),
|
|
265
266
|
"is_imported": is_imported,
|
|
266
267
|
"is_exported": is_exported,
|
|
267
268
|
"information": symbol.information,
|
|
@@ -342,13 +343,13 @@ def parse_pe_data(parsed_obj):
|
|
|
342
343
|
section_name = ""
|
|
343
344
|
section_chars = ""
|
|
344
345
|
section_entropy = ""
|
|
345
|
-
dir_type =
|
|
346
|
+
dir_type = enum_to_str(directory.type)
|
|
346
347
|
if not dir_type.startswith("?") and directory.size:
|
|
347
348
|
if directory.has_section:
|
|
348
349
|
if directory.section.has_characteristic:
|
|
349
350
|
section_chars = ", ".join(
|
|
350
351
|
[
|
|
351
|
-
|
|
352
|
+
enum_to_str(chara)
|
|
352
353
|
for chara in directory.section.characteristics_lists
|
|
353
354
|
]
|
|
354
355
|
)
|
|
@@ -433,10 +434,10 @@ def process_pe_signature(parsed_obj):
|
|
|
433
434
|
ci = sig.content_info
|
|
434
435
|
signature_obj = {
|
|
435
436
|
"version": sig.version,
|
|
436
|
-
"digest_algorithm":
|
|
437
|
+
"digest_algorithm": enum_to_str(sig.digest_algorithm),
|
|
437
438
|
"content_info": {
|
|
438
439
|
"content_type": lief.PE.oid_to_string(ci.content_type),
|
|
439
|
-
"digest_algorithm":
|
|
440
|
+
"digest_algorithm": enum_to_str(ci.digest_algorithm),
|
|
440
441
|
"digest": ci.digest.hex(),
|
|
441
442
|
},
|
|
442
443
|
}
|
|
@@ -446,7 +447,7 @@ def process_pe_signature(parsed_obj):
|
|
|
446
447
|
"version": signer.version,
|
|
447
448
|
"serial_number": signer.serial_number.hex(),
|
|
448
449
|
"issuer": str(signer.issuer),
|
|
449
|
-
"digest_algorithm":
|
|
450
|
+
"digest_algorithm": enum_to_str(signer.digest_algorithm),
|
|
450
451
|
"encryption_algorithm": str(signer.encryption_algorithm).rsplit(
|
|
451
452
|
".", maxsplit=1
|
|
452
453
|
)[-1],
|
|
@@ -475,7 +476,7 @@ def parse_pe_authenticode(parsed_obj):
|
|
|
475
476
|
"sha256_hash": parsed_obj.authentihash_sha256.hex(*sep),
|
|
476
477
|
"sha512_hash": parsed_obj.authentihash_sha512.hex(*sep),
|
|
477
478
|
"sha1_hash": parsed_obj.authentihash(lief.PE.ALGORITHMS.SHA_1).hex(*sep),
|
|
478
|
-
"verification_flags":
|
|
479
|
+
"verification_flags": enum_to_str(parsed_obj.verify_signature()),
|
|
479
480
|
}
|
|
480
481
|
if signatures := parsed_obj.signatures:
|
|
481
482
|
if not isinstance(signatures, lief.lief_errors) and signatures[0].signers:
|
|
@@ -535,9 +536,9 @@ def parse_pe_symbols(symbols):
|
|
|
535
536
|
"name": demangle_symbolic_name(symbol.name),
|
|
536
537
|
"value": symbol.value,
|
|
537
538
|
"id": section_nb_str,
|
|
538
|
-
"base_type":
|
|
539
|
-
"complex_type":
|
|
540
|
-
"storage_class":
|
|
539
|
+
"base_type": enum_to_str(symbol.base_type),
|
|
540
|
+
"complex_type": enum_to_str(symbol.complex_type),
|
|
541
|
+
"storage_class": enum_to_str(symbol.storage_class),
|
|
541
542
|
}
|
|
542
543
|
)
|
|
543
544
|
except (IndexError, AttributeError, ValueError, RuntimeError):
|
|
@@ -576,7 +577,7 @@ def parse_pe_imports(imports):
|
|
|
576
577
|
{
|
|
577
578
|
"name": f"{import_.name}::{demangle_symbolic_name(entry.name)}",
|
|
578
579
|
"short_name": demangle_symbolic_name(entry.name),
|
|
579
|
-
"
|
|
580
|
+
"address": ADDRESS_FMT.format(entry.data).strip(),
|
|
580
581
|
"iat_value": entry.iat_value,
|
|
581
582
|
"hint": entry.hint,
|
|
582
583
|
}
|
|
@@ -610,7 +611,7 @@ def parse_pe_exports(exports):
|
|
|
610
611
|
metadata = {
|
|
611
612
|
"name": demangle_symbolic_name(entry.name),
|
|
612
613
|
"ordinal": entry.ordinal,
|
|
613
|
-
"address": ADDRESS_FMT.format(entry.address),
|
|
614
|
+
"address": ADDRESS_FMT.format(entry.address).strip(),
|
|
614
615
|
"extern": extern,
|
|
615
616
|
}
|
|
616
617
|
fwd = entry.forward_information if entry.is_forwarded else None
|
|
@@ -644,11 +645,8 @@ def parse_macho_symbols(symbols):
|
|
|
644
645
|
libname = ""
|
|
645
646
|
if symbol.has_binding_info and symbol.binding_info.has_library:
|
|
646
647
|
libname = symbol.binding_info.library.name
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
if symbol.value > 0 or not symbol.has_binding_info
|
|
650
|
-
else ADDRESS_FMT.format(symbol.binding_info.address)
|
|
651
|
-
)
|
|
648
|
+
address = symbol.value if symbol.value > 0 or not symbol.has_binding_info else symbol.binding_info.address
|
|
649
|
+
symbol_value = ADDRESS_FMT.format(address).strip()
|
|
652
650
|
symbol_name = symbol.demangled_name
|
|
653
651
|
if not symbol_name or isinstance(symbol_name, lief.lief_errors):
|
|
654
652
|
symbol_name = demangle_symbolic_name(symbol.name)
|
|
@@ -661,10 +659,18 @@ def parse_macho_symbols(symbols):
|
|
|
661
659
|
{
|
|
662
660
|
"name": (f"{libname}::{symbol_name}" if libname else symbol_name),
|
|
663
661
|
"short_name": symbol_name,
|
|
662
|
+
"category": symbol.category,
|
|
664
663
|
"type": symbol.type,
|
|
665
664
|
"num_sections": symbol.numberof_sections,
|
|
666
665
|
"description": symbol.description,
|
|
667
|
-
"
|
|
666
|
+
"address": symbol_value,
|
|
667
|
+
"export_info": {
|
|
668
|
+
"symbol": symbol.export_info.symbol, "kind": symbol.export_info.kind,
|
|
669
|
+
"flags": str(symbol.export_info.flags),
|
|
670
|
+
"offset": ADDRESS_FMT.format(symbol.export_info.offset),
|
|
671
|
+
"address": ADDRESS_FMT.format(symbol.export_info.address)
|
|
672
|
+
} if symbol.has_export_info else None,
|
|
673
|
+
"origin": symbol.origin,
|
|
668
674
|
}
|
|
669
675
|
)
|
|
670
676
|
except (AttributeError, TypeError):
|
|
@@ -785,16 +791,14 @@ def add_elf_header(header, metadata):
|
|
|
785
791
|
return metadata
|
|
786
792
|
try:
|
|
787
793
|
eflags_str = determine_elf_flags(header)
|
|
788
|
-
metadata["class"] =
|
|
789
|
-
metadata["endianness"] =
|
|
790
|
-
metadata["identity_version"] =
|
|
791
|
-
metadata["identity_os_abi"] =
|
|
792
|
-
metadata["identity_abi_version"] = header.identity_abi_version
|
|
793
|
-
metadata["file_type"] =
|
|
794
|
-
metadata["machine_type"] =
|
|
795
|
-
metadata["object_file_version"] =
|
|
796
|
-
-1
|
|
797
|
-
]
|
|
794
|
+
metadata["class"] = enum_to_str(header.identity_class)
|
|
795
|
+
metadata["endianness"] = enum_to_str(header.identity_data)
|
|
796
|
+
metadata["identity_version"] = enum_to_str(header.identity_version)
|
|
797
|
+
metadata["identity_os_abi"] = enum_to_str(header.identity_os_abi)
|
|
798
|
+
metadata["identity_abi_version"] = enum_to_str(header.identity_abi_version)
|
|
799
|
+
metadata["file_type"] = enum_to_str(header.file_type)
|
|
800
|
+
metadata["machine_type"] = enum_to_str(header.machine_type)
|
|
801
|
+
metadata["object_file_version"] = enum_to_str(header.object_file_version)
|
|
798
802
|
metadata["entrypoint"] = header.entrypoint
|
|
799
803
|
metadata["processor_flag"] = str(header.processor_flag) + eflags_str
|
|
800
804
|
except (AttributeError, TypeError, ValueError) as e:
|
|
@@ -859,7 +863,7 @@ def add_elf_dynamic_entries(dynamic_entries, metadata):
|
|
|
859
863
|
metadata["dynamic_entries"].append(
|
|
860
864
|
{
|
|
861
865
|
"name": demangle_symbolic_name(entry.name),
|
|
862
|
-
"tag":
|
|
866
|
+
"tag": enum_to_str(entry.tag),
|
|
863
867
|
"value": entry.value,
|
|
864
868
|
}
|
|
865
869
|
)
|
|
@@ -871,7 +875,7 @@ def add_elf_dynamic_entries(dynamic_entries, metadata):
|
|
|
871
875
|
metadata["dynamic_entries"].append(
|
|
872
876
|
{
|
|
873
877
|
"name": "runpath",
|
|
874
|
-
"tag":
|
|
878
|
+
"tag": enum_to_str(entry.tag),
|
|
875
879
|
"value": entry.runpath,
|
|
876
880
|
}
|
|
877
881
|
)
|
|
@@ -881,7 +885,7 @@ def add_elf_dynamic_entries(dynamic_entries, metadata):
|
|
|
881
885
|
metadata["dynamic_entries"].append(
|
|
882
886
|
{
|
|
883
887
|
"name": "rpath",
|
|
884
|
-
"tag":
|
|
888
|
+
"tag": enum_to_str(entry.tag),
|
|
885
889
|
"value": entry.rpath,
|
|
886
890
|
}
|
|
887
891
|
)
|
|
@@ -899,7 +903,7 @@ def determine_elf_flags(header):
|
|
|
899
903
|
eflags_str = ""
|
|
900
904
|
if header.machine_type == lief.ELF.ARCH.ARM and hasattr(header, "arm_flags_list"):
|
|
901
905
|
eflags_str = " - ".join(
|
|
902
|
-
[
|
|
906
|
+
[enum_to_str(s) for s in header.arm_flags_list]
|
|
903
907
|
)
|
|
904
908
|
if header.machine_type in [
|
|
905
909
|
lief.ELF.ARCH.MIPS,
|
|
@@ -907,15 +911,15 @@ def determine_elf_flags(header):
|
|
|
907
911
|
lief.ELF.ARCH.MIPS_X,
|
|
908
912
|
]:
|
|
909
913
|
eflags_str = " - ".join(
|
|
910
|
-
[
|
|
914
|
+
[enum_to_str(s) for s in header.mips_flags_list]
|
|
911
915
|
)
|
|
912
916
|
if header.machine_type == lief.ELF.ARCH.PPC64:
|
|
913
917
|
eflags_str = " - ".join(
|
|
914
|
-
[
|
|
918
|
+
[enum_to_str(s) for s in header.ppc64_flags_list]
|
|
915
919
|
)
|
|
916
920
|
if header.machine_type == lief.ELF.ARCH.HEXAGON:
|
|
917
921
|
eflags_str = " - ".join(
|
|
918
|
-
[
|
|
922
|
+
[enum_to_str(s) for s in header.hexagon_flags_list]
|
|
919
923
|
)
|
|
920
924
|
return eflags_str
|
|
921
925
|
|
|
@@ -1255,7 +1259,7 @@ def add_pe_metadata(exe_file: str, metadata: dict, parsed_obj: lief.PE.Binary):
|
|
|
1255
1259
|
metadata["rust_dependencies"] = parse_rust_buildinfo(parsed_obj)
|
|
1256
1260
|
tls = parsed_obj.tls
|
|
1257
1261
|
if tls and tls.sizeof_zero_fill:
|
|
1258
|
-
metadata["tls_address_index"] = tls.addressof_index
|
|
1262
|
+
metadata["tls_address_index"] = ADDRESS_FMT.format(tls.addressof_index).strip()
|
|
1259
1263
|
metadata["tls_sizeof_zero_fill"] = tls.sizeof_zero_fill
|
|
1260
1264
|
metadata["tls_data_template_len"] = len(tls.data_template)
|
|
1261
1265
|
metadata["tls_characteristics"] = tls.characteristics
|
|
@@ -1303,7 +1307,7 @@ def add_pe_header_data(metadata, parsed_obj):
|
|
|
1303
1307
|
dos_header.addressof_new_exeheader
|
|
1304
1308
|
).strip()
|
|
1305
1309
|
metadata["characteristics"] = ", ".join(
|
|
1306
|
-
[
|
|
1310
|
+
[enum_to_str(chara) for chara in header.characteristics_list]
|
|
1307
1311
|
)
|
|
1308
1312
|
metadata["num_sections"] = header.numberof_sections
|
|
1309
1313
|
metadata["time_date_stamps"] = header.time_date_stamps
|
|
@@ -1331,14 +1335,14 @@ def add_pe_optional_headers(metadata, optional_header):
|
|
|
1331
1335
|
with contextlib.suppress(IndexError, TypeError):
|
|
1332
1336
|
metadata["dll_characteristics"] = ", ".join(
|
|
1333
1337
|
[
|
|
1334
|
-
|
|
1338
|
+
enum_to_str(chara)
|
|
1335
1339
|
for chara in optional_header.dll_characteristics_lists
|
|
1336
1340
|
]
|
|
1337
1341
|
)
|
|
1338
1342
|
# Detect if this binary is a driver
|
|
1339
1343
|
if "WDM_DRIVER" in metadata["dll_characteristics"]:
|
|
1340
1344
|
metadata["is_driver"] = True
|
|
1341
|
-
metadata["subsystem"] =
|
|
1345
|
+
metadata["subsystem"] = enum_to_str(optional_header.subsystem)
|
|
1342
1346
|
metadata["is_gui"] = metadata["subsystem"] == "WINDOWS_GUI"
|
|
1343
1347
|
metadata["exe_type"] = "PE32" if optional_header.magic == lief.PE.PE_TYPE.PE32 else "PE64"
|
|
1344
1348
|
metadata["major_linker_version"] = optional_header.major_linker_version
|
|
@@ -1552,13 +1556,13 @@ def add_mach0_build_metadata(exe_file, metadata, parsed_obj):
|
|
|
1552
1556
|
build_version = parsed_obj.build_version
|
|
1553
1557
|
if not build_version:
|
|
1554
1558
|
return metadata
|
|
1555
|
-
metadata["platform"] =
|
|
1559
|
+
metadata["platform"] = enum_to_str(build_version.platform)
|
|
1556
1560
|
metadata["minos"] = "{:d}.{:d}.{:d}".format(*build_version.minos)
|
|
1557
1561
|
metadata["sdk"] = "{:d}.{:d}.{:d}".format(*build_version.sdk)
|
|
1558
1562
|
if tools := build_version.tools:
|
|
1559
1563
|
metadata["tools"] = []
|
|
1560
1564
|
for tool in tools:
|
|
1561
|
-
tool_str =
|
|
1565
|
+
tool_str = enum_to_str(tool.tool)
|
|
1562
1566
|
metadata["tools"].append(
|
|
1563
1567
|
{
|
|
1564
1568
|
"tool": tool_str,
|
|
@@ -1614,12 +1618,12 @@ def add_mach0_header_data(exe_file, metadata, parsed_obj):
|
|
|
1614
1618
|
"""
|
|
1615
1619
|
try:
|
|
1616
1620
|
header = parsed_obj.header
|
|
1617
|
-
flags_str = ", ".join([
|
|
1618
|
-
metadata["magic"] =
|
|
1621
|
+
flags_str = ", ".join([enum_to_str(s) for s in header.flags_list])
|
|
1622
|
+
metadata["magic"] = enum_to_str(header.magic)
|
|
1619
1623
|
metadata["is_neural_model"] = header.magic == lief.MachO.MACHO_TYPES.NEURAL_MODEL
|
|
1620
|
-
metadata["cpu_type"] =
|
|
1624
|
+
metadata["cpu_type"] = enum_to_str(header.cpu_type)
|
|
1621
1625
|
metadata["cpu_subtype"] = header.cpu_subtype
|
|
1622
|
-
metadata["file_type"] =
|
|
1626
|
+
metadata["file_type"] = enum_to_str(header.file_type)
|
|
1623
1627
|
metadata["flags"] = flags_str
|
|
1624
1628
|
metadata["number_commands"] = header.nb_cmds
|
|
1625
1629
|
metadata["size_commands"] = header.sizeof_cmds
|
|
@@ -1643,6 +1647,18 @@ def add_mach0_functions(metadata, parsed_obj):
|
|
|
1643
1647
|
metadata["ctor_functions"] = parse_functions(parsed_obj.ctor_functions)
|
|
1644
1648
|
metadata["unwind_functions"] = parse_functions(parsed_obj.unwind_functions)
|
|
1645
1649
|
metadata["symtab_symbols"], exe_type = parse_macho_symbols(parsed_obj.symbols)
|
|
1650
|
+
|
|
1651
|
+
# Populate function info based on local symbols for .o files or others where parsed_obj.functions is empty.
|
|
1652
|
+
if not metadata["functions"]:
|
|
1653
|
+
metadata["functions"] = [
|
|
1654
|
+
{
|
|
1655
|
+
"idx": idx,
|
|
1656
|
+
"name": symbol["name"],
|
|
1657
|
+
"address": symbol["address"]
|
|
1658
|
+
}
|
|
1659
|
+
for idx, symbol in enumerate(s for s in metadata["symtab_symbols"] if s["category"] == lief.MachO.Symbol.CATEGORY.LOCAL)
|
|
1660
|
+
]
|
|
1661
|
+
|
|
1646
1662
|
if exe_type:
|
|
1647
1663
|
metadata["exe_type"] = exe_type
|
|
1648
1664
|
if parsed_obj.dylinker:
|