Giter VIP home page Giter VIP logo

ios-class-guard's Introduction


This repository is no longer maintained. Issue reports and pull requests will not be attended.


iOS Class Guard

iOS-Class-Guard is a command-line utility for obfuscating Objective-C class, protocol, property and method names. It was made as an extension for class-dump. The utility generates a symbol table which is then included during compilation. It effectively hides most of class, protocol, method, property and i-var names.

iOS Class Guard itself is not the silver bullet for security of your application. However, it will definitiely make your application harder to read by an attacker.

Read the official announcement at Polidea Blog

Version

0.8

Do I need It?

This utility makes code analyzing and runtime inspection more difficult, which can be referred to as a simple/basic method of obfuscation. You may ask yourself why it is needed; due to Objective-C architecture any dissection of iOS applications is rather simple. You may want to check out the following links:

How does it work?

The utility works on the compiled version of an application. It reads the Objective-C portion of Mach-O object files. It parses all classes, properties, methods and i-vars defined in that file adding all symbols to the list. Then it reads all dependent frameworks doing the same (parsing Objective-C code structure), but now adding symbols to a forbidden list. Then all symbols from your executable that aren't in the forbidden list are obfuscated. For each symbol a random identifier consisting of letters and digits is generated. Every time you do obfuscation, a unique symbol map is generated. The generated map is then formatted as a header file with C-preprocessor defines. This file is then included in .pch file. Then it finds all XIBs and Storyboards and updates names inside (so effectively Interface Builder files are also obfuscated). The utility also finds xcdatamodel files inside your project and adds symbols (class and property names) to the forbidden list. During compilation any symbol defined in the header is compiled with a different identifier, the generated one.

iOS Class Guard also provides support for obfuscating CocoaPods libraries. When you provide paths to Pods the project utility automatically goes through all listed targets and finds .xcconfig files and precompiled header paths to be modified. Then it adds the previously generated header to library .pch header and updates the header search path in .xcconfig file for a target.

iOS Class Guard also generates symbol mapping in a JSON format. It’s needed for reversing the process when e.g. you get a crash report. It is important to note that iOS Class Guard does not obfuscate system symbols, so if some of the methods/properties have the same name in a custom class they won’t be obfuscated.

Example generated symbols header:

// Properties
#ifndef _parentCell
#define _parentCell _m5c
#endif // _parentCell
#ifndef parentCell
#define parentCell m5c
#endif // parentCell
#ifndef setParentCell
#define setParentCell setM5c
#endif // setParentCell
#ifndef _buttonIndex
#define _buttonIndex _f8q

Installation

Execute this simple bash script in Terminal. When asked for the password, enter your account. It's needed, because the utility is installed in /usr/local/bin.

brew install ios-class-guard

To install bleeding edge version:

brew install --HEAD ios-class-guard

How to use it?

A few steps are required to integrate iOS Class Guard in a project.

  1. Download obfuscate_project in to your project root path.
curl -o obfuscate_project https://raw.githubusercontent.com/Polidea/ios-class-guard/master/contrib/obfuscate_project && chmod +x obfuscate_project
  1. Update the project file, scheme and configuration name.

  2. Do bash obfuscate_project every time when you want to obfuscate your project. It should be done every release. Store the json file containing symbol mapping so you can get the original symbol names in case of a crash.

  3. Build, test and archive your project using Xcode or other tools.

The presented way is the simplest one. You can also add additional target that will automatically regenerate the symbols map during compilation.

Pre compiled header file

After obfuscation, iOS-Class-Guard will try to add generated symbols header (symbols.h) to your project's *.pch file. However, projects created in Xcode 6 and above don't contain *.pch file by default. In case your project doesnt have any *.pch file, you have to add it manually before obfuscation.

To add *.pch file to your project follow the steps below:

  1. Create PCH file in your project's root directory. In Xcode go to File -> New -> File -> iOS -> Other -> PCH File. To ensure backward compatibility iOS-Class-Guard will be looking for a file matching the *-Prefix.pch mask, as an example MyProject-Prefix.pch

  2. At the target's Build Settings, in Apple LLVM - Language section, set Prefix Header to your PCH file name.

  3. At the target's Build Settings, in Apple LLVM - Language section, set Precompile Prefix Header to YES.

For more details please refer to this Stack Overflow question.

Example

You can take a look what changes are required and how it works in some example projects.

git clone https://github.com/Polidea/ios-class-guard-example ios-class-guard-example
cd ios-class-guard-example
make compile

Here is class-dump for non-obfuscated sources: https://github.com/Polidea/ios-class-guard-example/tree/master/SWTableViewCell-no-obfuscated.xcarchive/Headers

What it will look like when you use iOS Class Guard: https://github.com/Polidea/ios-class-guard-example/tree/master/SWTableViewCell-obfuscated.xcarchive/Headers

Command Line Options

ios-class-guard 0.8 (64 bit)
Usage: ios-class-guard [options] <mach-o-file>

  where options are:
        -F <class>     specify class filter for symbols obfuscator (also protocol))
        -i <symbol>    ignore obfuscation of specific symbol)
        --arch <arch>  choose a specific architecture from a universal binary (ppc, ppc64, i386, x86_64, armv6, armv7, armv7s, arm64)
        --list-arches  list the arches in the file, then exit
        --sdk-ios      specify iOS SDK version (will look for /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS<version>.sdk
                       or /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS<version>.sdk)
        --sdk-mac      specify Mac OS X version (will look for /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX<version>.sdk
                       or /Developer/SDKs/MacOSX<version>.sdk)
        --sdk-root     specify the full SDK root path (or use --sdk-ios/--sdk-mac for a shortcut)
        -X <directory> base directory for XIB, storyboards (will be searched recursively)
        -P <path>      path to project.pbxproj of Pods project (located inside Pods.xcodeproj)
        -O <path>      path to file where obfuscated symbols are written
        -m <path>      path to symbol file map (default value symbols.json)
        -c <path>      path to symbolicated crash dump

The utility requires you to get familiar with a few options.

Output header path

iOS Class Guard requires you to provide path to generated symbols header.

Example

-O SWTableView/symbols.h

Class filter

iOS Class Guard allows to filter out some of the classes that can't be obfuscated. For example, because you use it as a precompiled static library.

iOS Code Style assumes that every class is prefixed with a two-or-three-symbol identifier - namespace (ie. NS* for Foundation class). This allows you to filter in or filter out the whole namespace.

Example

-F '!APH*' -F '!MC*'

This will filter out any class in namespace APH and MC.

Ignored symbols

It may happen that some symbols get obfuscated even though they shouldn’t, e.g. if you use C method and name Objective-C method using the same name. It will lead to a linker error (unresolved external). You have to find what symbol is it and add it to the list of ignored symbols.

Example

-i 'deflate' -i 'curl_*'

This will not obfuscate symbols named deflate and symbols that start with curl_*.

CocoaPods

If you’re using CocoaPods in your project you can also obfuscate symbols inside external libraries. The only thing you need is to specify path to Pods PBX project file. It’s located inside the .xcodeproj directory. Utility will modify configurations and precompiled headers so that they’re also obfuscated.

Example

-P Pods/Pods.xcodeproj/project.pbxproj

Other options

Xib directory

This is optional argument. By default utility searches for all XIB/Storyboard files recursively from directory of execution (in most cases root directory of the project). If you store those files in a different directory you can provide a path to the directory where they can be found.

Example
-X SWTableView/Xib

Symbol mapping file

You can provide the path where utility will save symbol mapping. By default it’s symbols.json.

-m release/symbols_1.0.0.json

Reversing obfuscation in crash dump

iOS Class Guard lets you reverse the process of obfuscation. It might come in handy when you get a crash report from a user and you’re trying to find the reason. You can provide a path to a file with crash dump or a file with the output of atos command. Symbols in the file which was provided will be replaced using the symbol mapping file. The result will be saved in the same file.

Example
-c crashdump -m symbols_1.0.0.json

Reversing obfuscation in dSYMs

iOS Class Guard lets you reverse the process of obfuscation for automatic crash reporting tools such as Crashlytics, Fabric, BugSense/Splunk Mint, Crittercism or HockeyApp. With --dsym parameter, iOS Class Guard will exchange obfuscated symbols with original ones within provided dSYM file. We highly recommend you adding in the very beginnig of your Build Phases/Run script one line shown in the example below to automate dSYM translation process. Feature has been tested with the tools mentioned above.

Build Phases/Run script example
if [ -f "$PROJECT_DIR/symbols.json" ]; then
/usr/local/bin/ios-class-guard -m $PROJECT_DIR/symbols.json --dsym $DWARF_DSYM_FOLDER_PATH/$DWARF_DSYM_FILE_NAME --dsym-out $DWARF_DSYM_FOLDER_PATH/$DWARF_DSYM_FILE_NAME
fi

# Another invocations eg.: ./Crashlytics.framework/run <Crashlytics secret #1> <Crashlytics secret #2>
Manual usage example
ios-class-guard -m symbols.json --dsym MyProject_obfuscated.app.dSYM --dsym-out MyProject_unobfuscated.app.dSYM

Limitations

Due to the way iOS Class Guard works you should be aware of two main limitations of that approach.

XIB and Storyboards

ios-class-guard works pretty well with XIB and Storyboard files, but if you’re using external libraries which provide their bundle with Interface Builder files be sure to ignore those symbols, as they won’t work when you launch the app and try to use them. You can do that using Class filter.

Key-Value Observing (KVO)

It is possible that during obfuscation KVO will stop working. Most developers use hardcoded strings to specify KeyPath.

- (void)registerObserver {
    [self.otherObject addObserver:self
                       forKeyPath:@"isFinished"
                          options:NSKeyValueObservingOptionNew
                          context:nil];
}

- (void)unregisterObserver {
    [otherObject removeObserver:self
                     forKeyPath:@"isFinished"
                        context:nil];
}

- (void)observeValueForKeyPath:(NSString *)keyPath
              ofObject:(id)object
                change:(NSDictionary *)change
               context:(void *)context
{
  if ([keyPath isEqualToString:@"isFinished"]) {
    // ...
  }
}

This will simply not work. The property isFinished will get a new name and the hardcoded string will not reflect the change.

Remove any keyPath and change it to NSStringFromSelector(@selector(keyPath)).

The fixed code should look like this:

- (void)registerObserver {
    [self.otherObject addObserver:self
                       forKeyPath:NSStringFromSelector(@selector(isFinished))
                          options:NSKeyValueObservingOptionNew
                          context:nil];
}

- (void)unregisterObserver {
    [otherObject removeObserver:self
                     forKeyPath:NSStringFromSelector(@selector(isFinished))
                        context:nil];
}

- (void)observeValueForKeyPath:(NSString *)keyPath
              ofObject:(id)object
                change:(NSDictionary *)change
               context:(void *)context
{
  if ([keyPath isEqualToString:NSStringFromSelector(@selector(isFinished))]) {
    // ...
  }
}

Serialization

If you use classes that are saved to the disk or user defaults using NSCoding protocol you’ll have to exclude them from obfuscation. If you don’t, after generating symbols again your app will start crashing as it won’t be able to read that class from serialized data.

Undefined symbols

When using iOS-Class-Guard it is more than probable that you will encounter issues similar to this:

Undefined symbols for architecture i386:
  "_OBJC_CLASS_$_n9z", referenced from:
      objc-class-ref in GRAppDelegate.o

To fix it, copy n9z and search for it in symbols.h. Most probably it will be a class. You simply have to exclude it from obfuscation by specifying: -F '!UnresolvedClassName' and retest.

Note

iOS-Class-Guard works alongside LLVM Obfuscator: https://github.com/obfuscator-llvm/obfuscator. However, this has not been tested.

License

This file is part of ios-class-guard, a utility for obfuscating the Objective-C applications. Copyright (C) 2014 Polidea. The application is made as an extension for class-dump, a utility for examining the Objective-C segment of Mach-O files. Copyright (C) 1997-1998, 2000-2001, 2004-2013 Steve Nygard.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

ios-class-guard's People

Contributors

0xced avatar aricha avatar ayufan avatar jakublipinski avatar literator avatar nygard avatar rodionovd avatar tgrf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ios-class-guard's Issues

Cannot compile the app after obfuscation when using Xcode 7

I tried to compile the app after obfuscation by using Xcode 7 GM but compile fails with lot of errors. See few example errors below.

error: use of undeclared identifier 'k1r' self.view.backgroundColor = [UIColor colorWithWhite:0 alpha:0.6];

error: no known class method for selector 'colorWithWhite:k7G:' self.view.backgroundColor = [UIColor colorWithWhite:0 alpha:0.6];

error: no visible @interface for 'UIViewController' declares the selector 'b50' [super didReceiveMemoryWarning];

Any glue or plans for Xcode 7 support?

Obfuscated C++ methods

Thanks for the amazing tool! I ran it into my project and it worked perfectly. The only thing I had to do was comment the obfuscated C++ methods in symbols.h (as free(void *)).

Best regards.

iOS 9 warnings regarding dylib

Did anyone get these types of warnings -
2015-10-21 14:29:07.544 ios-class-guard[20418:1056995] Warning: Failed to load: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.0.sdk/usr/lib/libobjc.A.dylib
2015-10-21 14:29:07.544 ios-class-guard[20418:1056995] Warning: Couldn't load MachOFile with ID: /usr/lib/libobjc.A.dylib, adjustedID: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.0.sdk/usr/lib/libobjc.A.dylib

With the move from .dylib to .tbd I can understand why we have these warnings, but how come nobody encountered this issue, and if someone did - is there a solution?

The result of the ".\obfuscate_project" is not expected.

I run the command: ./obfuscate_project, the result is: "Congratulations! Obfuscation completed. You can now build, test and archive Your project using Xcode, Xctool or Xcodebuid..." so i open my xcode and click Product->Archive, i am exporting to ".IPA" the result file ".APP".
When open the file in the software "IDAQ" i can see all name of the methods e other codes inside the file.
That result is the same when i build direct in xcode, whithout .\obfuscate_project
what i am making wrong ?

Installation Failure

When I run the installation command, I got the following error. Anyone can help?

brew install https://raw.githubusercontent.com/Polidea/homebrew/ios-class-guard/Library/Formula/ios-class-guard.rb

################################################################## 100.0%

==> Downloading https://github.com/Polidea/ios-class-guard/archive/0.6.tar.gz
Already downloaded: /Library/Caches/Homebrew/ios-class-guard-0.6.tar.gz
==> xcodebuild -workspace ios-class-guard.xcworkspace -scheme ios-class-guard -configuration Release SYMROOT=build PREFIX=/usr/local/Cellar/ios-class-guard/0.6

The following build commands failed:
CompileC DerivedData/ios-class-guard/Build/Intermediates/ios-class-guard.build/Release/MachObjC.build/Objects-normal/x86_64/CDLCSegment.o Source/CDLCSegment.m normal x86_64 objective-c com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)

check dependencies failed

I downloaded obfuscate_project into my project's root directory, changed the configuration and then ran it. Then it has a code sign error saying: entitlements are required for product type 'Application' in SDK 'Simulator - iOS 9.2'. Your Xcode installation may be damaged. I don't know how to solve this problem. Can anyone help me? Thanks so much!!!

Expected a version of the form 'major[.minor[.subminor]]'

In header classes:
stdlib.h
stdio.h

Error name :
1)Expected a version of the form 'major[.minor[.subminor]]'
2)__swift_unavailable

After obfuscation I build my project suddenly these above errors occurred.
i don't know what to do.
please give me a solution.

Undefined symbol error

I am just getting started. Using the basic script tweaked slightly, I am getting this (after successfully building a million files).

Can anyone help with this?

Thanks

▸ Analyzing FOOLike.m

⌦ Undefined symbols for architecture arm64

Symbol: OBJC_CLASS$_c6r
Referenced from: objc-class-ref in FOOFacebookFriendsConnector.o

⌦ ld: symbol(s) not found for architecture arm64

⌦ clang: error: linker command failed with exit code 1 (use -v to see invocation)

⌦ Undefined symbols for architecture armv7

Symbol: OBJC_CLASS$_c6r
Referenced from: objc-class-ref in FOOFacebookFriendsConnector.o

⌦ ld: symbol(s) not found for architecture armv7

⌦ clang: error: linker command failed with exit code 1 (use -v to see invocation)

** BUILD FAILED **

obfuscate project with xib option doesn't work

I get my project obfuscated with the help of class-guard,but when I want to Single-step debug my project, I need to appoint my X option ,while the symbol of xib cannot match the projects.
can someone give me an small example using x option, ?

Cannot find offset for address 0x5000000001004dca in stringAtAddress:

Following the manual, I have tried to use obfuscate_project script. All I changed is "General build options". Script passes clean and build stage with success, but fails on obfuscation itself.

So ios-class-guard fails with following output:

2015-09-18 17:02:00.614 ios-class-guard[68503:1570876] Error: Cannot find offset for address 0x5000000001004dca in stringAtAddress:

Can someone tell why this error may occur and how I can fix it? Thanks in advance.

UPDATE: By exclusion I determined that problem lays in some swift classes, i.e. when I exclude them from project obfuscation works like a charm. Looks like ios-class-guard cannot simply process it. Maybe I can somehow "tell" ios-class-guard to pass swift code and work only with objC? Or any way to avoid this behaviour. It is not a big deal if I cannot obfuscate swift code.
I appreciate any advice.

Running on Xcode 6.1 obfuscates system symbols

When running obfuscation script on Xcode 6.1, my output file contains defines such as "NSObject", "self", "length", "isEqual" and some other names from iOS SDK. On Xcode 5 eveything works fine, application compiles and works as expected with generated preprocessor's directives. Have you got similar experience on latest Xcode?

Apple Watch support

I am currently developing an app that has support for Apple watch. I would like to obfuscate all the targets that the entire app implies, those are:

  • iPhone target, as always.
  • Apple watch extension target (this is a target, but not a scheme).
  • Apple watch target.

Currently, the library gives just support for one target, does anyone know how may I work this out? does anyone know any work around in order to get this aim?

Thanks!

use the obfuscate_project, but outside the git.

Hi. I want to use the obfuscate_project in my project, but outside the git.

But when I run "./obfuscate_project" at the root of my project I get the error:
        "git reset --hard
        fatal: Not a git repository (or any of the parent directories): .git "

It is possible?

Can you Help Me?please!!!

I am using ios-class-guard with Xcode8.3.3,when my CocoapodsProject contain
Realm ,i meet this question. eg: #include "collection_notifications.hpp" file not found ?who help me ???Anxious!,please!!!

how to set obfuscate-project file?

My project is running in Xcode 7.2,I had tried to obfuscated the ExampleBankingApp,but it didn't work.
From the log,i find that obfuscate-project file is wrong setting.After that,I use ios-class-guard in my own
project,the obfuscate-project (use the curl )is different from the example one,so i doubt something is wrong with my obfuscate-project setting,can any one tell me how to set this?

Obfuscating class base type problem (UInt32).

Im using a cocapods library called 'UIColor-Utilities' in the obfuscation process everything goes fine without any problems. But when compiling the obfuscated project I'm getting a error in the pods library in the category class right at the property with the type UInt32:

Unknown type name 'z1sQYfL2O'
Expected a type

I've also tried to exclude the the category class from obfuscating it, but it does't seem to work:

-F '!UIColor*' -F '!UIColor+Expanded' -F '!UIColor+HSV'

Is there any solution to this issue ?

obfuscate only some classes

it would be very useful if one could use a inverse filter, like -F X -F Y and only classes X and Y would get obfuscated

Obfuscation fails on Xcode 7.2

I am trying to obfuscate my project and I am getting tons of errors in the process

While building module 'Darwin' imported from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKitDefines.h:8:
In file included from <module-includes>:1:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk/usr/include/sys/cdefs.h:707:2: error: 
      Unsupported architecture
# error Unsupported architecture```

I assume that this is just too new a version of Xcode? or am I missing something else?  thanks in advance for any help

Build failed

I have a project with two targets and few pods. When i successfully obfuscate it, the build is not working.

Error: Expected an Objective C directive after "@"
This error exists in every class where @optional is used

Pods error

Linking failed using Pods
Command "Link ... Objects-normal/armv7/AppName"
Command "Link ... Objects-normal/arm64/AppName"

Got an error "ld: library not found for -lPods-CocoaAsyncSocket
clang: error: linker command failed with exit code 1 (use -v to see invocation)}"

Polidea ios-class-guard not supporting latest mac os x capitan

Was trying to use polidea to obfuscate the code. while running the script its shows its needed mavericks osx version. does it support mac latest osx capitan?

The Exact error is below:

class-dump: This formula either does not compile or function as expected on OS X
versions newer than Mavericks due to an upstream incompatibility.
Error: An unsatisfied requirement failed this build.

Static libraries

Currently static libraries are not supported. I understand that securing apps (not libs) is more common use case.

Is it just a matter of configuring the tool? That is providing list of files to obfuscate (.h .m) along with public header files that should not be obfuscated as entry point?

not working for iOS Frameworks

Hi Team,

I tried obsficating the iOS framework using iOS guard.Its not working as symbols.h file is showing no data.Same way there is no values in JSON file also.

Note : I am able to obsficate the project if the target is .app but if my target is a .framework, then only the above issue is coming.

Please help.

line 27: xctool: command not found

Hello, I wanted to run the command:
ios-class-guard --sdk-root /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.1.sdk
But nothing has changed. Can you help me?

How to exclude some classes and pods libraries

I need to exclude some some classes and all pods libraries like UISS, StompKit, else...

I am trying like this CLASS_GUARD_OPTS="-F 'IG *' -F 'UISS *'", but still iOS class guard obfuscating it

also i tried like this CLASS_GUARD_OPTS="-F '!IG *' -F '!UISS *'"

2016-01-10 11:47:54.693 ios-class-guard[71726:1372666] Obfuscating@ class IGAxis 
2016-01-10 11:47:54.694 ios-class-guard[71726:1372666] Obfuscating @class IGCategoryAxisBase 
2016-01-10 11:47:54.694 ios-class-guard[71726:1372666] Obfuscating @class IGNumericAxisBase

Am using xcode 7.1.1

ViewControllers exclusion

After starting obfuscated project we have a lot of crashes related to ViewController classes (e.g. reference in XIB).

In console log we see symbol which caused the crash. After finding that symbol in "symbols.h" we exclude associated class, as described in section "Undefined symbols" of your README.md.

By repeating this process we manage to get app work properly BUT most of our ViewControllers are now excluded. This means that level of protection is now much lower.

Is there a way to fix problematic symbols without excluding classes?

ios-class-guard design

Last week we had an internal discussion about new features and whether they should be in separate commands or should be implemented in current ios-class-guard binary. Here are proposals:

  1. Implement any action as separate tools:
    a. ios-class-guard-obfuscate <symbols.h> - main action to process iOS binary and generate symbol's map
    b. ios-class-guard-symbolicate <symbols.json> - additional tool to convert deobfuscate crash dumps
    c. ios-class-guard-dsym <symbols.json> - additional tool to deobfuscate dSYM
  2. Add top level commands to ios-class guard:
    a. ios-class-guard obfuscate <symbols.h>
    b. ios-class-guard symbolicate <symbols.json>
    c. ios-class-guard dsym <symbols.json>
    d. ios-class-guard help [command], ie.: ios-class-guard help obfuscate
  3. Use switches (current method):
    a. ios-class-guard [options] -O symbols.h -m symbols.json - main action
    b. ios-class-guard -c crashdump -m symbols_1.0.0.json - crash dumps
    c. ios-class-guard -D -m symbols.json -O <dSYM.new> - deobfuscate dSYM
    d. ios-class-guard - help

Which one do you prefer? I personally would opt for option 2, because of commonness of such approach, ie.: vagrant, github client, docker, etc.

xcodebuild: error: 'YourProject.xcodeproj' does not exist.

git reset --hard
HEAD is now at 46bb94d 04.03.15 for obfuscate 2
git clean -fdx
xcodebuild -project YourProject.xcodeproj -scheme YourScheme -configuration Release -sdk iphonesimulator7.1 clean build -derivedDataPath build
User defaults from command line:
IDEDerivedDataPathOverride = ....

Build settings from command line:
SDKROOT = iphonesimulator7.1

xcodebuild: error: 'YourProject.xcodeproj' does not exist.
logout

Can I obfuscate a Framework ?

I developed a frameqork to use in my projects, and i'm need obfuscate this Framework.
Is it possible with command ./obfuscate_project ?

ios-class-guard on Mac app error

$ ios-class-guard MyApp.app/Contents/MacOS/MyApp
ios-class-guard[6578:474976] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'must provide a directory path'
*** First throw call stack:
(
0 CoreFoundation 0x00007fff919f464c __exceptionPreprocess + 172
1 libobjc.A.dylib 0x00007fff8f4936de objc_exception_throw + 43
2 CoreFoundation 0x00007fff919f44fd +[NSException raise:format:] + 205
3 Foundation 0x00007fff958a5d4d COPY_SETTER_IMPL + 150
4 ios-class-guard 0x000000010a92a56c -[CDSystemProtocolsProcessor systemProtocolsSymbolsToExclude] + 218
5 ios-class-guard 0x000000010a8e816e main + 5738
6 libdyld.dylib 0x00007fff98d3d5c9 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Abort trap: 6

Error when OBFUSCATE with SDK 11.0 XCode 9.0

I updated my SDK to 11.0. When I OBFUSCATE my project and compiled, I get many errors with the phrases: "I expected an Objective-C directive after '@'", "Missing '@EnD'" and "Illegal interface qualifier."
Anyone have any idea why this?

Error with installed libraries

We are using Infragistics grid in our project by installing the library (.dmg), library header files in "/Developer" path.
When obfuscate the project we got this error:

TTouchGridView.h:9:9: fatal error:
'IG/IG.h' file not found

import < IG/IG.h >

iOS-class-guard gives error "could not find scheme name in project"

I am using the ios-class-guard for obfuscating my code. However, I am running into an issue where it cannot find the name of scheme that I am providing. I have noticed that as I run the obfuscate_project command, the folder containing the scheme is deleted (I can see it being removed on the terminal). After that, it gives the error that it cannot find the scheme that I have mentioned.

Please help..!! What am I doing wrong?

Obfuscator hangs mid-obfuscation

I have a file that, when fed to the obfuscator, causes it to hang at this point:

2015-03-30 11:07:41.120 ios-class-guard[20143:4698377] Generating symbol table...
2015-03-30 11:07:41.121 ios-class-guard[20143:4698377] Protocols = 16
2015-03-30 11:07:41.121 ios-class-guard[20143:4698377] Classes = 136
2015-03-30 11:07:41.121 ios-class-guard[20143:4698377] Categories = 16
2015-03-30 11:07:41.121 ios-class-guard[20143:4698377] Methods = 1751
2015-03-30 11:07:41.121 ios-class-guard[20143:4698377] I-vars = 345
2015-03-30 11:07:41.121 ios-class-guard[20143:4698377] Forbidden keywords = 154210

Unfortunately, the history is such that I can't just unmake the last change (don't remember what it was).

Has anyone else seen this? Does anyone know how to get around it?

Thanks

Obfuscation not working

I am trying to obfuscate an OSX application after making some changes to the obfuscate_project script, the symbols.json file is getting generated, but the final app is not getting obfuscated. May be following warning messages are the source of error, kindly check :

Warning: Failed to load: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation

Warning: Couldn't load MachOFile with ID: /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation, adjustedID: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation

Warning: Failed to load: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/lib/libobjc.A.dylib
Warning: Couldn't load MachOFile with ID: /usr/lib/libobjc.A.dylib, adjustedID: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/lib/libobjc.A.dylib

Warning: Failed to load: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/lib/libSystem.B.dylib
Warning: Couldn't load MachOFile with ID: /usr/lib/libSystem.B.dylib, adjustedID: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/lib/libSystem.B.dylib

Warning: Failed to load: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks/AppKit.framework/Versions/C/AppKit
Warning: Couldn't load MachOFile with ID: /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit, adjustedID: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks/AppKit.framework/Versions/C/AppKit

Warning: Failed to load: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation

Warning: Couldn't load MachOFile with ID: /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation, adjustedID: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation

Kindly, suggest me some workaround.

I'm having trouble obfuscation.

When i obfuscate my project, i have no error.
But when i run my project, only appears my screens UITableViewController, but my screens UIViewController only appear black screen.

xctool: command not found

Dear author,

When I ran the sample project, it reported the error message xctool: command not found.

I guess the xctool should be the tool from facebook (https://github.com/facebook/xctool), but facebook's xctool is a batch file, so it should be xctool.sh.

Please help me, the detailed console log is below:

+ PROJECT=SWTableViewCell.xcodeproj
+ SCHEME=SWTableViewCell
+ TARGET=SWTableViewCell
+ CONFIGURATION=Release
+ SDK=iphoneos
+ git reset --hard
HEAD is now at 1d0469d Integrate iOS-Class-Guard
+ git clean -fdx
+ [[ -f Podfile ]]
+ xctool -project SWTableViewCell.xcodeproj -scheme SWTableViewCell -configuration Release -sdk iphoneos clean build OBJROOT=build/ SYMROOT=build/
obfuscate_project: line 19: xctool: command not found

Local Podspecs can not find

Podfile:
pod 'QCCommon', :path => '../repo/QCCommon/'

fatal error:
'QCCommon.h' file not found
#import "QCCommon.h"

😢

I am getting this error when I run this command

ld: warning: directory not found for option '-L/x/build/Build/Products/PROD-iphonesimulator/AFNetworking'
ld: warning: directory not found for option '-L/x/build/Build/Products/PROD-iphonesimulator/ActionSheetPicker-3.0'
ld: warning: directory not found for option '-L/x/build/Build/Products/PROD-iphonesimulator/Bolts'
ld: warning: directory not found for option '-L/x/build/Build/Products/PROD-iphonesimulator/EAIntroView'
ld: warning: directory not found for option '-L/x/build/Build/Products/PROD-iphonesimulator/EARestrictedScrollView'
ld: warning: directory not found for option '-L/x/build/Build/Products/PROD-iphonesimulator/FBSDKCoreKit'
ld: warning: directory not found for option '-L/x/build/Build/Products/PROD-iphonesimulator/FBSDKLoginKit'
ld: warning: directory not found for option '-L/x/build/Build/Products/PROD-iphonesimulator/FBSDKShareKit'
ld: warning: directory not found for option '-L/x/build/Build/Products/PROD-iphonesimulator/IQKeyboardManager'
ld: warning: directory not found for option '-L/x/build/Build/Products/PROD-iphonesimulator/JDFTooltips'
ld: warning: directory not found for option '-L/x/build/Build/Products/PROD-iphonesimulator/KIImagePager'
ld: warning: directory not found for option '-L/x/build/Build/Products/PROD-iphonesimulator/MBProgressHUD'
ld: warning: directory not found for option '-L/x/build/Build/Products/PROD-iphonesimulator/MZTimerLabel'
ld: warning: directory not found for option '-L/x/build/Build/Products/PROD-iphonesimulator/Ono'
ld: warning: directory not found for option '-L/x/build/Build/Products/PROD-iphonesimulator/RMMapper'
ld: warning: directory not found for option '-L/x/build/Build/Products/PROD-iphonesimulator/SDWebImage'
ld: warning: directory not found for option '-L/x/build/Build/Products/PROD-iphonesimulator/SVProgressHUD'
ld: warning: directory not found for option '-L/x/build/Build/Products/PROD-iphonesimulator/SevenSwitch'
ld: warning: directory not found for option '-FFrameworks'
ld: library not found for -lAFNetworking
clang: error: linker command failed with exit code 1 (use -v to see invocation)

** BUILD FAILED **

The following build commands failed:
Ld build/Build/Intermediates.noindex/x.build/PROD-iphonesimulator/x.build/Objects-normal/x86_64/x normal x86_64
Ld build/Build/Intermediates.noindex/x.build/PROD-iphonesimulator/x.build/Objects-normal/i386/x normal i386
(2 failures)

Obfuscating categories

I have a class User and also with a category User (Additional).

In my obfuscate script, I've added -F "!User*" but it still obfuscates the category. Is there anyway to prevent the category from being obfuscated?

Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.