Skip to content

Instantly share code, notes, and snippets.

@Wowfunhappy
Created April 21, 2022 18:02
Show Gist options
  • Save Wowfunhappy/e1ecb2158cbdd52efee66a733b82d6f1 to your computer and use it in GitHub Desktop.
Save Wowfunhappy/e1ecb2158cbdd52efee66a733b82d6f1 to your computer and use it in GitHub Desktop.
Why deal with use-after-free crashes when you can just leak memory instead?
//COMPILE: clang -framework Foundation noCFRelease.m -undefined dynamic_lookup -dynamiclib -o noCFRelease.dylib
//USE: DYLD_INSERT_LIBRARIES=/path/to/noCFRelease.dylib /path/to/foo.app/Contents/MacOS/foo
#include <CoreFoundation/CoreFoundation.h>
#define DYLD_INTERPOSE(_replacement,_replacee) \
__attribute__((used)) static struct{ const void* replacement; const void* replacee; } _interpose_##_replacee \
__attribute__ ((section ("__DATA,__interpose"))) = { (const void*)(unsigned long)&_replacement, (const void*)(unsigned long)&_replacee };
void noCFRelease (CFTypeRef cf) {
//😴
}
DYLD_INTERPOSE(noCFRelease, CFRelease);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment