diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 2fea284..c4be634 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -15,9 +15,6 @@ compileKotlin.kotlinOptions { repositories { mavenCentral() - maven { - url = uri("http://repository-dex2jar.forge.cloudbees.com/release/") - } } dependencies { @@ -45,7 +42,7 @@ dependencies { implementation("com.squareup.retrofit2:adapter-rxjava:$retrofit_version") - + // reactivex implementation("io.reactivex:rxjava:1.3.8") // implementation("io.reactivex:rxandroid:1.2.1") // implementation("com.jakewharton.rxrelay:rxrelay:1.2.0") @@ -64,7 +61,7 @@ dependencies { implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion") // dex2jar - implementation("com.googlecode.d2j:dex-reader:2.0") + implementation(fileTree("../lib/dex2jar/")) testImplementation("org.jetbrains.kotlin:kotlin-test") diff --git a/app/src/main/java/ir/armor/tachidesk/APKExtractor.java b/app/src/main/java/ir/armor/tachidesk/APKExtractor.java index 8aa76d6..9c848f0 100644 --- a/app/src/main/java/ir/armor/tachidesk/APKExtractor.java +++ b/app/src/main/java/ir/armor/tachidesk/APKExtractor.java @@ -8,8 +8,11 @@ import org.xml.sax.InputSource; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import java.io.*; +import java.nio.file.Files; +import java.nio.file.Paths; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; +import java.util.zip.ZipInputStream; class APKExtractor { // decompressXML -- Parse the 'compressed' binary form of Android XML docs @@ -203,30 +206,29 @@ class APKExtractor { } public static String extract_dex_and_read_className(String filePath, String dexPath) throws IOException { - InputStream is = null; ZipFile zip = null; zip = new ZipFile(filePath); ZipEntry androidManifest = zip.getEntry("AndroidManifest.xml"); ZipEntry classesDex = zip.getEntry("classes.dex"); - is = zip.getInputStream(androidManifest); // write dex file InputStream dexStream = zip.getInputStream(classesDex); - byte[] dexBuffer = new byte[dexStream.available()]; - FileOutputStream dexOs = new FileOutputStream(new File(dexPath)); - dexOs.write(dexBuffer); - dexOs.close(); - - - byte[] buf = new byte[10240]; - int bytesRead = is.read(buf); - - is.close(); - if (zip != null) { - zip.close(); + try (OutputStream os = Files.newOutputStream(Paths.get(dexPath))) { + byte[] buffer = new byte[1024]; + int len; + while ((len = dexStream.read(buffer)) > 0) { + os.write(buffer, 0, len); + } } + // read xml file + InputStream is = zip.getInputStream(androidManifest); + byte[] buf = new byte[1024000]; // 100 kb + is.read(buf); + is.close(); + zip.close(); + String xml = APKExtractor.decompressXML(buf); try { Document xmlDoc = loadXMLFromString(xml); diff --git a/app/src/main/kotlin/ir/armor/tachidesk/Main.kt b/app/src/main/kotlin/ir/armor/tachidesk/Main.kt index 7c3e4fe..0450978 100644 --- a/app/src/main/kotlin/ir/armor/tachidesk/Main.kt +++ b/app/src/main/kotlin/ir/armor/tachidesk/Main.kt @@ -1,5 +1,9 @@ package ir.armor.tachidesk +import com.googlecode.d2j.dex.Dex2jar +import com.googlecode.d2j.reader.DexFileReader +import com.googlecode.dex2jar.tools.Dex2jarCmd + class Main { companion object { @JvmStatic @@ -50,7 +54,12 @@ class Main { val apk = "/tmp/tachidesk/tachiyomi-en.killsixbilliondemons-v1.2.3.apk" val dex = "/tmp/tachidesk/tachiyomi-en.killsixbilliondemons-v1.2.3.dex" + val jar = "/tmp/tachidesk/tachiyomi-en.killsixbilliondemons-v1.2.3.jar" val pkg = APKExtractor.extract_dex_and_read_className(apk, dex) + + Dex2jarCmd.main(dex, "-o", jar, "--force") + + } } } diff --git a/lib/dex2jar/antlr-runtime-3.5.jar b/lib/dex2jar/antlr-runtime-3.5.jar new file mode 100644 index 0000000..a8b5969 Binary files /dev/null and b/lib/dex2jar/antlr-runtime-3.5.jar differ diff --git a/lib/dex2jar/asm-debug-all-4.1.jar b/lib/dex2jar/asm-debug-all-4.1.jar new file mode 100644 index 0000000..4133d82 Binary files /dev/null and b/lib/dex2jar/asm-debug-all-4.1.jar differ diff --git a/lib/dex2jar/d2j-base-cmd-2.0.jar b/lib/dex2jar/d2j-base-cmd-2.0.jar new file mode 100644 index 0000000..60c9fff Binary files /dev/null and b/lib/dex2jar/d2j-base-cmd-2.0.jar differ diff --git a/lib/dex2jar/d2j-jasmin-2.0.jar b/lib/dex2jar/d2j-jasmin-2.0.jar new file mode 100644 index 0000000..de745bd Binary files /dev/null and b/lib/dex2jar/d2j-jasmin-2.0.jar differ diff --git a/lib/dex2jar/d2j-smali-2.0.jar b/lib/dex2jar/d2j-smali-2.0.jar new file mode 100644 index 0000000..c6d2647 Binary files /dev/null and b/lib/dex2jar/d2j-smali-2.0.jar differ diff --git a/lib/dex2jar/dex-ir-2.0.jar b/lib/dex2jar/dex-ir-2.0.jar new file mode 100644 index 0000000..24b02e7 Binary files /dev/null and b/lib/dex2jar/dex-ir-2.0.jar differ diff --git a/lib/dex2jar/dex-reader-2.0.jar b/lib/dex2jar/dex-reader-2.0.jar new file mode 100644 index 0000000..0a648b8 Binary files /dev/null and b/lib/dex2jar/dex-reader-2.0.jar differ diff --git a/lib/dex2jar/dex-reader-api-2.0.jar b/lib/dex2jar/dex-reader-api-2.0.jar new file mode 100644 index 0000000..d54ab99 Binary files /dev/null and b/lib/dex2jar/dex-reader-api-2.0.jar differ diff --git a/lib/dex2jar/dex-tools-2.0.jar b/lib/dex2jar/dex-tools-2.0.jar new file mode 100644 index 0000000..49a5cb7 Binary files /dev/null and b/lib/dex2jar/dex-tools-2.0.jar differ diff --git a/lib/dex2jar/dex-translator-2.0.jar b/lib/dex2jar/dex-translator-2.0.jar new file mode 100644 index 0000000..e322e7f Binary files /dev/null and b/lib/dex2jar/dex-translator-2.0.jar differ diff --git a/lib/dex2jar/dex-writer-2.0.jar b/lib/dex2jar/dex-writer-2.0.jar new file mode 100644 index 0000000..ce9b95a Binary files /dev/null and b/lib/dex2jar/dex-writer-2.0.jar differ diff --git a/lib/dex2jar/dx-1.7.jar b/lib/dex2jar/dx-1.7.jar new file mode 100644 index 0000000..481a00e Binary files /dev/null and b/lib/dex2jar/dx-1.7.jar differ