Created
September 21, 2020 17:21
-
-
Save mimi89999/98df99d9fbbbeb6bf62f82c8bfe9bb84 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sb_data = b'' | |
with open(signed_apk, 'rb') as unsigned: | |
unsigned.seek(-6, 2) # From file end, 2 byte comment length, 4 byte offset of CD | |
cd_start = 0 | |
for i in reversed(unsigned.read(4)): | |
cd_start *= (0xff + 1) | |
cd_start += i | |
print('cd_start:', cd_start) | |
unsigned.seek(cd_start - 16 - 8, 0) # 16 byte magic, uint64 size | |
sb_size = 0 | |
for i in reversed(unsigned.read(8)): | |
sb_size *= (0xff + 1) | |
sb_size += i | |
print('sb_size:', sb_size) | |
sb_start = cd_start - sb_size - 8 # sb_size excludes first sb_size field | |
print('sb_start:', sb_start) | |
unsigned.seek(sb_start, 0) | |
sb_data = unsigned.read(sb_size + 8) | |
print(sb_data) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment