kam800 / MachObfuscator

MachObfuscator is a programming-language-agnostic Mach-O apps obfuscator for Apple platforms.
MIT License
521 stars 77 forks source link

App file crash because obfuscated Set function #97

Open Yiiff opened 4 years ago

Yiiff commented 4 years ago

Hi Kam I do appreciate this repo help me to solve the obfuscator problem. But I found a problem when I obfuscated .app file. This is the log:

2019-12-23 22:03:56.963655+0800 Simulation[3932:439170] -[XXXxxx setApiVersion:]: unrecognized selector sent to instance 0x280bb2780
2019-12-23 22:03:56.966199+0800 Simulation[3932:439170] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[XXXxxx setApiVersion:]: unrecognized selector sent to instance 0x280bb2780'
*** First throw call stack:
(0x1af5b180c 0x1af2d9fa4 0x1af4b536c 0x1af5b5c88 0x1af5b7a6c 0x1051f8578 0x1051f13e4 0x1051dae10 0x104f035e8 0x10573ffb8 0x1b3610ecc 0x1b3612cf8 0x1b361852c 0x1b2de6c3c 0x1b327bf9c 0x1b2de7724 0x1b2de717c 0x1b2de7550 0x1b2de6e0c 0x1b2deb328 0x1b31ae67c 0x1b3295588 0x1b2deb060 0x1b3295484 0x1b2deaecc 0x1b2c5cb04 0x1b2c5b66c 0x1b2c5c83c 0x1b36168ac 0x1b31cf074 0x1b46b6850 0x1b46db8e8 0x1b46c0fb4 0x1b46db5a4 0x1058aabd8 0x1058adffc 0x1b47004c8 0x1b4700194 0x1b47006bc 0x1af52f7c4 0x1af52f71c 0x1af52eeb4 0x1af52a000 0x1af5298a0 0x1b9481328 0x1b361a740 0x104f2e9b0 0x1af3b4360)
libc++abi.dylib: terminating with uncaught exception of type NSException

So I add this method to --objc-blacklist-selector, but app crash again.

After I dump header, I can't found this method, but there is a property with this name.

I want to know how to add an obfuscation strategy that does not obfuscate the specified attributes.

kjamroz-bt commented 4 years ago

Just to be sure: did you blacklist setApiVersion: with colon at the end (that is important because colon is part of selector name)? Do you get the same crash with the same selector after blacklisting? Property names and ivars currently are not obfuscated.

Yiiff commented 4 years ago

I do add a colon at the end of the selector. And the app still crashed, so I do some test, and I found a result:

Test Code

#import "HomeViewController.h"
@interface HomeViewController () {
    int _apiVersion;
    NSString *_token;
    NSString *_session;
}

/** Token */
@property (nonatomic, copy) NSString *token;

@end

_apiVersion and __token will be obfuscated as cstring, but _session_ is not.

property method and class name was fine after obfuscated, cstring was not.

Seems to be a random situation, I'm still analyzing the existing code, hoping to manually control the content of the property, just like this feature of the selector blacklist.