14

How can I remove the code signature from a binary so that I can patch it without the binary refusing to run afterwards?

Needless to say, I'm not the original creator of the binary, nor I have the certs that were used to sign the binary.

1
  • if the app's name I want to remove the code signature is a two words with space between them, how should I type it? Thanks in advance
    – user34480
    Commented Sep 24, 2020 at 2:29

3 Answers 3

18

There are tools for that, as well as a codesign flag --remove-signature

First two should work the same. The codesign flag is undocumented and so YMMV (A user reported in a comment the codesign produced a corrupt executable).

You should use any of them with caution and backup the application before using them.

4
  • Would you recommend me using one of those 3 tools in particular or any of those would work exactly the same for me and my use case? Commented Sep 30, 2016 at 12:13
  • Added the question to address your questions here
    – NirIzr
    Commented Sep 30, 2016 at 12:24
  • 3
    codesign --remove-signature seems to create malformed executables, at least in some cases.
    – zneak
    Commented Sep 6, 2017 at 16:20
  • 1
    @zneak thanks for sharing your experience. Edited my answer to note that.
    – NirIzr
    Commented Sep 6, 2017 at 16:27
2

Another blunt way that seemed to work for me on Catalina (note that this strips all attributes):

xattr -cr /path/to/your/program.app

-1
codesign --remove-signature /path/to/binaryAppName

Tested it on macOS 10.15.3 Catalina, works perfectly.

You can edit the hex values of the now removed code signature binaries and it will launch on macOS with out a hitch.

1
  • This answer doesn't offer any new information. The accepted answer (from 2016) already discusses the codesign --remove-signature approach
    – julian
    Commented Mar 19, 2020 at 15:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.