IOS Introduction to code obfuscation (OC)
I do iOS development also has a few years of time, usually finished the project is directly packaged onto the AppStore, and then do the shelves to operate. But recently, the customer has put forward code security requirements. Say is to do code obfuscation, this aspect of work has never been touched before. Then I looked up the internet, there are many applications have been code confusion. It seems that I am on my laurels ...
Cause
Using Classdump to dump the original program, you can dump all the functions of the source program all the information: the source program all function types, the variables are all leaked. In this way, the attackers, that is, hackers understand the program structure to facilitate the reverse. Because in the project, we have these variables or function naming are certain readability, for example, with the user name related, that generally there will be userName, with the password-related general will have password, so the definition is for our own code readability is stronger, we modify the time is more convenient. But we believe that this definition of law, we just want to facilitate ourselves, we do not want to facilitate hackers to hack our app. Summed up is a sentence: "will be your project all the methods and variables are listed."
Start confusion: 1.
Before we do code obfuscation, we need to add two files to our project: confuse.sh &func.list
Let's open our terminal command line.
First CD to the path of your project, then enter
Then enter them in the terminal separately.touch confuse.shAndfunc.listAnd then enter.
When we open our project folder this time, we can see two more files. This time we open our project and add the two files we created to the project.
2
This time we click on our confuse.sh files can see the content is empty, we have to fill in some code, click this link address iOS security attack and Defense (23): Objective-c code Confusion can paste the great God's code into his own confuse.sh file
3
Add a file to the project .PCH . If you say you don't know how .pch to add, it doesn't matter. Here's a link address to help you create and configure PCH files in iOS.
After successfully adding the .pch file, we will .pch add the code to the file #import"codeObfuscation.h and we compile it, is it an error? Is that it?
Let's comment out the error code first and then go to the project'sBuild PhasesIn the upper-left corner of the+Number, check that.New Run Script PhaseAnd then, as shown, put yourconfuse.shThe address of the file is written and returned to our PCH file, which opens the line of code we just commented on, and then compiles it all at once. This is the time to prove that the code confuses the upfront work that we have done.
4
Then the next step is how to confuse the code.
At this point you'll find a class (. h. m) file that you want to confuse. Copy the code you want to confuse and paste it into our func.list file. Then compile it and switch to the interface
We can see that the attributes or method names we have defined are confused.
5 Finish the call, over!!!!!. 6 Note: This method can only be confused with. m.h classes, static libraries, etc. only. h files cannot be confused 7 Portal: Objective-c code obfuscation
C4ibd3
Links: https://juejin.im/post/5b06578f51882538c150744b
IOS Exploration Code obfuscation (OC)