private static void Clean(string fileName) { try { if (File.Exists(PathMgr.Temp(fileName))) { File.Delete(PathMgr.Temp(fileName)); } if (Directory.Exists(PathMgr.Lua(fileName).Replace($"\\{DirName}", ""))) { Utils.Rmdir(PathMgr.Lua(fileName).Replace($"\\{DirName}", "")); } foreach (var mod in ListOfMod.Keys) { var modName = "scripts-" + mod.ToString().ToLower().Replace("_", "-"); if (File.Exists(PathMgr.Temp(modName))) { File.Delete(PathMgr.Temp(modName)); } if (Directory.Exists(PathMgr.Lua(modName).Replace($"\\{DirName}", ""))) { Utils.Rmdir(PathMgr.Lua(modName).Replace($"\\{DirName}", "")); } } } catch (Exception e) { Utils.LogException("Exception detected during cleaning", e); } }
private static void Clean(string fileName) { try { if (File.Exists(PathMgr.Temp(fileName))) { File.Delete(PathMgr.Temp(fileName)); } if (Directory.Exists(PathMgr.Lua(fileName).Replace("\\CAB-android", ""))) { Utils.Rmdir(PathMgr.Lua(fileName).Replace("\\CAB-android", "")); } foreach (var mod in ListOfMod) { if (File.Exists(PathMgr.Temp(mod))) { File.Delete(PathMgr.Temp(mod)); } if (Directory.Exists(PathMgr.Lua(mod).Replace("\\CAB-android", ""))) { Utils.Rmdir(PathMgr.Lua(mod).Replace("\\CAB-android", "")); } } } catch (Exception e) { Utils.eLogger("Exception detected during cleaning", e); } }
private static void Clean(string fileName) { if (File.Exists(PathMgr.Temporary(fileName))) { File.Delete(PathMgr.Temporary(fileName)); } if (Directory.Exists(PathMgr.Lua(fileName).Replace("\\CAB-android", ""))) { Utils.DeleteDirectory(PathMgr.Lua(fileName).Replace("\\CAB-android", "")); } foreach (var mod in ConfigMgr.ListOfMod) { if (File.Exists(PathMgr.Temporary(mod))) { File.Delete(PathMgr.Temporary(mod)); } if (Directory.Exists(PathMgr.Lua(mod).Replace("\\CAB-android", ""))) { Utils.DeleteDirectory(PathMgr.Lua(mod).Replace("\\CAB-android", "")); } } }
private static void Main(string[] args) { if (args.Length > 1) { Console.WriteLine(@"Invalid argument, usage: Azurlane.exe <path-to-scripts>"); return; } else if (args.Length < 1) { using (var openFileDialog = new OpenFileDialog()) { openFileDialog.Title = @"Open a scripts file..."; openFileDialog.Filter = @"Azurlane AssetBundle|scripts*"; openFileDialog.CheckFileExists = true; openFileDialog.Multiselect = true; openFileDialog.ShowDialog(); if (File.Exists(openFileDialog.FileName)) { args = new[] { openFileDialog.FileName } } ; else { Console.WriteLine(@"Please open a scripts file..."); Console.ReadKey(); return; } } } if (!File.Exists(args[0])) { Console.WriteLine(Directory.Exists(args[0]) ? $"{args[0]} is a directory, please input a file..." : $"{args[0]} doesn't exists..."); return; } var filePath = Path.GetDirectoryName(args[0]); var fileName = Path.GetFileName(args[0]); var listOfLua = new string[] { "aircraft_template.lua.txt", "enemy_data_statistics.lua.txt", "weapon_property.lua.txt" }; var listOfMod = new string[] { "weakenemy", "godmode", "godmode-cd", "godmode-dmg", "godmode-dmg-cd", "godmode-weakenemy" }; for (var i = 0; i < listOfMod.Length; i++) { listOfMod[i] = string.Format("{0}-{1}", fileName, listOfMod[i]); } if (File.Exists(PathMgr.Temp(fileName))) { File.Delete(PathMgr.Temp(fileName)); } if (Directory.Exists(Path.Combine(PathMgr.Temp("Unity_Assets_Files"), fileName))) { Utils.DeleteDirectory(Path.Combine(PathMgr.Temp("Unity_Assets_Files"), fileName)); } foreach (var mod in listOfMod) { if (File.Exists(PathMgr.Temp(mod))) { File.Delete(PathMgr.Temp(mod)); } if (Directory.Exists(Path.Combine(PathMgr.Temp("Unity_Assets_Files"), mod))) { Utils.DeleteDirectory(Path.Combine(PathMgr.Temp("Unity_Assets_Files"), mod)); } } try { var index = 1; Console.Write("[+] Copying AssetBundle to temp workspace..."); File.Copy(args[0], PathMgr.Temp(fileName), true); Console.Write(" <done>"); Console.WriteLine(); Console.Write("[+] Decrypting and Unpacking AssetBundle..."); AssetBundle.Run(PathMgr.Temp(fileName), Tasks.Decrypt); AssetBundle.Run(PathMgr.Temp(fileName), Tasks.Unpack); Console.Write(" <done>"); Console.WriteLine(); Console.Write($"[+] Decrypting and Decompiling Lua..."); foreach (var lua in listOfLua) { Console.Write($" {index}/{listOfLua.Length}"); Lua.Run(PathMgr.Lua(fileName, lua), Tasks.Decrypt); Lua.Run(PathMgr.Lua(fileName, lua), Tasks.Decompile); if (index == listOfLua.Length) { Console.Write(" <done>"); } index++; } Console.WriteLine(); index = 1; Console.Write($"[+] Cloning Lua and AssetBundle..."); foreach (var mod in listOfMod) { Console.Write($" {index}/{listOfMod.Length}"); try { if (!Directory.Exists(PathMgr.Lua(mod))) { Directory.CreateDirectory(PathMgr.Lua(mod)); } foreach (var lua in listOfLua) { File.Copy(PathMgr.Lua(fileName, lua), PathMgr.Lua(mod, lua), true); } } catch (Exception e) { Utils.ExceptionLogger("Exception detected during cloning lua and assetbundle", e); } File.Copy(PathMgr.Temp(fileName), PathMgr.Temp(mod), true); if (index == listOfMod.Length) { Console.Write(" <done>"); } index++; } Console.WriteLine(); index = 1; Console.Write("[+] Rewriting Lua..."); foreach (var mod in listOfMod) { Console.Write($" {index}/{listOfMod.Length}"); foreach (var lua in listOfLua) { if (mod.Contains("godmode-weakenemy")) { Write.GodMode(PathMgr.Lua(mod, lua)); Write.WeakEnemy(PathMgr.Lua(mod, lua), 20); } else if (mod.Contains("godmode-dmg-cd")) { Write.GodMode(PathMgr.Lua(mod, lua)); Write.Damage(PathMgr.Lua(mod, lua), 325); Write.Cooldown(PathMgr.Lua(mod, lua), 100); } else if (mod.Contains("godmode-dmg")) { Write.GodMode(PathMgr.Lua(mod, lua)); Write.Damage(PathMgr.Lua(mod, lua), 325); } else if (mod.Contains("godmode-cd")) { Write.GodMode(PathMgr.Lua(mod, lua)); Write.Cooldown(PathMgr.Lua(mod, lua), 100); } else if (mod.Contains("godmode")) { Write.GodMode(PathMgr.Lua(mod, lua)); } else if (mod.Contains("weakenemy")) { Write.WeakEnemy(PathMgr.Lua(mod, lua), 10); } } if (index == listOfMod.Length) { Console.Write(" <done>"); } index++; } Console.WriteLine(); index = 1; Console.Write("[+] Recompiling and Encypting Lua..."); foreach (var mod in listOfMod) { Console.Write($" {index}/{listOfMod.Length}"); foreach (var lua in listOfLua) { Lua.Run(PathMgr.Lua(mod, lua), Tasks.Recompile); Lua.Run(PathMgr.Lua(mod, lua), Tasks.Encrypt); } if (index == listOfMod.Length) { Console.Write(" <done>"); } index++; } Console.WriteLine(); index = 1; Console.Write("[+] Repacking & encrypting assetbundle..."); foreach (var mod in listOfMod) { Console.Write($" {index}/{listOfMod.Length}"); AssetBundle.Run(PathMgr.Temp(mod), Tasks.Repack); AssetBundle.Run(PathMgr.Temp(mod), Tasks.Encrypt); if (index == listOfMod.Length) { Console.Write(" <done>"); } index++; } Console.WriteLine(); index = 1; Console.Write("[+] Cleaning..."); foreach (var mod in listOfMod) { if (File.Exists(Path.Combine(filePath, mod))) { File.Delete(Path.Combine(filePath, mod)); } File.Copy(PathMgr.Temp(mod), Path.Combine(filePath, mod), true); } if (File.Exists(PathMgr.Temp(fileName))) { File.Delete(PathMgr.Temp(fileName)); } if (Directory.Exists(Path.Combine(PathMgr.Temp("Unity_Assets_Files"), fileName))) { Utils.DeleteDirectory(Path.Combine(PathMgr.Temp("Unity_Assets_Files"), fileName)); } foreach (var mod in listOfMod) { if (File.Exists(PathMgr.Temp(mod))) { File.Delete(PathMgr.Temp(mod)); } if (Directory.Exists(Path.Combine(PathMgr.Temp("Unity_Assets_Files"), mod))) { Utils.DeleteDirectory(Path.Combine(PathMgr.Temp("Unity_Assets_Files"), mod)); } } Console.Write(" <done>\n"); Console.WriteLine(); } finally { if (ExceptionCount != 0) { Console.WriteLine("Exception Detected, please check Logs.txt"); } Console.WriteLine("Press any key to exit."); Console.ReadLine(); } }
private static void Main(string[] args) { Initialize(); if (Abort) { return; } if (args.Length < 1) { using (var dialog = new OpenFileDialog()) { dialog.Title = @"Open an AssetBundle..."; dialog.Filter = @"Azurlane AssetBundle|scripts*"; dialog.CheckFileExists = true; dialog.Multiselect = false; dialog.ShowDialog(); if (File.Exists(dialog.FileName)) { args = new[] { dialog.FileName }; } else { Utils.Write(@"Please open an AssetBundle...", true, true); goto END; } } } else if (args.Length > 1) { Utils.Write(@"Invalid argument, usage: Azurlane.exe <path-to-assetbundle>", true, true); goto END; } var filePath = Path.GetFullPath(args[0]); var fileDirectoryPath = Path.GetDirectoryName(filePath); var fileName = Path.GetFileName(filePath); if (!File.Exists(filePath)) { Utils.Write(Directory.Exists(fileDirectoryPath) ? $"{args[0]} is a directory, please input a file..." : $"{args[0]} does not exists...", true, true); goto END; } if (!AssetBundleMgr.CheckAssetBundle(filePath)) { Utils.Write("Not a valid AssetBundle file...", true, true); goto END; } Clean(fileName); if (!Directory.Exists(PathMgr.Temp())) { Directory.CreateDirectory(PathMgr.Temp()); } var startTime = DateTime.Now; var index = 1; if (_listOfAction == null) { _listOfAction = new List <Action>() { () => { try { Utils.LogInfo("Copying AssetBundle to tmp workspace...", true, false); File.Copy(filePath, PathMgr.Temp(fileName), true); Utils.Write(" <done>", false, true); } catch (Exception e) { Utils.Write(" <failed>", false, true); Utils.LogException("Exception detected during copying AssetBundle to tmp workspace", e); } }, () => { try { Utils.LogInfo("Decrypting AssetBundle...", true, false); Utils.Command($"Azcli.exe --dev --decrypt \"{PathMgr.Temp(fileName)}\""); Utils.Write(" <done>", false, true); } catch (Exception e) { Utils.Write(" <failed>", false, true); Utils.LogException("Exception detected during decrypting AssetBundle", e); } }, () => { try { Utils.LogInfo("Unpacking AssetBundle...", true, false); Utils.Command($"Azcli.exe --dev --unpack \"{PathMgr.Temp(fileName)}\""); Utils.Write(" <done>", false, true); } catch (Exception e) { Utils.Write(" <failed>", false, true); Utils.LogException("Exception detected during unpacking AssetBundle", e); } }, () => { try { var showDoneMessage = true; Utils.LogInfo("Decrypting Lua...", true, false); foreach (var lua in ListOfLua) { Utils.Command($"Azcli.exe --dev --unlock \"{PathMgr.Lua(fileName, lua)}\""); if (LuaMgr.CheckLuaState(PathMgr.Lua(fileName, lua)) != LuaMgr.State.Encrypted) { break; } Console.WriteLine(); Utils.LogDebug($"Failed to decrypt {Path.GetFileName(lua)}", true, true); showDoneMessage = false; } if (showDoneMessage) { Utils.Write(" <done>", false, true); } } catch (Exception e) { Utils.Write(" <failed>", false, true); Utils.LogException("Exception detected during decrypting Lua", e); } }, () => { try { Utils.LogInfo("Decompiling Lua...", true, false); var tasks = new List <Task>(); foreach (var lua in ListOfLua) { tasks.Add(Task.Factory.StartNew(() => { Utils.Command($"Azcli.exe --dev --decompile \"{PathMgr.Lua(fileName, lua)}\""); Utils.Write($@" {index}/{ListOfLua.Count}", false, false); index++; })); } Task.WaitAll(tasks.ToArray()); Utils.Write(" <done>", false, true); } catch (Exception e) { Utils.Write(" <failed>", false, true); Utils.LogException("Exception detected during decompiling Lua", e); } }, () => { try { Utils.LogInfo("Cloning Lua & AssetBundle", true, false); foreach (var mod in ListOfMod) { if (mod.Value) { var modName = ("scripts-" + mod.Key).ToLower().Replace("_", "-"); if (!Directory.Exists(PathMgr.Lua(modName))) { Directory.CreateDirectory(PathMgr.Lua(modName)); } foreach (var lua in ListOfLua) { if (File.Exists(PathMgr.Lua(fileName, lua))) { File.Copy(PathMgr.Lua(fileName, lua), PathMgr.Lua(modName, lua), true); } } if (File.Exists(PathMgr.Temp(fileName))) { File.Copy(PathMgr.Temp(fileName), PathMgr.Temp(modName), true); } } } Utils.Write(" <done>", false, true); } catch (Exception e) { Utils.Write(" <failed>", false, true); Utils.LogException("Exception detected during cloning lua & assetbundle", e); } }, () => { try { Utils.LogInfo("Cleaning...", true, false); if (File.Exists(PathMgr.Temp(fileName))) { File.Delete(PathMgr.Temp(fileName)); } if (Directory.Exists(PathMgr.Lua(fileName).Replace($"\\{DirName}", ""))) { Utils.Rmdir(PathMgr.Lua(fileName).Replace($"\\{DirName}", "")); } Utils.Write(" <done>", false, true); } catch (Exception e) { Utils.Write(" <failed>", false, true); Utils.LogException("Exception detected during cleaning", e); } }, () => { try { Utils.LogInfo("Rewriting Lua...", true, false); Utils.Command("Azrewriter.exe"); Utils.Write(" <done>", false, true); } catch (Exception e) { Utils.Write(" <failed>", false, true); Utils.LogException("Exception detected during rewriting Lua", e); } }, () => { try { Utils.LogInfo("Recompiling Lua...", true, false); var tasks = new List <Task>(); foreach (var mod in ListOfMod) { if (mod.Value) { var modName = ("scripts-" + mod.Key).ToLower().Replace("_", "-"); foreach (var lua in ListOfLua) { tasks.Add(Task.Factory.StartNew(() => { })); } } } Task.WaitAll(tasks.ToArray()); Utils.Write(" <done>", false, true); } catch (Exception e) { Utils.Write(" <failed>", false, true); Utils.LogException("Exception detected during recompiling Lua", e); } }, () => { try { var showDoneMessage = true; Utils.LogInfo("Encrypting Lua...", true, false); foreach (var mod in ListOfMod) { if (mod.Value) { var modName = ("scripts-" + mod.Key).ToLower().Replace("_", "-"); foreach (var lua in ListOfLua) { Utils.Command($"Azcli.exe --dev --lock \"{PathMgr.Lua(modName, lua)}\""); if (LuaMgr.CheckLuaState(PathMgr.Lua(modName, lua)) != LuaMgr.State.Decrypted) { break; } Console.WriteLine(); Utils.LogDebug($"Failed to encrypt {mod}/{Path.GetFileName(lua)}...", true, true); showDoneMessage = false; } } } if (showDoneMessage) { Utils.Write(" <done>", false, true); } } catch (Exception e) { Utils.Write(" <failed>", false, true); Utils.LogException("Exception detected during encrypting Lua", e); } }, DevMode, () => { try { Utils.LogInfo("Repacking AssetBundle...", true, false); var tasks = new List <Task>(); foreach (var mod in ListOfMod) { if (mod.Value) { var modName = ("scripts-" + mod.Key).ToLower().Replace("_", "-"); tasks.Add(Task.Factory.StartNew(() => { Utils.Command($"Azcli.exe --dev --repack \"{PathMgr.Temp(modName)}\""); Utils.Write($@" {index}/{ListOfMod.Count(x => x.Value)}", false, false); index++; })); } } Task.WaitAll(tasks.ToArray()); Utils.Write(" <done>", false, true); } catch (Exception e) { Utils.Write(" <failed>", false, true); Utils.LogException("Exception detected during repacking AssetBundle", e); } }, () => { try { Utils.LogInfo("Encrypting AssetBundle...", true, false); foreach (var mod in ListOfMod) { if (mod.Value) { var modName = ("scripts-" + mod.Key).ToLower().Replace("_", "-"); Utils.Command($"Azcli.exe --dev --encrypt \"{PathMgr.Temp(modName)}\""); } } Utils.Write(" <done>", false, true); } catch (Exception e) { Utils.Write(" <failed>", false, true); Utils.LogException("Exception detected during encrypting AssetBundle", e); } }, () => { try { Utils.LogInfo("Copying modified AssetBundle to original location...", true, false); foreach (var mod in ListOfMod) { if (mod.Value) { var modName = ("scripts-" + mod.Key).ToLower().Replace("_", "-"); if (File.Exists(Path.Combine(fileDirectoryPath, modName))) { File.Delete(Path.Combine(fileDirectoryPath, modName)); } File.Copy(PathMgr.Temp(modName), Path.Combine(fileDirectoryPath, modName)); } } Utils.Write(" <done>", false, true); } catch (Exception e) { Utils.Write(" <failed>", false, true); Utils.LogException("Exception detected during copying modified AssetBundle to original location", e); } } }; } try { foreach (var action in _listOfAction) { if (Abort) { break; } index = 1; action.Invoke(); } } finally { Utils.LogInfo("Cleaning...", true, true); Clean(fileName); Console.WriteLine(); Utils.Write("Finished.", true, true); var endTime = DateTime.Now; TimeSpan timeSpan = endTime - startTime; Utils.Write("Started at {0} - Ended at {1}", true, true, startTime.ToString("HH:mm"), endTime.ToString("HH:mm")); Utils.Write("{0} seconds elapsed.", true, true, timeSpan.TotalSeconds.ToString()); Console.WriteLine(); // Please don't delete this lol Utils.Write("Good work (even though you have done nothing at all).", true, true); } END: Utils.Write("Press any key to exit...", true, true); Console.ReadKey(); }
private static void Main(string[] args) { if (args.Length < 1) { using (var dialog = new OpenFileDialog()) { dialog.Title = "Open an AssetBundle..."; dialog.Filter = "Azurlane AssetBundle|scripts*"; dialog.CheckFileExists = true; dialog.Multiselect = false; dialog.ShowDialog(); if (File.Exists(dialog.FileName)) { args = new[] { dialog.FileName }; } else { Console.WriteLine("Please open an AssetBundle..."); goto END; } } } else if (args.Length > 1) { Console.WriteLine("Invalid argument, usage: Azurlane.exe <path-to-assetbundle>"); goto END; } var filePath = Path.GetFullPath(args[0]); var fileDirectoryPath = Path.GetDirectoryName(filePath); var fileName = Path.GetFileName(filePath); if (!File.Exists(filePath)) { Console.WriteLine(Directory.Exists(fileDirectoryPath) ? string.Format("{0} is a directory, please input a file...", args[0]) : string.Format("{0} does not exists...", args[0])); goto END; } if (!AssetBundleMgr.IsAssetBundleValid(filePath)) { Console.WriteLine("Not a valid AssetBundle file..."); goto END; } ConfigMgr.Initialize(); for (var i = 0; i < ListOfMod.Count; i++) { ListOfMod[i] = string.Format("{0}-{1}", fileName, ListOfMod[i]); } if (File.Exists(PathMgr.Local("Logs.txt"))) { File.Delete(PathMgr.Local("Logs.txt")); } Clean(fileName); if (!Directory.Exists(PathMgr.Temp())) { Directory.CreateDirectory(PathMgr.Temp()); } var index = 1; if (ListOfAction == null) { ListOfAction = new List <Action>() { { () => { try { Utils.pInfof("Copying AssetBundle to temporary workspace..."); File.Copy(filePath, PathMgr.Temp(fileName), true); Console.Write(" <Done>\n"); } catch (Exception e) { Utils.eLogger("Exception detected during copying AssetBundle to temporary workspace", e); } } }, { () => { try { Utils.pInfof("Decrypting AssetBundle..."); Utils.NewCommand(string.Format("Azcli.exe --decrypt \"{0}\"", PathMgr.Temp(fileName))); Console.Write(" <Done>\n"); } catch (Exception e) { Utils.eLogger("Exception detected during decrypting AssetBundle", e); } } }, { () => { try { Utils.pInfof("Unpacking AssetBundle..."); Utils.NewCommand(string.Format("Azcli.exe --unpack \"{0}\"", PathMgr.Temp(fileName))); Console.Write(" <Done>\n"); } catch (Exception e) { Utils.eLogger("Exception detected during unpacking AssetBundle", e); } } }, { () => { try { var showDoneMessage = true; Utils.pInfof("Decrypting Lua..."); foreach (var lua in ListOfLua) { Utils.NewCommand(string.Format("Azcli.exe --unlock \"{0}\"", PathMgr.Lua(fileName, lua))); if (LuaMgr.CheckLuaState(PathMgr.Lua(fileName, lua)) == LuaMgr.State.Encrypted) { Utils.pDebugln(string.Format("Failed to decrypt {0}", Path.GetFileName(lua))); showDoneMessage = false; } } if (showDoneMessage) { Console.Write(" <Done>\n"); } } catch (Exception e) { Utils.eLogger("Exception detected during decrypting Lua", e); } } }, { () => { try { Utils.pInfof("Decompiling Lua..."); foreach (var lua in ListOfLua) { Console.Write($" {index}/{ListOfLua.Count}"); Utils.NewCommand(string.Format("Azcli.exe --decompile \"{0}\"", PathMgr.Lua(fileName, lua))); index++; } Console.Write(" <Done>\n"); } catch (Exception e) { Utils.eLogger("Exception detected during decompiling Lua", e); } } }, { () => { try { Utils.pInfof("Creating a copy of Lua & AssetBundle"); foreach (var mod in ListOfMod) { if (!Directory.Exists(PathMgr.Lua(mod))) { Directory.CreateDirectory(PathMgr.Lua(mod)); } foreach (var lua in ListOfLua) { File.Copy(PathMgr.Lua(fileName, lua), PathMgr.Lua(mod, lua), true); } File.Copy(PathMgr.Temp(fileName), PathMgr.Temp(mod), true); } Console.Write(" <Done>\n"); } catch (Exception e) { Utils.eLogger("Exception detected during creating a copy of Lua & AssetBundle", e); } } }, { () => { try { Utils.pInfof("Cleaning..."); if (File.Exists(PathMgr.Temp(fileName))) { File.Delete(PathMgr.Temp(fileName)); } if (Directory.Exists(PathMgr.Lua(fileName).Replace("\\CAB-android", ""))) { Utils.Rmdir(PathMgr.Lua(fileName).Replace("\\CAB-android", "")); } Console.Write(" <Done>\n"); } catch (Exception e) { Utils.eLogger("Exception detected during cleaning", e); } } }, { () => { try { Utils.pInfof("Rewriting Lua..."); Utils.NewCommand("Rewriter.exe"); Console.Write(" <Done>\n"); } catch (Exception e) { Utils.eLogger("Exception detected during rewriting Lua", e); } } }, { () => { try { Utils.pInfof("Recompiling Lua..."); foreach (var mod in ListOfMod) { foreach (var lua in ListOfLua) { Utils.NewCommand(string.Format("Azcli.exe --recompile \"{0}\"", PathMgr.Lua(mod, lua))); } } Console.Write(" <Done>\n"); } catch (Exception e) { Utils.eLogger("Exception detected during recompiling Lua", e); } } }, { () => { try { var showDoneMessage = true; Utils.pInfof("Encrypting Lua..."); foreach (var mod in ListOfMod) { foreach (var lua in ListOfLua) { Utils.NewCommand(string.Format("Azcli.exe --lock \"{0}\"", PathMgr.Lua(mod, lua))); if (LuaMgr.CheckLuaState(PathMgr.Lua(mod, lua)) == LuaMgr.State.Decrypted) { Utils.pDebugln(string.Format("Failed to encrypt {0}/{1}...", mod, Path.GetFileName(lua))); showDoneMessage = false; } } } if (showDoneMessage) { Console.Write(" <Done>\n"); } } catch (Exception e) { Utils.eLogger("Exception detected during encrypting Lua", e); } } }, { () => { try { Utils.pInfof("Repacking AssetBundle..."); foreach (var mod in ListOfMod) { Console.Write($" {index}/{ListOfMod.Count}"); Utils.NewCommand(string.Format("Azcli.exe --repack \"{0}\"", PathMgr.Temp(mod))); index++; } Console.Write(" <Done>\n"); } catch (Exception e) { Utils.eLogger("Exception detected during repacking AssetBundle", e); } } }, { () => { try { Utils.pInfof("Encrypting AssetBundle..."); foreach (var mod in ListOfMod) { Utils.NewCommand(string.Format("Azcli.exe --encrypt \"{0}\"", PathMgr.Temp(mod))); } Console.Write(" <Done>\n"); } catch (Exception e) { Utils.eLogger("Exception detected during encrypting AssetBundle", e); } } }, { () => { try { Utils.pInfof("Copying modified AssetBundle to original location..."); foreach (var mod in ListOfMod) { if (File.Exists(Path.Combine(fileDirectoryPath, mod))) { File.Delete(Path.Combine(fileDirectoryPath, mod)); } File.Copy(PathMgr.Temp(mod), Path.Combine(fileDirectoryPath, mod)); } Console.Write(" <Done>\n"); } catch (Exception e) { Utils.eLogger("Exception detected during copying modified AssetBundle to original location", e); } } } }; } try { foreach (var action in ListOfAction) { if (index != 1) { index = 1; } action.Invoke(); } } finally { Utils.pInfoln("Finishing..."); Clean(fileName); Console.WriteLine(); Console.WriteLine("Finished."); } END: Console.WriteLine("Press any key to exit..."); Console.ReadKey(); }
private static void Main(string[] args) { if (args.Length < 1) { using (var dialog = new OpenFileDialog()) { dialog.Title = "Open an AssetBundle..."; dialog.Filter = "Azurlane AssetBundle|scripts*"; dialog.CheckFileExists = true; dialog.Multiselect = false; dialog.ShowDialog(); if (File.Exists(dialog.FileName)) { args = new[] { dialog.FileName }; } else { Console.WriteLine("Please open an AssetBundle..."); goto END; } } } else if (args.Length > 1) { Console.WriteLine("Invalid argument, usage: Azurlane.exe <path-to-assetbundle>"); goto END; } var filePath = Path.GetFullPath(args[0]); var fileDirectoryPath = Path.GetDirectoryName(filePath); var fileName = Path.GetFileName(filePath); if (!File.Exists(filePath)) { Console.WriteLine(Directory.Exists(fileDirectoryPath) ? string.Format("{0} is a directory, please input a file...", args[0]) : string.Format("{0} doesn't exists", args[0])); goto END; } if (!AssetBundleMgr.IsAssetBundleValid(filePath)) { Console.WriteLine("Not a valid AssetBundle file..."); goto END; } ConfigMgr.Initialize(); for (var i = 0; i < ConfigMgr.ListOfMod.Count; i++) { ConfigMgr.ListOfMod[i] = string.Format("{0}-{1}", fileName, ConfigMgr.ListOfMod[i]); } Clean(fileName); var index = 1; var listOfAction = new List <Action>() { { () => { Console.Write("[+] Copying AssetBundle to temporary workspace..."); File.Copy(filePath, PathMgr.Temporary(fileName), true); } }, { () => { Console.Write("[+] Decrypting AssetBundle..."); AssetBundleMgr.Execute(PathMgr.Temporary(fileName), Tasks.Decrypt); } }, { () => { Console.Write("[+] Unpacking AssetBundle..."); AssetBundleMgr.Execute(PathMgr.Temporary(fileName), Tasks.Unpack); } }, { () => { Console.Write("[+] Decrypting Lua..."); foreach (var lua in ConfigMgr.ListOfLua) { LuaMgr.Execute(PathMgr.Lua(fileName, lua), Tasks.Decrypt); } } }, { () => { Console.Write("[+] Decompiling Lua..."); foreach (var lua in ConfigMgr.ListOfLua) { Console.Write($" {index}/{ConfigMgr.ListOfLua.Count}"); LuaMgr.Execute(PathMgr.Lua(fileName, lua), Tasks.Decompile); index++; } } }, { () => { Console.Write("[+] Creating a copy of Lua & AssetBundle..."); foreach (var mod in ConfigMgr.ListOfMod) { if (!Directory.Exists(PathMgr.Lua(mod))) { Directory.CreateDirectory(PathMgr.Lua(mod)); } foreach (var lua in ConfigMgr.ListOfLua) { File.Copy(PathMgr.Lua(fileName, lua), PathMgr.Lua(mod, lua), true); } File.Copy(PathMgr.Temporary(fileName), PathMgr.Temporary(mod), true); } } }, { () => { Console.Write("[+] Rewriting Lua..."); foreach (var mod in ConfigMgr.ListOfMod) { foreach (var lua in ConfigMgr.ListOfLua) { RewriteMgr.Execute(mod, PathMgr.Lua(mod, lua)); } } } }, { () => { Console.Write("[+] Recompiling Lua..."); foreach (var mod in ConfigMgr.ListOfMod) { foreach (var lua in ConfigMgr.ListOfLua) { LuaMgr.Execute(PathMgr.Lua(mod, lua), Tasks.Recompile); } } } }, { () => { Console.Write("[+] Encrypting Lua..."); foreach (var mod in ConfigMgr.ListOfMod) { foreach (var lua in ConfigMgr.ListOfLua) { LuaMgr.Execute(PathMgr.Lua(mod, lua), Tasks.Encrypt); } } } }, { () => { Console.Write("[+] Repacking AssetBundle..."); foreach (var mod in ConfigMgr.ListOfMod) { Console.Write($" {index}/{ConfigMgr.ListOfMod.Count}"); AssetBundleMgr.Execute(PathMgr.Temporary(mod), Tasks.Repack); index++; } } }, { () => { Console.Write("[+] Encrypting AssetBundle..."); foreach (var mod in ConfigMgr.ListOfMod) { AssetBundleMgr.Execute(PathMgr.Temporary(mod), Tasks.Encrypt); } } }, { () => { Console.Write("[+] Copying modified AssetBundle to original location..."); foreach (var mod in ConfigMgr.ListOfMod) { if (File.Exists(Path.Combine(fileDirectoryPath, mod))) { File.Delete(Path.Combine(fileDirectoryPath, mod)); } File.Copy(PathMgr.Temporary(mod), Path.Combine(fileDirectoryPath, mod)); } } } }; try { foreach (var action in listOfAction) { try { if (index != 1) { index = 1; } action.Invoke(); } catch (Exception e) { Utils.Log("Exception detected", e); } Console.Write(" <Done>\n"); } } finally { Console.Write("[!] Cleaning..."); Clean(fileName); Console.Write(" <Done>\n"); Console.WriteLine(); Console.WriteLine(string.Format("[!] We're done, {0}", ExceptionCount != 0 ? "exception detected... please check Logs.txt" : "horray!")); } END: Console.WriteLine("Press any key to exit..."); Console.ReadKey(); }