2

Please forgive me if this is an obvious question or if there are any errors. I am very new to Objective-C and have kind of been thrown in the deep end.

I am looking into Objective-C obfuscation. On simple method of this that I found here is to user the preprocessor to change method names to gibberish. My question is whether a decompiler can recognize preprocessor statements, such that it would be able to decompile the source back to the original method names. The example from the above referenced question is below:

#ifndef DEBUG
#define MyClass aqwe
#define myMethod oikl
#endif

@interface MyClass : NSObject {
}

- (void)myMethod;

Is it possible for, when not compiled for debugging, this code could be decompiled back to anything other than

@interface aqwe : NSObject {
}

- (void)oikl;
Community
  • 1
  • 1
ewok
  • 20,148
  • 51
  • 149
  • 254
  • Yes, you could simply run the source file through the C pre-processor to get the output (once you'd stripped out include files). – trojanfoe Feb 22 '12 at 16:21
  • @trojanfoe so I'm clear, if the compiled code were deployed without the source included (just the compiled binaries when not compiled for debugging) it is still possible to get the original source out of it? – ewok Feb 22 '12 at 16:24
  • I think I've misunderstood your question - I have assumed you wanted to give the source file to somebody, but that's not the case is it. – trojanfoe Feb 22 '12 at 16:34
  • Actually thinking about obfuscation is most frequently used when distributing source code. If you want to protect your binary can't you just `strip` the symbols? – trojanfoe Feb 22 '12 at 16:52

2 Answers2

4

You could absolutely not un-obfuscate that. The preprocessor runs before the compiler gets its greasy paws on the code, so it's just as if you had manually gone through and replaced all occurrences of MyClass with aqwe, etc.

Although, you should ask yourself why you want to do this. It's just obfuscation remember, rather than actually securing anything about your code. People could still look and see the code that each method comprises. You're just changing the name of symbols.

mattjgalloway
  • 34,792
  • 12
  • 100
  • 110
0

You'll save yourself a lot of time, pain and trouble if you just choose to use one the many existing obfuscators availible instead of trying to reinvent the wheel.

Take a look at this thread, you'll find lot of useful information for a starter:

https://stackoverflow.com/questions/337134/what-is-the-best-net-obfuscator-on-the-market

Community
  • 1
  • 1
oanoss
  • 86
  • 4