Skip to content

Instantly share code, notes, and snippets.

@lazymutt
Created April 3, 2018 21:48
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lazymutt/d6b145f14437e9eae1e7174058618b1f to your computer and use it in GitHub Desktop.
Save lazymutt/d6b145f14437e9eae1e7174058618b1f to your computer and use it in GitHub Desktop.
Modification of https://gist.github.com/bruienne/5f84cfa559ca957dc2943c33a3098149, address struct exceptions
#!/usr/bin/python
from __future__ import print_function
import os
import sys
import struct
import macholib
from macholib import MachO
input_path = sys.argv[1]
for root, dirs, files in os.walk(input_path):
for item in files:
abs_path = os.path.join(root, item)
if os.access(abs_path, os.X_OK):
try:
macho = MachO.MachO(abs_path)
except (ValueError, KeyError):
break
except struct.error:
print(" struct error handling: %s" % abs_path)
if len(macho.headers) == 1:
if not isinstance(macho.headers[0].mach_header(), macholib.mach_o.mach_header_64):
print("%s" % abs_path)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment