diff --git a/ClassySharkWS/src/com/google/classyshark/gui/panel/displayarea/doodles/Doodle.java b/ClassySharkWS/src/com/google/classyshark/gui/panel/displayarea/doodles/Doodle.java index 72686c68..536cc9d4 100644 --- a/ClassySharkWS/src/com/google/classyshark/gui/panel/displayarea/doodles/Doodle.java +++ b/ClassySharkWS/src/com/google/classyshark/gui/panel/displayarea/doodles/Doodle.java @@ -18,6 +18,6 @@ public class Doodle { public static String get() { - return SanFranBG.SHARKEY; + return SharkBG.SHARKEY; } } diff --git a/ClassySharkWS/src/com/google/classyshark/gui/panel/displayarea/doodles/SharkBG.java b/ClassySharkWS/src/com/google/classyshark/gui/panel/displayarea/doodles/SharkBG.java index 480483d2..4ff8bb56 100644 --- a/ClassySharkWS/src/com/google/classyshark/gui/panel/displayarea/doodles/SharkBG.java +++ b/ClassySharkWS/src/com/google/classyshark/gui/panel/displayarea/doodles/SharkBG.java @@ -46,6 +46,6 @@ class SharkBG { + " ii! '*YMWM, \n" + " I' \"YM\n" + "\n\n\n\thttp://www.retrojunkie.com/asciiart/animals/sharks.htm" - + "\n\n\n\tClassyShark ver. 6.0 powered by SilverGhost"; + + "\n\n\n\tClassyShark ver. 6.1 powered by SilverGhost"; } diff --git a/ClassySharkWS/src/com/google/classyshark/gui/panel/tree/FilesTree.java b/ClassySharkWS/src/com/google/classyshark/gui/panel/tree/FilesTree.java index 4a831ac8..5d98fdca 100644 --- a/ClassySharkWS/src/com/google/classyshark/gui/panel/tree/FilesTree.java +++ b/ClassySharkWS/src/com/google/classyshark/gui/panel/tree/FilesTree.java @@ -200,8 +200,7 @@ public void valueChanged(TreeSelectionEvent e) { DefaultMutableTreeNode defaultMutableTreeNode = (DefaultMutableTreeNode) selection; - if (selection.toString().startsWith("classes") && - selection.toString().endsWith(".dex")) { + if (selection.toString().endsWith(".dex")) { FilesTree.this.viewerController.onSelectedClassName( (String) defaultMutableTreeNode.getUserObject()); return; diff --git a/ClassySharkWS/src/com/google/classyshark/silverghost/contentreader/apk/ApkReader.java b/ClassySharkWS/src/com/google/classyshark/silverghost/contentreader/apk/ApkReader.java index cddb3cf3..e900c69a 100644 --- a/ClassySharkWS/src/com/google/classyshark/silverghost/contentreader/apk/ApkReader.java +++ b/ClassySharkWS/src/com/google/classyshark/silverghost/contentreader/apk/ApkReader.java @@ -75,6 +75,7 @@ private static void readClassNamesFromMultidex(File binaryArchiveFile, } if (zipEntry.getName().endsWith(".dex")) { + File file = File.createTempFile("classes" + dexIndex, "dex"); file.deleteOnExit(); @@ -89,7 +90,7 @@ private static void readClassNamesFromMultidex(File binaryArchiveFile, fos.close(); List classesAtDex = - DexReader.readClassNamesFromDex(binaryArchiveFile); + DexReader.readClassNamesFromDex(file); classNames.add("classes" + dexIndex + ".dex"); classNames.addAll(classesAtDex); @@ -100,6 +101,58 @@ private static void readClassNamesFromMultidex(File binaryArchiveFile, new ContentReader.Component(zipEntry.getName(), ContentReader.ARCHIVE_COMPONENT.NATIVE_LIBRARY)); } + + // Dynamic dex loading + if (zipEntry.getName().endsWith("jar") || zipEntry.getName().endsWith("zip")) { + File innerZip = File.createTempFile("inner_zip", "zip"); + innerZip.deleteOnExit(); + + FileOutputStream fos = + new FileOutputStream(innerZip); + byte[] bytes = new byte[1024]; + int length; + while ((length = zipFile.read(bytes)) >= 0) { + fos.write(bytes, 0, length); + } + + fos.close(); + + // so far we have a zip file + ZipInputStream fromInnerZip = new ZipInputStream(new FileInputStream( + innerZip)); + + ZipEntry innerZipEntry; + + while (true) { + innerZipEntry = fromInnerZip.getNextEntry(); + + if (innerZipEntry == null) { + break; + } + + if (innerZipEntry.getName().endsWith(".dex")) { + File tempDexFile = File.createTempFile("inner_zip_classes" + dexIndex, "dex"); + tempDexFile.deleteOnExit(); + + FileOutputStream fos1 = new FileOutputStream(tempDexFile); + byte[] bytes1 = new byte[1024]; + + while ((length = fromInnerZip.read(bytes1)) >= 0) { + fos1.write(bytes1, 0, length); + } + + fos1.close(); + + List classesAtDex = + DexReader.readClassNamesFromDex(tempDexFile); + + String name = zipEntry.getName() + "###" + innerZipEntry.getName(); + + classNames.add(name); + classNames.addAll(classesAtDex); + } + } + } } zipFile.close(); diff --git a/ClassySharkWS/src/com/google/classyshark/silverghost/translator/dex/DexInfoTranslator.java b/ClassySharkWS/src/com/google/classyshark/silverghost/translator/dex/DexInfoTranslator.java index dcbb4d90..7b36a42a 100644 --- a/ClassySharkWS/src/com/google/classyshark/silverghost/translator/dex/DexInfoTranslator.java +++ b/ClassySharkWS/src/com/google/classyshark/silverghost/translator/dex/DexInfoTranslator.java @@ -139,6 +139,55 @@ private static File extractClassesDex(String dexName, File apkFile, DexInfoTrans break; } } + + if (zipEntry.getName().endsWith("jar") || zipEntry.getName().endsWith("zip")) { + + File innerZip = File.createTempFile("inner_zip", "zip"); + innerZip.deleteOnExit(); + + FileOutputStream fos = + new FileOutputStream(innerZip); + byte[] bytes = new byte[1024]; + int length; + while ((length = zipFile.read(bytes)) >= 0) { + fos.write(bytes, 0, length); + } + + fos.close(); + + // so far we have a zip file + ZipInputStream fromInnerZip = new ZipInputStream(new FileInputStream( + innerZip)); + + ZipEntry innerZipEntry; + + while (true) { + innerZipEntry = fromInnerZip.getNextEntry(); + + if (innerZipEntry == null) { + fromInnerZip.close(); + break; + } + + if (innerZipEntry.getName().endsWith(".dex")) { + file = File.createTempFile("classes_innerzip", "dex"); + FileOutputStream fos1 = new FileOutputStream(file); + byte[] bytes1 = new byte[1024]; + + while ((length = fromInnerZip.read(bytes1)) >= 0) { + fos1.write(bytes1, 0, length); + } + + fos1.close(); + + if (dexName.startsWith(zipEntry.getName())) { + diTranslator.index = 99; + zipFile.close(); + return file; + } + } + } + } } zipFile.close(); } catch (Exception e) { diff --git a/ClassySharkWS/src/com/google/classyshark/silverghost/translator/java/dex/Multidex.java b/ClassySharkWS/src/com/google/classyshark/silverghost/translator/java/dex/Multidex.java index c06bdd7a..bd5e3ebe 100644 --- a/ClassySharkWS/src/com/google/classyshark/silverghost/translator/java/dex/Multidex.java +++ b/ClassySharkWS/src/com/google/classyshark/silverghost/translator/java/dex/Multidex.java @@ -29,6 +29,8 @@ private Multidex() { } public static File extractClassesDexWithClass(String className, File apkFile) { + + // TODO need to delete this file File file = new File("classes.dex"); ZipInputStream zipFile; try { @@ -66,6 +68,57 @@ public static File extractClassesDexWithClass(String className, File apkFile) { break; } } + + if (zipEntry.getName().endsWith("jar") || zipEntry.getName().endsWith("zip")) { + + File innerZip = File.createTempFile("inner_zip", "zip"); + innerZip.deleteOnExit(); + + FileOutputStream fos = + new FileOutputStream(innerZip); + byte[] bytes = new byte[1024]; + int length; + while ((length = zipFile.read(bytes)) >= 0) { + fos.write(bytes, 0, length); + } + + fos.close(); + + // so far we have a zip file + ZipInputStream fromInnerZip = new ZipInputStream(new FileInputStream( + innerZip)); + + ZipEntry innerZipEntry; + + while (true) { + innerZipEntry = fromInnerZip.getNextEntry(); + + if (innerZipEntry == null) { + fromInnerZip.close(); + break; + } + + if (innerZipEntry.getName().endsWith(".dex")) { + file = File.createTempFile("classes_innerzip", "dex"); + FileOutputStream fos1 = new FileOutputStream(file); + byte[] bytes1 = new byte[1024]; + + while ((length = fromInnerZip.read(bytes1)) >= 0) { + fos1.write(bytes1, 0, length); + } + + fos1.close(); + + List classNamesInDex = + DexReader.readClassNamesFromDex(file); + if (classNamesInDex.contains(className)) { + fromInnerZip.close(); + zipFile.close(); + return file; + } + } + } + } } zipFile.close(); } catch (Exception e) {