Created
October 29, 2024 16:27
-
-
Save obfusk/83ca1ada701a5d58458fff65c2ae74dd to your computer and use it in GitHub Desktop.
python script to search for specific class in r8 dumps | https://issuetracker.google.com/issues/366412380
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
import glob | |
import os | |
import sys | |
import tempfile | |
import zipfile | |
classname_str, *search_dirs = sys.argv[1:] | |
classname_bytes = classname_str.encode() | |
for search_dir in search_dirs: | |
print(f"dir={search_dir}") | |
for file in sorted(glob.glob(os.path.join(search_dir, "*.zip"))): | |
with tempfile.TemporaryDirectory() as tmpdir: | |
jar = os.path.join(tmpdir, "program.jar") | |
with zipfile.ZipFile(file) as zf: | |
zf.extract("program.jar", tmpdir) | |
with zipfile.ZipFile(jar) as zf: | |
for info in zf.infolist(): | |
if info.filename.endswith(".dex"): | |
if classname_bytes in zf.read(info.filename): | |
print(f"file={file} dex={info.filename}") | |
elif info.filename.endswith(".class"): | |
if classname_str in info.filename: | |
print(f"file={file} class={info.filename}") | |
else: | |
print(f"file={file} entry={info.filename}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment