iOS 代碼混淆的簡單使用

1.工具下載  http://stevenygard.com/projects/class-dump/  選擇dmg安裝包python

2.打開終端輸入:open/usr/local/binweb

3.shell

4.修改權限在終端鍵入: sudo chmod 777 /usr/local/bin/class-dumpapi

5.使用Python3自動發包工具解壓包後綴爲zipapp

Python腳本以下(上傳蒲公英腳本能夠忽略)iphone

#!/usr/bin/env python函數

#coding=utf-8 工具

import ospost

import requestsui

import webbrowser

import subprocess

import shutil

 

'''

使用注意事項:該腳本基於python3.6

一、將工程的編譯設備選成 Gemeric iOS Device

二、command + B編譯

三、執行腳本文件

//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,系統方法等

相關文章
相關標籤/搜索