前言
最近蘋果的熱更新和私有庫問題檢查的更嚴了,如果應(yīng)用被拒悍及,蘋果在拒絕信中會說到使用strings
/otool
/nm
命令進行自查镣煮,所以總結(jié)了一些命令,方便查找和定位文件內(nèi)容相關(guān)信息墩崩。
1、grep
作用:判斷是否包含字符串
-
使用示例:
grep -r "xxx” path
檢查是否包含(weixin)字符串:
matches
表示包含侯勉。
2鹦筹、strings
作用:find the printable strings in a object, or other binary, file
-
使用示例:
strings a.out | grep hello
//檢查 a.out 文件中含有 hello 字符串的字節(jié)序列 -
檢查二進制是否含有關(guān)鍵詞的庫(比如檢查私有庫):
strings a.out | grep hello.png
- 更多使用說明
man strings
3、otool
作用: object file displaying tool. (針對目標文件的展示工具址貌,用來發(fā)現(xiàn)應(yīng)用中使用到了哪些系統(tǒng)庫铐拐,調(diào)用了其中哪些方法,使用了庫中哪些對象及屬性)
-
使用示例:
otool -L path
//查看可執(zhí)行程序都鏈接了那些庫otool -L path | grep "xxx"
//篩選是否鏈接了xxx庫otool -D path
//查看支持的架構(gòu)otool -ov path
//output the Objective-C class structures and their defined methods.(輸出Object-C類結(jié)構(gòu)以及定義的方法) -
查看該應(yīng)用是否砸殼:
otool -l path | grep crypt
//cryptid 0(砸殼) 1(未砸殼)
otool -l path | grep crypt.png 更多用法
man otool
4练对、nm
作用:display name list (symbol table). (顯示符號表)
-
使用示例:
nm path
//得到Mach-O中的程序符號表nm -nm path
//目標文件的所有符號
nm -nm path.png符號表中標示為 undefined遍蟋,意思是目標文件引用了類_XXX(XXX庫),不過這并沒有實現(xiàn)它螟凭。
更多用法
man nm
5虚青、file
作用:determine file type. (判斷文件類型)
-
使用示例:
file path
判斷.a/framework是靜態(tài)庫還是動態(tài)庫:
靜態(tài)庫:
file path - static Lib.png
動態(tài)庫:
file path - dynamically Lib.png
6、lipo
作用:create or operate on universal files(創(chuàng)建或處理通用文件的工具)
-
使用示例:
lipo -info 'file path'
// 判斷靜態(tài)庫所支持的平臺 - i386 armv7 armv7s x86_64 arm64lipo -remove i386 origin_xxx.a -output op_xxx.a
// 刪除靜態(tài)庫包括的i386平臺lipo -thin i386 origin_xxx.a -output op_xxx.a
// 拆分靜態(tài)庫螺男,只保留i386 CPU架構(gòu)lipo -create device_xxx.a simulator_xxx.a -output universal_xxx.a
//對真機或者模擬器分別打出 .a 文件合并
參考閱讀
- "nm tool" Xcode manual page
- iOS-private-api-scanner/iOS私有API掃描工作總結(jié)· mrmign/iOS-private-api-scanner
- iOS-private-api-checker蘋果iOS私有API檢查工具
- iOS開發(fā)-如何判斷framework是動態(tài)庫或靜態(tài)庫以及framework靜態(tài)庫轉(zhuǎn).a靜態(tài)庫
注:本文首發(fā)于 iHTCboy's blog棒厘,如若轉(zhuǎn)載纵穿,請注明來源。