Skip to content

Instantly share code, notes, and snippets.

@obfusk
Created October 29, 2024 16:27
Show Gist options
  • Save obfusk/83ca1ada701a5d58458fff65c2ae74dd to your computer and use it in GitHub Desktop.
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
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