iOS 代码混淆的简单使用

1.工具下载  http://stevenygard.com/projects/class-dump/  选择dmg安装包

2.打开终端输入:open/usr/local/bin

3.

4.修改权限在终端键入: sudo chmod 777 /usr/local/bin/class-dump

5.使用Python3自动发包工具解压包后缀为zip

Python脚本如下(上传蒲公英脚本可以忽略)

#!/usr/bin/env python

#coding=utf-8 

import os

import requests

import webbrowser

import subprocess

import shutil

 

'''

使用注意事项:该脚本基于python3.6

1、将工程的编译设备选成 Gemeric iOS Device

2、command + B编译

3、执行脚本文件

//3.7/Users/zrq/Library/Developer/Xcode/DerivedData/GSTProject-fqtpprwvigsfvugxwfsdvxdvywcu/Build/Products/Debug-iphoneos/GSTProject.app

//3.6 /Users/zrq/Library/Developer/Xcode/DerivedData/GSTProject-cuyhzrkrfbncceatynnajegnbsyu/Build/Products/Debug-iphoneos/GSTProject.app

//线上 /Users/zrq/Library/Developer/Xcode/DerivedData/GSTProject-azzauvtqxgmxnrggnafpvhisblsq/Build/Products/Debug-iphoneos/GSTProject.app

//3.9 /Users/zrq/Library/Developer/Xcode/DerivedData/GSTProject-aghhbgcjerclpeaxxbjwxsyjielw/Build/Products/Debug-iphoneos/GSTProject.app

 

'''

 

appFileFullPath = '/Users/zrq/Library/Developer/Xcode/DerivedData/GSTProject-azzauvtqxgmxnrggnafpvhisblsq/Build/Products/Debug-iphoneos/GSTProject.app'

PayLoadPath = '/Users/zrq/Desktop/Payload'

packBagPath = '/Users/zrq/Desktop/ProgramBag'

openUrlPath = 'https://www.pgyer.com/d33d'

 

 

#上传蒲公英

USER_KEY = "cc33dd4d7e9ef30b1be9d8022648e0e2"

API_KEY = "e989280adbf6890b4072970f07d9aaf8"

 

#上传蒲公英

def uploadIPA(IPAPath):

    if(IPAPath==''):

        print("\n*************** 没有找到对应上传的IPA包 *********************\n")

        return

    else:

        print("\n***************开始上传到蒲公英*********************\n")

        url='http://www.pgyer.com/apiv1/app/upload'

        data={

            'uKey':USER_KEY,

            '_api_key':API_KEY,

            'installType':'2',

            'password':'',

            'updateDescription':""

        }

        files={'file':open(IPAPath,'rb')}

        r=requests.post(url,data=data,files=files)

 

def openDownloadUrl():

    webbrowser.open(openUrlPath,new=1,autoraise=True)

    print ("\n*************** 更新成功 *********************\n")

 

#编译打包流程

def bulidIPA():

    

    #删除之前打包的ProgramBag文件夹

    subprocess.call(["rm","-rf",packBagPath])

    #创建PayLoad文件夹

    mkdir(PayLoadPath)

    #将app拷贝到PayLoadPath路径下

    subprocess.call(["cp","-r",appFileFullPath,PayLoadPath])

    #在桌面上创建packBagPath的文件夹

    subprocess.call(["mkdir","-p",packBagPath])

    #将PayLoadPath文件夹拷贝到packBagPath文件夹下

    subprocess.call(["cp","-r",PayLoadPath,packBagPath])

    #删除桌面的PayLoadPath文件夹

    subprocess.call(["rm","-rf",PayLoadPath])

    #切换到当前目录

    os.chdir(packBagPath)

    #压缩packBagPath文件夹下的PayLoadPath文件夹夹

    subprocess.call(["zip","-r","./Payload.zip","."])

    print ("\n*************** 打包成功 *********************\n")

    #将zip文件改名为ipa

    subprocess.call(["mv","payload.zip","Payload.ipa"])

    #删除payLoad文件夹

    subprocess.call(["rm","-rf","./Payload"])

 

 

#创建PayLoad文件夹

def mkdir(PayLoadPath):

    isExists = os.path.exists(PayLoadPath)

    if not isExists:

        os.makedirs(PayLoadPath)

        print(PayLoadPath + '创建成功')

        return True

    else:

        print (PayLoadPath + '目录已经存在')

        return False

 

 

if __name__ == '__main__':

    des = input("请输入更新的日志描述:")

    bulidIPA()

    uploadIPA('%s/Payload.ipa'%packBagPath)

    openDownloadUrl()

6.解压出Payload文件夹,.app就是我们的目标文件

7.在终端使用命令class-dump -H[.app文件路径] -o[输出文件夹路径],就会生成我们需要解析成.h文件有相对应的方法及属性

 8.混淆代码的方法通过shell脚本来实现,同时需要一个文档写入我们需要混淆的方法名与变量名

9.打开终端,cd到文件所在目录,使用touch命令 创建confuse.sh(混淆脚本) func.list(混淆方法,函数列表)

10.添加run script命令Targrt--build phases---new run script phase(把shell脚本运行)

11.生成混淆文件 就是说明混淆成功了

有些地方不能混淆:storyboard,init,系统方法等

 

posted @ 2018-08-03 13:55 tryFighting 阅读(...) 评论(...) 编辑 收藏