mirror of
https://github.com/NekoX-Dev/NekoX.git
synced 2024-11-22 06:15:17 +01:00
update apkdiff.py apkfrombundle.py
This commit is contained in:
parent
17283cea01
commit
2628a58147
@ -3,12 +3,12 @@ from zipfile import ZipFile
|
||||
|
||||
def compareFiles(first, second):
|
||||
while True:
|
||||
firstBytes = first.read(4096);
|
||||
secondBytes = second.read(4096);
|
||||
firstBytes = first.read(4096)
|
||||
secondBytes = second.read(4096)
|
||||
if firstBytes != secondBytes:
|
||||
return False
|
||||
|
||||
if firstBytes == b"":
|
||||
if firstBytes == b"" and secondBytes == b"":
|
||||
break
|
||||
|
||||
return True
|
||||
|
@ -2,31 +2,31 @@ import sys
|
||||
from zipfile import ZipFile
|
||||
|
||||
def compareFiles(first, second):
|
||||
while True:
|
||||
firstBytes = first.read(4096);
|
||||
secondBytes = second.read(4096);
|
||||
if firstBytes != secondBytes:
|
||||
return False
|
||||
while True:
|
||||
firstBytes = first.read(4096)
|
||||
secondBytes = second.read(4096)
|
||||
if firstBytes != secondBytes:
|
||||
return False
|
||||
|
||||
if firstBytes != b"" or secondBytes != b"":
|
||||
break
|
||||
if firstBytes == b"" and secondBytes == b"":
|
||||
break
|
||||
|
||||
return True
|
||||
|
||||
return True
|
||||
|
||||
def remove_prefix(text, prefix):
|
||||
if text.startswith(prefix):
|
||||
return text[len(prefix):]
|
||||
return text
|
||||
|
||||
|
||||
def compareApkFromBundle(bundle, apk):
|
||||
FILES_TO_IGNORE = ["META-INF/MANIFEST.MF", "META-INF/CERT.RSA", "META-INF/CERT.SF", "resources.arsc"]
|
||||
FILES_TO_IGNORE = ["resources.arsc", "stamp-cert-sha256"]
|
||||
|
||||
apkZip = ZipFile(apk, 'r')
|
||||
bundleZip = ZipFile(bundle, 'r')
|
||||
|
||||
firstList = list(filter(lambda info: info.filename not in FILES_TO_IGNORE, apkZip.infolist()))
|
||||
secondList = list(filter(lambda secondInfo: secondInfo.filename not in FILES_TO_IGNORE, bundleZip.infolist()))
|
||||
|
||||
|
||||
for apkInfo in firstList:
|
||||
if (apkInfo.filename.startswith("META-INF/")):
|
||||
continue
|
||||
@ -56,16 +56,16 @@ def compareApkFromBundle(bundle, apk):
|
||||
if found == False:
|
||||
print("file %s not found in APK" % apkInfo.filename)
|
||||
return False
|
||||
|
||||
|
||||
return True
|
||||
|
||||
if __name__ == '__main__':
|
||||
if len(sys.argv) != 3:
|
||||
print("Usage: apkfrombundle <pathToBundle> <pathToApk>")
|
||||
sys.exit(1)
|
||||
|
||||
if len(sys.argv) != 3:
|
||||
print("Usage: apkfrombundle <pathToBundle> <pathToApk>")
|
||||
sys.exit(1)
|
||||
|
||||
if sys.argv[1] == sys.argv[2] or compareApkFromBundle(sys.argv[1], sys.argv[2]) == True:
|
||||
print("APKs are from bundle!")
|
||||
else:
|
||||
print("APKs are different!")
|
||||
|
||||
if sys.argv[1] == sys.argv[2] or compareApkFromBundle(sys.argv[1], sys.argv[2]) == True:
|
||||
print("APK from bundle!")
|
||||
else:
|
||||
print("APK has difference!")
|
||||
|
Loading…
Reference in New Issue
Block a user