-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mach_inject crashes target in OSX 10.12 (Sierra), unless if launched through Xcode #3
Comments
i've never tried running it on sierra. you may want to check out issue #2 which i think originally was about sierra issues. |
Actually there's a fundamental issue with the bootstrap function as when it's loaded into the osxinj process the symbol stubs are actually resolved in the osxinj process space NOT in the injected process space. So basically you have the bootstrap function that's calling osxinj's _pthread_set_self which is NOT the same address as the one in the injected process so you get a EXC_BAD_ACCESS. Now I think that Xcode uses a debug friendly version of the libraries and caches them into a big file so the __pthread_set_self address stays the same even in different processes. That's probably why it works in Xcode and not outside of it, basically because of os's ASLR. I made an assembly version of bootstrap where you find two necessary functions' (_pthread_set_self and dlopen) address inside the injected process space and pass them in the registers to the bootstrap function where you initialize the thread using _pthread_set_self and just load the payload using os's dlopen after that you also need to suspend the thread which I did using a syscall. |
@SFaghihi Odd, when you state "assembly version of bootstrap", does that mean you can't get the bootstrap function working either unless you use your assembly version? Could you share that, if so? I wonder if there's a non ASM way of ensuring the pthread_set_self points to the target process rather than the local process. |
Is this working for you in 10.12/Sierra?
I have an odd situation where mach_inject works perfectly fine, when my app is launched through Xcode. If I launch my app directly, the target process crashes as soon as it attempts to inject:
Does you have any ideas on how to tackle this?
The text was updated successfully, but these errors were encountered: