I've researched quite a bit, both on SO, as well google-ing all over the place, but I can't seem to find a straight-forward answer in regards to code obfuscation for iPhone/iPad apps written in Objective-C.
My questions are these:
Why iOS apps need obfuscation. Mobile app-based cybercrime is ever-evolving, and hackers always find new and better methods to reverse engineer apps to identify weaknesses, secrets and get a hold of sensitive information. Objective-C and Swift are the most common programming languages for iOS apps.
Strongly consider utilizing obfuscation and runtime app self-protection if you release software that runs in an untrusted environment and has intellectual property, provides access to sensitive information, or has gated functionality.
If you're deploying code in untrusted environments where you want to protect your source code, you should almost always use at least a basic obfuscator to rename functions, methods, and properties to make decompiling take a bit more effort.
Press F12 to open Developer Tools inside Chrome. Now switch to the Scripts tab, right-click and choose De-obfuscate source. That's it!
There doesn't seem to a code obfuscator for Objective-C. But let's assume for a moment that one does exist.
Apple will probably not reject an obfuscated app as long as it doesn't crash. The main question is: what is the point of obfuscation ? Normally, you want to obfuscate code to protect your knowledge, for example if your program uses a copy protection you want to make it harder for a potential cracker or if you're using some advanced algorithm you don't want the business competitors to be able to decompile it.
The copy protection is already been taken care of on iOS. Although through jailbreaking a normal app can be copied and run, I'd say the actual number of users who do this is fairly low (at least a lot lower than on "regular" computers like PC and Mac). Do you expect piracy such a big problem that you need to obfuscate ?
If you do have important knowledge to protect then obfuscation might be worthwhile. Obfuscation has its downsides: you can't debug your obfuscated app any more. Crash reports will be useless.
You might also want to read the article Obfuscating Cocoa.
Back to the fact there doesn't seem to be an obfuscator: What you can do is this trick: say you have a header like this:
@interface MyClass : NSObject {
}
- (void)myMethod;
You could do a cheap obfuscation like this:
#ifndef DEBUG
#define MyClass aqwe
#define myMethod oikl
#endif
@interface MyClass : NSObject {
}
- (void)myMethod;
This way you can still use meaningful symbols in your source, but the compiler would turn it into "garbage" when not compiling for debugging.
Further to the earlier answers there are now several 3rd party tools that offer some degree of obfuscation and integrity protection including :-
They vary in capabilities and include :-
All of these tools are very expensive and not without their problems so you really need an application that requires a high degree of integrity in order to consider them e.g. banking or where DRM is very important.
For these types of app you will also need skilled penetration testers to ensure that your app is not exposed in other ways as these tools are often only as good as the people using them and there are still other OS vulnerabilities that will need mitigating that the tools don't address.
The executable of an app is already encrypted by Apple, and the executable code segment of the app sandbox isn't writeable, so you can't do additional encryption that requires runtime arm code modification. And the optimizer pass of the Objective C/C compiler already creates something very different from the original source code. Using more C and less Objective C will reveal less of your function names, as method names are embedded in visible plain text, but C function names are not. So any trade secret type code should probably be coded in plain C, and compiled with the optimizer turned all the way up. You could obfuscate any webKit Javascript embedded within the app bundle, or any other embedded VM code (as long as interpreted code isn't downloaded).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With