From 135779e03cf78d5ac8d4c0656d5ec28278f2cf62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marcus=20andr=C3=A9?= Date: Sun, 12 May 2019 00:30:44 -0300 Subject: [PATCH] Allow Manual SiglusPatcher Key Specifier --- SiglusPatcher/Program.cs | 44 ++++++++++++++++++++++++++++++++-------- 1 file changed, 36 insertions(+), 8 deletions(-) diff --git a/SiglusPatcher/Program.cs b/SiglusPatcher/Program.cs index 09c3e82..e59d169 100644 --- a/SiglusPatcher/Program.cs +++ b/SiglusPatcher/Program.cs @@ -125,15 +125,43 @@ private static uint IndexOfSequence(byte[] Data, byte[] Sequence) { } return uint.MaxValue; } + private static byte[] GetSiglusKey(string Exe) { - Process Proc = Process.Start(Exe); - while (Proc.MainWindowHandle == IntPtr.Zero) - System.Threading.Thread.Sleep(100); - KeyFinder.Key Key = KeyFinder.ReadProcess(Proc.Id)[0]; - byte[] KeyB = Key.KEY; - Proc.Kill(); - Console.WriteLine("Encryption Key Detected:\n{0}", Key.KeyStr); - return KeyB; + try + { + Process Proc = Process.Start(Exe); + while (Proc.MainWindowHandle == IntPtr.Zero) + System.Threading.Thread.Sleep(100); + KeyFinder.Key Key = KeyFinder.ReadProcess(Proc.Id)[0]; + byte[] KeyB = Key.KEY; + Proc.Kill(); + Console.WriteLine("Encryption Key Detected:\n{0}", Key.KeyStr); + return KeyB; + } + catch (Exception ex) { + var Color = Console.ForegroundColor; + Console.ForegroundColor = ConsoleColor.Red; + Console.WriteLine("Failed, Please, Report a issue... LOG:\n{0}", ex.ToString()); + Console.ForegroundColor = Color; + + Console.WriteLine("You know the key? If yes, type it..."); + string Reply = Console.ReadLine(); + Reply = Reply.ToUpper().Replace("0X", "").Replace(",", "").Replace(" ", "").Trim(); + + if (string.IsNullOrWhiteSpace(Reply) || Reply.Length/2 != KeyPointers.Length) + throw new Exception(); + + if ((from x in Reply where ((x >= '0' && x <= '9') || (x >= 'A' && x <= 'F')) select x).Count() != Reply.Length) + throw new Exception(); + + byte[] Key = new byte[KeyPointers.Length]; + for (byte i = 0; i < Key.Length; i++) + { + Key[i] = Convert.ToByte(Reply.Substring(i * 2, 2), 16); + } + + return Key; + } } private static void ExtractResource(string Resource, string Dir) {