MAC上使用apktool進行反編譯

本文參考http://blog.csdn.net/hanhailong726188/article/details/42368295

一、準備工作

工具準備,下載工具

1.apktool
2.dex2jar
3.jd-gui
下載地址:戳我

安裝工具

apktool安裝

解壓下載的文件,進入apktool文件夾中,可以看到apktool,apltool.jar和aapt三個文件,將這三個文件拷貝到/usr/local/bin中

ps: 操作/usr/local/bin文件夾需要權限許可,要輸入密碼
由於/usr/local/bin屬於隱藏保護的,磁盤上看不到,除了通過命令行進行復制操作外,我們也可以通過一下方式用Finder進行查看

使用Finder進行操作

打開Finder,點擊菜單欄上的前往>前往文件夾,然後在彈出框內輸入/usr/local/bin,就能進入該文件夾了,然後將上面所述的三個文件拷貝到bin文件夾中

使用命令行進行操作

1.打開終端,輸入命令cd /usr/local/bin,進入bin文件夾,此操作需要輸入密碼進行授權
2.輸入命令cd xxx/xxx/apltool,進入下載的apktool文件夾中
3.輸入命令sudo cp apltool apktool.jar aapt /usr/local/bin,講上面所述的三個文件拷貝到bin文件夾中

判斷apktool是否安裝成功

打開終端,執行apktool命令,看是否出現以下數據,如果出現,說麼安裝成功

Apktool v2.0.0-RC2 - a tool for reengineering Android apk files
with smali v2.0.3 and baksmali v2.0.3
Copyright 2010 Ryszard Wiśniewski <[email protected]>
Updated by Connor Tumbleson <[email protected]>

usage: apktool
 -advance,--advanced   prints advance information.
 -version,--version    prints the version then exits
usage: apktool if|install-framework [options] <framework.apk>
 -p,--frame-path <dir>   Stores framework files into <dir>.
 -t,--tag <tag>          Tag frameworks using <tag>.
usage: apktool d[ecode] [options] <file_apk>
 -f,--force              Force delete destination directory.
 -o,--output <dir>       The name of folder that gets written. Default is apk.out
 -p,--frame-path <dir>   Uses framework files located in <dir>.
 -r,--no-res             Do not decode resources.
 -s,--no-src             Do not decode sources.
 -t,--frame-tag <tag>    Uses framework files tagged by <tag>.
usage: apktool b[uild] [options] <app_path>
 -f,--force-all          Skip changes detection and build all files.
 -o,--output <dir>       The name of apk that gets written. Default is dist/name.apk
 -p,--frame-path <dir>   Uses framework files located in <dir>.

For additional info, see: http://code.google.com/p/android-apktool/ 
For smali/baksmali info, see: http://code.google.com/p/smali/

dex2jar不需要安裝

jd-gui安裝

點擊jd-gui-0.2.7.osx.i686.dmg運行即可

二、使用工具進行反編譯

使用apktool獲取資源文件

1.打開終端,輸入命令cd xxxx/xxxx ,進入所要反編譯的apk文件夾
2.輸入命令apktool d xxxx.apk,進行反編譯apk,結束後我們會發現在該文件夾下回出現一個新的文件夾,名稱和apk的名稱一樣,打開后里面有AndroidManifest.xml文件和res文件夾,裏面爲反編譯後的資源文件

使用dex2jar,jd-gui反編譯classes.dex文件

1.將所要反編譯的apk重命名,修改後綴爲zip,並解壓,我們會發現解壓後的文件夾中有個classes.dex文件,獲取該文件的路徑
2.打開終端,輸入命令cd xxx/xxx/dex2jar,進入下載的dex2jar文件夾中
3.輸入命令sh dextool.sh xxx/xxx/xxx/classes.dex,進行反編譯classes.dex文件,操作完成後,會在dex2jar文件夾中生成一個classes-dex2jar.jar文件
4.打開jd-gui文件,將classes-dex2jar.jar拖入jd-gui界面上,就能夠看到java文件了

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章