static void UnpackJar(UnpackedApp app) { string jarName = Path.GetFileNameWithoutExtension(app.OriginalJarPath); string targetPath = string.Format(@"TempSmali\Unpacked\{0}\", jarName); targetPath = Path.GetFullPath(targetPath); Console.WriteLine(" Unpacking: {0} to: {1}", app.OriginalJarPath, targetPath); Console.WriteLine(); var processInfo = new ProcessStartInfo(Path.GetFullPath("apktool.bat"), string.Format(@"d -f -o {0} {1}", targetPath, app.OriginalJarPath)) { //CreateNoWindow = true, UseShellExecute = false, }; Process.Start(processInfo).WaitForExit(); Console.WriteLine(); app.UnpackedPath = targetPath; foreach (var smaliFolder in Directory.EnumerateDirectories(targetPath, "smali*")) { Console.WriteLine(" Found Smali: {0}", smaliFolder); app.BaksmailedDexPaths.Add(smaliFolder); } }
static void RunBaksmali(UnpackedApp app, string dexPath) { string jarName = Path.GetFileNameWithoutExtension(app.OriginalJarPath); string dexName = Path.GetFileNameWithoutExtension(dexPath); string targetPath = string.Format(@"TempSmali\Baksmalied\{0}\{1}\", jarName, dexName); if (singleDex) { targetPath = string.Format(@"TempSmali\Baksmalied\SingleDex\"); } targetPath = Path.GetFullPath(targetPath); Console.WriteLine(" Baksmaling: {0} to: {1}", dexPath, targetPath); Directory.CreateDirectory(targetPath); var processInfo = new ProcessStartInfo(Path.GetFullPath("baksmali.bat"), string.Format(@"-o {0} {1}", targetPath, dexPath)) { CreateNoWindow = true, UseShellExecute = false, }; Process.Start(processInfo).WaitForExit(); app.BaksmailedDexPaths.Add(targetPath); app.BaksmailedDexNames[targetPath] = dexName; }
static void UnpackJarOld(UnpackedApp app) { string jarName = Path.GetFileNameWithoutExtension(app.OriginalJarPath); string targetPath = string.Format(@"TempSmali\Unpacked\{0}\", jarName); targetPath = Path.GetFullPath(targetPath); Console.WriteLine(" Unpacking: {0} to: {1}", app.OriginalJarPath, targetPath); Directory.CreateDirectory(targetPath); ZipFile.ExtractToDirectory(app.OriginalJarPath, targetPath); app.UnpackedPath = targetPath; }
static void CopyToMerge(UnpackedApp app) { if (app.OnlyCopyDex) { Console.WriteLine(" Skipping File Merge for: {0} because -dex-only flag is set", app.UnpackedPath); return; } string targetPath = string.Format(@"TempSmali\Merged\"); targetPath = Path.GetFullPath(targetPath); Console.WriteLine(" Merging: {0} to: {1}", app.UnpackedPath, targetPath); DirectoryCopy(app.UnpackedPath, targetPath, true, false); }
static void RunSmali(UnpackedApp app, string baksmailedDex, int dexIndex) { string dexName = dexIndex == 1 ? "classes.dex" : string.Format("classes{0}.dex", dexIndex); string targetPath = string.Format(@"TempSmali\Smalied\{0}", dexName); targetPath = Path.GetFullPath(targetPath); Console.WriteLine(" Smailing: {0} to: {1}", baksmailedDex, targetPath); var processInfo = new ProcessStartInfo(Path.GetFullPath("smali.bat"), string.Format(@"-o {0} {1}", targetPath, baksmailedDex)) { CreateNoWindow = true, UseShellExecute = false, }; Process.Start(processInfo).WaitForExit(); app.CompiledDexPaths.Add(targetPath); }