批量反编译Android XML文件Python脚本
16lz
2021-01-23
学习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 最简单的SD卡文件遍历程序
- “AndroidManifest.xml 系统找不到指定的文件”解决方案
- Android资源文件mk的格式
- Android获取文件的MD5值
- Android 文件读写工具类
- Android使用Retrofit上传单个文件以及多个文件
- Android检测版本更新(读取apk配置文件中的版本信息)