Created
April 21, 2022 18:02
-
-
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?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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