Last active
January 14, 2024 13:41
-
-
Save kmark/17f9a211bdca9f5a50ed to your computer and use it in GitHub Desktop.
Explores the current Android classpath
This file contains hidden or 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
try { | |
PathClassLoader pcl = (PathClassLoader) Thread.currentThread().getContextClassLoader(); | |
Field f = Class.forName("dalvik.system.BaseDexClassLoader").getDeclaredField("pathList"); | |
f.setAccessible(true); | |
Object dpl = f.get(pcl); | |
Class cls = Class.forName("dalvik.system.DexPathList"); | |
Field f2 = cls.getDeclaredField("dexElements"); | |
f2.setAccessible(true); | |
Object[] elements = (Object[])f2.get(dpl); | |
for(Object e : elements) { | |
cls = Class.forName("dalvik.system.DexPathList$Element"); | |
Field f3 = cls.getDeclaredField("dexFile"); | |
f3.setAccessible(true); | |
DexFile df = (DexFile)f3.get(e); | |
Enumeration<String> entries = df.entries(); | |
while(entries.hasMoreElements()) { | |
String entry = entries.nextElement(); | |
Log.e("OH NOEZ", "Entry: " + entry); | |
} | |
} | |
} catch (Exception ex) { | |
Log.wtf("WTF", ex); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment