mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-26 14:00:29 +01:00
contrib: add macho branch protection check
This commit is contained in:
@@ -192,6 +192,16 @@ def check_MACHO_control_flow(binary) -> bool:
|
||||
return True
|
||||
return False
|
||||
|
||||
def check_MACHO_branch_protection(binary) -> bool:
|
||||
'''
|
||||
Check for branch protection instrumentation
|
||||
'''
|
||||
content = binary.get_content_from_virtual_address(binary.entrypoint, 4, lief.Binary.VA_TYPES.AUTO)
|
||||
|
||||
if content.tolist() == [95, 36, 3, 213]: # bti
|
||||
return True
|
||||
return False
|
||||
|
||||
BASE_ELF = [
|
||||
('PIE', check_PIE),
|
||||
('NX', check_NX),
|
||||
@@ -231,7 +241,7 @@ CHECKS = {
|
||||
lief.ARCHITECTURES.X86: BASE_MACHO + [('PIE', check_PIE),
|
||||
('NX', check_NX),
|
||||
('CONTROL_FLOW', check_MACHO_control_flow)],
|
||||
lief.ARCHITECTURES.ARM64: BASE_MACHO,
|
||||
lief.ARCHITECTURES.ARM64: BASE_MACHO + [('BRANCH_PROTECTION', check_MACHO_branch_protection)],
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user