批量反编译Android(安卓)XML文件Python脚本
16lz
2022-03-20
学习Android的过程中,难免有时候会反编译别人的APK文件,而解压APK后的XML文件数量众多,如果要逐个地敲命令来反编译的话未免太麻烦了点,于是写了个Python脚本来完成批量反编译的工作,现把代码贴上:
'''利用AXMLPrinter2.jar反编译Android的xml文件使用:decompile.py pathpath:文件路径,如:F:/Android/apk@author: Administrator'''import sysimport osdef decompile(pathname): for root,dirs,files in os.walk(pathname): for file in files: if file.endswith('.xml'): newname = file[:len(file)-3]+"txt" os.chdir(root) command = 'java -jar %s %s > %s'%(pathname+'AXMLPrinter2.jar',file,newname) if(os.system(command) == 0): print('成功:',command) os.remove(file) os.rename(newname, file) else: print('失败:',command) if(len(sys.argv)<2): print("缺少参数,示例:decompile.py F:/apk/")else: path = sys.argv[1] if(not(path.endswith('/') | path.endswith('\\'))): path += os.sep print(path) decompile(path)
注:这里用到的反编译XML文件的工具是AXMLPrinter2.jar,使用时将AXMLPrinter2.jar放到你要反编译XML文件的目录下,如,要反编译 F:\360Downloads\Apk\mojitianqi\ 目录下及其子目录下的所有xml文件,只需将AXMLPrinter.jar放入F:\360Downloads\Apk\mojitianqi\ 目录下,然后执行decompile.py F:\360Downloads\Apk\mojitianqi 即可将该目录及其子目录下的所有XML文件反编译:
更多相关文章
- 如何提高Android的性能
- android中圆角的bug
- 【移动安全高级篇】————7、APK 的自我保护
- Android的TextView/EditText使用CharacterStyle&SpannableString
- (转)Android中LocationManager的简单使用,获取当前位置
- 如何开发Android(安卓)Maps
- 箭头函数的基础使用
- NPM 和webpack 的基础使用
- Python list sort方法的具体使用