天天看點

android 反編譯,android反編譯之路

一、需要的工具

apktool:反編譯APK檔案,得到classes.dex檔案,同時也能擷取到資源檔案以及布局檔案。

dex2jar:将反編譯後的classes.dex檔案轉化為.jar檔案。

jd-gui:用于将.jar檔案轉換成java代碼。

二、反編譯步驟

第一步:使用apktool工具對APK進行反編譯

android 反編譯,android反編譯之路

image

2. 把下載下傳好的apktool腳本和apktool.jar檔案移動到 /usr/local/bin 檔案夾下

android 反編譯,android反編譯之路

image

android 反編譯,android反編譯之路

image

android 反編譯,android反編譯之路

image

3. 使用指令chmod +x 分别對apktool和apktool.jar檔案進行提權

//先進入到/usr/local/bin檔案夾下

cd /usr/local/bin

chmod +x apktool

chmod +x apktool.jar

4. 測試是否成功,終端輸入apktool,若成功,如下圖

android 反編譯,android反編譯之路

image

5. 運作apoktool腳本進行反編譯

①. 把你需要反編譯的apk檔案也複制到 /usr/local/bin 檔案夾下,確定apktool、apktool.jar以及apk檔案都在/usr/local/bin目錄下

②. 終端輸入指令 apktool d xxx.apk回車,等待執行完畢

//如果目前已在/usr/local/bin 目錄下,忽略此步

cd /usr/local/bin

//開始反編譯目标APK檔案

apktool d xxx.apk

android 反編譯,android反編譯之路

image

③. 執行完畢後目錄下會生成反編譯apk的對應檔案夾

android 反編譯,android反編譯之路

image

但是我們在反編譯apk後的檔案夾裡并沒有看到classes.dex檔案,這時候就需要在上述指令行添加-s,表示禁止将dex檔案解碼成smali

apktool d -s xxx.apk

android 反編譯,android反編譯之路

image

android 反編譯,android反編譯之路

image

第二步:使用dex2jar工具把classes.dex檔案轉化成.jar檔案

2. 進入到你解壓後的dex2jar檔案夾下(根據你的實際情況檔案夾位置不一樣),如:

cd Downloads/dex2jar-2.0

3. 把classes.dex檔案複制到解壓後的dex2jar檔案夾下,終端執行指令sh d2j-dex2jar.sh classes.dex

sh d2j-dex2jar.sh classes.dex

android 反編譯,android反編譯之路

image

3. 執行完畢後,會在檔案夾下生成一個.jar檔案,裡面就是java源碼

android 反編譯,android反編譯之路

image

第三步:使用JD-GUI軟體檢視jar包下的java源碼

2. 打開安裝好的JD-GUI,直接把第二步生成的.jar檔案拖進去,就能看到反編譯出來的java源碼了

android 反編譯,android反編譯之路

image

android 反編譯,android反編譯之路

image

作者:AIllll

連結:https://www.jianshu.com/p/3a305f32c4a3

來源:簡書

著作權歸作者所有。商業轉載請聯系作者獲得授權,非商業轉載請注明出處。