This project aims to encypt or obscure plain text for all the Objective C implement files(extension name 'm') in iOS project. So no plain text in your app's binary file.
- Simple. Developer can hard code plain text in iOS project, all the operation like encrypting or obscuring will automatically run before compiling.
- Customable of encrypting or obscuring(because decrypting happens in app's running, the way of encrypting should be fast and easy) which improves difficulty of reverse engineering
- Can't encrypt objective-c string like @"a""b" because of the default regex. Make sure change it to @"ab", or the project will not compile successfully
- Can't encrypt escape sequences contains \nnn,\xnn, \unnnn and \Unnnnnnnn. Make sure your objective-c string doesn't contain these.
- Can't encrypt static type string
- Using private API, let MixPlainText handle the obscring, make sure don't invoke private API when in the Apple approval process
- Improving the difficulty of reverse analysis
-
Open your project which needs to be obscured. In the Build Phases session of target, add a new Run Script, make sure this is before Compile Souces. The content of script is like below:
# 默认是 Debug 情况下运行,可根据需要自定义,比如 Release if [ "${CONFIGURATION}" = "Debug" ]; then # 注意由于你的工程目录可能包含 Pods 这类第三方代码,所以你需要切换到你自己代码所在的目录比如 MixIosDemo 目录 cd MixIosDemo chmod +x ../mix.swift ../mix.swift fi
-
add MixIosDemo/MixOC/MixDecrypt.h in your project
-
import MixDecrypt.h in your project's pch header
You can watch MixIosDemo for detail setting
The default encrypt method is xor(maybe it just obscrue the plain text). Two steps to custom encrypt or obscure.
- Modify encrypt method in mix.swift
- Modify decrypt method in dl_getRealText function in MixDecrypt.h
Attention, don't use complex encyrpt/decyrpt method, and make sure encyrpt/decyprt right, or the running will fail.
- Support C type string
- Support file type, like mm, h, pch, c, cpp type of file.
Author: @粉碎音箱的音乐(weibo)
Blog: Blog
Please star if you think it is helpful to you. Thank you. 😄