学习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文件反编译:

更多相关文章

  1. 如何提高Android的性能
  2. android中圆角的bug
  3. 【移动安全高级篇】————7、APK 的自我保护
  4. Android的TextView/EditText使用CharacterStyle&SpannableString
  5. (转)Android中LocationManager的简单使用,获取当前位置
  6. 如何开发Android(安卓)Maps
  7. 箭头函数的基础使用
  8. NPM 和webpack 的基础使用
  9. Python list sort方法的具体使用

随机推荐

  1. 变量的类型转换方式 变量值传递与值引用
  2. js 中使用for或者forEach可以遍历数组,
  3. Vue组件的注册与挂载流程,实例演示; 2.
  4. 从入门到入土(八)RocketMQ的Consumer是如何
  5. 【小白笔记】Elastic Search使用Rest风格
  6. 创建线程那么容易,为什么非要让我使用线程
  7. Nginx SSL配置
  8. 面试官:什么是大事务?小林哥:就是 很大...的
  9. Nginx配置文件详解及多站点配置
  10. RocketMQ入门到入土(七 )为什么同一个消费