学习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 XML文件Python脚本_第1张图片

更多相关文章

  1. android文件管理实现源码
  2. Android 最简单的SD卡文件遍历程序
  3. “AndroidManifest.xml 系统找不到指定的文件”解决方案
  4. Android资源文件mk的格式
  5. Android获取文件的MD5值
  6. Android 文件读写工具类
  7. Android使用Retrofit上传单个文件以及多个文件
  8. Android检测版本更新(读取apk配置文件中的版本信息)

随机推荐

  1. Android 用户界面(User Interface)概要
  2. android之模拟手机助手下载
  3. 报错记录-The option ‘android.enableUn
  4. android 如何判断开机完成
  5. Java中的WeakReference 和 SoftReference
  6. Android Studio 更换debug.keystore问题
  7. Android 4.0 Launcher2源码分析——导入e
  8. Android RxJava:一步步带你源码分析 RxJav
  9. Android Telephony启动过程源码分析
  10. Android中Handler的简析