diff options
author | fanquake <fanquake@gmail.com> | 2020-04-21 09:41:17 +0800 |
---|---|---|
committer | fanquake <fanquake@gmail.com> | 2020-04-21 11:32:01 +0800 |
commit | 7b99c7454cdb74cd9cd7a5eedc2fb9d0a19df456 (patch) | |
tree | 9f7e558a656e9062197190fda308feac3291588f /contrib/devtools/security-check.py | |
parent | c4c3f110eb93243fc8f740070240f50b0008f206 (diff) |
scripts: add MACHO Canary check to security-check.py
Diffstat (limited to 'contrib/devtools/security-check.py')
-rwxr-xr-x | contrib/devtools/security-check.py | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/contrib/devtools/security-check.py b/contrib/devtools/security-check.py index b924698e56..65a80b4102 100755 --- a/contrib/devtools/security-check.py +++ b/contrib/devtools/security-check.py @@ -223,6 +223,20 @@ def check_MACHO_LAZY_BINDINGS(executable) -> bool: return False return True +def check_MACHO_Canary(executable) -> bool: + ''' + Check for use of stack canary + ''' + p = subprocess.Popen([OTOOL_CMD, '-Iv', executable], stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE, universal_newlines=True) + (stdout, stderr) = p.communicate() + if p.returncode: + raise IOError('Error opening file') + ok = False + for line in stdout.splitlines(): + if '___stack_chk_fail' in line: + ok = True + return ok + CHECKS = { 'ELF': [ ('PIE', check_ELF_PIE), @@ -239,7 +253,8 @@ CHECKS = { ('PIE', check_MACHO_PIE), ('NOUNDEFS', check_MACHO_NOUNDEFS), ('NX', check_MACHO_NX), - ('LAZY_BINDINGS', check_MACHO_LAZY_BINDINGS) + ('LAZY_BINDINGS', check_MACHO_LAZY_BINDINGS), + ('Canary', check_MACHO_Canary) ] } |