static void Main(string[] args) { Console.WriteAscii("USNQueryEngine", Color.FromArgb(240, 200, 200)); Stopwatch watch = new Stopwatch(); watch.Start(); entries = USNEngine.GetAllFilesAndDirectories(); watch.Stop(); Console.WriteLine("{0} files, {1} seconds", entries.Count(), watch.Elapsed.TotalSeconds); string filter = "UsnOperation.dll".ToUpper(); Formatter[] fruits = new Formatter[] { new Formatter($"{filter}", Color.LawnGreen), }; Console.WriteLineFormatted("Start to Serch [{0}]", Color.Gray, fruits); Console.WriteLine(); watch.Restart(); var result = entries .Where(f => f.FileName.ToUpper().Contains(filter)) .OrderBy(f => f.FileName) .ToList(); watch.Stop(); Console.WriteLine("{0} files in {1} seconds", result.Count(), watch.Elapsed.TotalSeconds); if (result.Count() > 0) { var table = new ConsoleTable("FileName", "Path"); foreach (var item in result) { if (item is FileAndDirectoryEntry) { table.AddRow(item.FileName, item.Path); } } table.Write(); Console.WriteLine(); } Console.WriteLine("Press any key to continue . . . "); Console.ReadKey(true); }
static void Main(string[] args) { Stopwatch ICwatch = new Stopwatch(); RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(); if (false && File.Exists(@"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\Extensions\gmfdiprp.bab\DebuggerShared.dll")) { DebuggerPath = @"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\Extensions\gmfdiprp.bab\DebuggerShared.dll"; Console.WriteLineFormatted("Found {0}", Color.LightGreen, Color.Gray, DebuggerPath); } else { var result = USNEngine.GetSearchPath("DebuggerShared.dll"); if (result.Count() > 0) { foreach (var item in result) { if (item is FileAndDirectoryEntry) { if (item.Path.Contains(@"\IDE\Extensions")) { //DebuggerPath = item.FullFileName; Console.WriteLineFormatted("Found {0}", Color.LightGreen, Color.Gray, DebuggerPath); } } } Console.WriteLine(); } } string licensPrivatekey = rsa.ToXmlString(true); string licensePublicKey = rsa.ToXmlString(false); if (DebuggerPath == "") { Console.WriteLineFormatted("Example {0} ", Color.LightYellow, Color.Gray, @"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\Extensions\gmfdiprp.bab\DebuggerShared.dll"); while (!DebuggerPath.Contains("DebuggerShared.dll")) { Console.WriteLineFormatted("Not Found [{0}]", Color.LightGreen, Color.Gray, "DebuggerShared.dll"); Console.WriteLineFormatted("Please Input [{0}] Path", Color.Red, Color.Gray, "DebuggerShared.dll"); DebuggerPath = Console.ReadLine(); } } byte[] array = File.ReadAllBytes(DebuggerPath); byte[] resbyteST = Encoding.UTF8.GetBytes(FileReplace.CharsFill("<RSAKeyValue><Modulus>".ToCharArray())); byte[] resbyteED = Encoding.UTF8.GetBytes(FileReplace.CharsFill("</Modulus><Exponent>AQAB</Exponent></RSAKeyValue>".ToCharArray())); int rsastarting = FileReplace.SundayIndexOf(array, resbyteST); int rsaEnding = FileReplace.SundayIndexOf(array, resbyteED); //byte[] searchRsa = Encoding.UTF8.GetBytes(FileReplace.CharsFill(rsaPublicKey.ToCharArray())); byte[] searchRsa = array.Skip(rsastarting).Take(rsaEnding - rsastarting + resbyteED.Length).ToArray(); string Rsastr = Encoding.UTF8.GetString(searchRsa).Replace($"\0", ""); Console.WriteLineFormatted("XmlRAS {0}", Color.LightGreen, Color.Gray, Rsastr); byte[] replaceRsa = Encoding.UTF8.GetBytes(FileReplace.CharsFill(licensePublicKey.ToCharArray())); try { if (FileReplace.SundayIndexOf(array, searchRsa) > -1) { Console.WriteLine("WriteAllBytes HexReplace"); File.WriteAllBytes(DebuggerPath, FileReplace.HexReplace(array, searchRsa, replaceRsa)); } } catch (Exception ex) { Console.WriteLineFormatted("ERR# \r\n {0}", Color.Red, Color.PowderBlue, ex); Console.WriteLineFormatted("Please Close VStudio ", Color.LightSeaGreen); } LicenseXml = Generating.Getkey(licensPrivatekey, "yang.linhao", Guid.NewGuid(), DateTime.UtcNow.AddYears(5), new Dictionary <string, string> { }, (Generating.EnumSet) 2); string Licensekey = Compression.CompressStringToBase64(LicenseXml); LicenseXml = Compression.DecompressStringFromBase64(Licensekey); //Console.WriteLine(LicenseXml); IsLicense isLicense = new IsLicense(); array = File.ReadAllBytes(DebuggerPath); rsastarting = FileReplace.SundayIndexOf(array, resbyteST); rsaEnding = FileReplace.SundayIndexOf(array, resbyteED); //byte[] searchRsa = Encoding.UTF8.GetBytes(FileReplace.CharsFill(rsaPublicKey.ToCharArray())); searchRsa = array.Skip(rsastarting).Take(rsaEnding - rsastarting + resbyteED.Length).ToArray(); Rsastr = Encoding.UTF8.GetString(searchRsa).Replace($"\0", ""); if (isLicense.HasExistingLicense(Rsastr)) { Console.WriteLineFormatted("It`s [{0}]", Color.LightGreen, Color.Gray, "OK."); Console.WriteLine(Licensekey); } else { Console.WriteLineFormatted("It`s [{0}]", Color.Red, Color.Gray, "ERR."); } Console.ReadKey(); }