apktool + eclipse 動態調試APK

來源:互聯網
上載者:User

標籤:digest   結合   遠程   sub   enter   2.0   ref   python   tor   

用了會AndBug,儘管挺強大的可是作為習慣了OD。EDB作為動態調試工具的人,自然有些不習慣,於是乎尋求新的動態調試解決方式。但大多數都是NetBeans + apktool。想著還得多下一個IDE就各種煩躁,還是去尋求Eclipse的組合吧。


http://code.google.com/p/android-apktool/wiki/SmaliDebugging

找到apktool的官網,看到有能夠實現動態調試。

能夠在反編譯和回編的時候通過設定參數給目標APK中的manifest檔案裡增加android:debuggable="true",,同一時候為了結合Eclipse。之後也會自己主動把.smali尾碼改為了.java。這樣就能夠用來調試了。

當然,別忘了回編後還須要簽名等。於是自己寫了個簡易的指令碼:

‘‘‘Created on 2014-5-28@author: Xbalien‘‘‘import osimport sysimport subprocessclass APKdebugger(object):    def unpackaging(self, apk_path):        print ‘Start Unpackaging...‘        subprocess.call([‘apktool_2.0.0b9.jar‘,‘d‘,‘-d‘,apk_path],shell=True)    def packaging(self, file_path):        print ‘Start Packaging...‘        subprocess.call([‘apktool_2.0.0b9.jar‘,‘b‘,‘-d‘,file_path],shell=True)    def signer(self, unsigned_path):        print ‘Start Signing...‘        signer_comm=[‘jarsigner‘,‘-verbose‘,‘-keystore‘,‘key‘,‘-digestalg‘,‘SHA1‘,‘-sigalg‘, ‘MD5withRSA‘ ,‘-signedjar‘,‘signed.apk‘]        signer_comm += [unsigned_path,‘key‘]        p = subprocess.Popen(signer_comm,stdin=subprocess.PIPE,stdout = subprocess.PIPE, stderr = subprocess.PIPE, shell = True)        p.communicate(input=‘key123456‘)        p.wait()    def zipalign(self, outapk_path):        subprocess.call([‘zipalign‘,‘-v‘,‘4‘,‘signed.apk‘,outapk_path],shell=True)if __name__ == ‘__main__‘:    if len(sys.argv) >1:        print ‘Start Create APKdebugger...‘        apk_path = sys.argv[1]        file_path = apk_path[:-4]        unsigned_path = ‘./‘+file_path+‘/dist/‘+apk_path        outapk_path = file_path+‘//‘+apk_path        apk_debugger = APKdebugger()        apk_debugger.unpackaging(apk_path)        apk_debugger.packaging(file_path)           apk_debugger.signer(unsigned_path)        apk_debugger.zipalign(outapk_path)    else: print ‘useage:main.py apk_name‘

指令碼處理好之後。apk也就產生了。之後將其安裝到手機上。點擊執行。這時候能夠通過DDMS查看



這時候開啟Eclipse,建立javaproject。增加源碼(反編譯代碼smali檔案夾)



之後我們能夠開啟個檔案下斷點


接著設定調試設定檔,選定遠端偵錯以及相應port就可以開始調試


之後點擊debug。這時候能夠在手機上開始了點擊。到對應斷點的時候就斷下來了


之後就能夠愉悅的單步調試了

apktool + eclipse 動態調試APK

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.