背景
由于某些情况下需要重打包App,如添加android:debuggable=“true”,注入smali代码等,本文主要探讨重打包的过程及其难点解决方案,比如签名绕过等
技术解析
流程图
修改AndroidManifest原理分析
由于随意修改资源强行绕过回编译过程,因此可能导致app无法正常运行,此时的思路是,回编译后的apk中的AndroidManifest.xml已经是二进制形式,因此如果直接替换原始APK中的xml即可正常绕过。
- 资源修正思路: 对于出现错误的item,直接脚本批量删除即可
zipalign -p -f -v 4 xx.apk output_unsigned.apk
批量处理错误脚本
import re
import xml.etree.ElementTree as ET
class XmlUtils(object):
"""docstring for XmlUtils"""
def __init__(self):
super(XmlUtils, self).__init__()
def config(self,xmlPath,ns=None):
self.path = xmlPath
self.et = ET.parse(xmlPath)
self.root = self.et.getroot()
for pre,uri in ns.items():
try:
ET.register_namespace(pre,uri)
except:
pass
def delAttrib(self,node,b):
try:
del node.attrib[b]
except Exception as e:
pass
if len(node) > 0:
for child in node:
self.delAttrib(child,b)
def getDealKeys(self,node,keys,errorAttrib):
for x in node.attrib.keys():
for attr in errorAttrib:
if attr in x and x not in keys:
keys.append(x)
if len(node) ><