/// <summary> /// Load predefined settings. /// </summary> private void SettingsLoad() { // Creating the history file directory in USERPROFILE\AppData\Local if not exist. if (!Directory.Exists(s_historyFilePath)) { Directory.CreateDirectory(s_historyFilePath); } //creating history file if not exist if (!File.Exists(s_historyFile)) { File.WriteAllText(s_historyFile, Environment.NewLine); } // Creating the Password Manager directory for storing the encrypted files. if (!Directory.Exists(s_passwordManagerDirectory)) { Directory.CreateDirectory(s_passwordManagerDirectory); } //Store current directory with current process id. StoreCurrentDirectory(); // Creating the addon directory for C# code script scomands if not exist. if (!Directory.Exists(s_addonDir)) { Directory.CreateDirectory(s_addonDir); } //reading current location s_currentDirectory = File.ReadAllText(GlobalVariables.currentDirectory); if (s_currentDirectory == "") { File.WriteAllText(GlobalVariables.currentDirectory, GlobalVariables.rootPath); } // Reading cport time out setting and set default vaule if is emtpy. string timeOut = RegistryManagement.regKey_Read(GlobalVariables.regKeyName, GlobalVariables.regCportTimeOut); if (timeOut == "") { RegistryManagement.regKey_WriteSubkey(GlobalVariables.regKeyName, GlobalVariables.regCportTimeOut, "500"); } // Reading UI settings. s_regUI = RegistryManagement.regKey_Read(GlobalVariables.regKeyName, GlobalVariables.regUI); if (s_regUI == "") { RegistryManagement.regKey_WriteSubkey(GlobalVariables.regKeyName, GlobalVariables.regUI, @"green;1|white;$|cyan"); } // Title display application name, version + current directory. Console.Title = $"{s_terminalTitle} | {s_currentDirectory}"; // Store xTerminal version. GlobalVariables.version = Application.ProductVersion; }
public void Execute(string arg) { if (arg.Length == 2) { Console.WriteLine($"Use -h param for {Name} command usage!"); return; } _regUI = RegistryManagement.regKey_Read(GlobalVariables.regKeyName, GlobalVariables.regUI); var args = arg.Split(' '); // Sore userinfo settings. if (arg.ContainsText("-u")) { if (arg.ContainsText(":e")) { SetUserColor(args.ParameterAfter("-c"), _regUI, "", true, Core.SystemTools.UI.Setting.UserInfo); return; } else if (arg.ContainsText(":d")) { SetUserColor(args.ParameterAfter("-c"), _regUI, "", false, Core.SystemTools.UI.Setting.UserInfo); return; } } // Store indicator setting. if (arg.ContainsText("-i")) { if (arg.ContainsText("-s")) { SetUserColor(args.ParameterAfter("-c"), _regUI, args.ParameterAfter("-s"), true, Core.SystemTools.UI.Setting.Indicator); return; } SetUserColor(args.ParameterAfter("-c"), _regUI, "$", true, Core.SystemTools.UI.Setting.Indicator); return; } // Store current directory setting. if (arg.ContainsText("-cd")) { SetUserColor(args.ParameterAfter("-cd"), _regUI, "$", true, Core.SystemTools.UI.Setting.CurrentDirectoy); return; } // Display help message if (arg == $"{Name} -h") { Console.WriteLine(_helpMessage); } }
public void Execute(string arg) { string file = string.Empty; string set; string dlocation = File.ReadAllText(GlobalVariables.currentDirectory); string cEditor = RegistryManagement.regKey_Read(GlobalVariables.regKeyName, GlobalVariables.regCurrentEitor); if (cEditor == "") { RegistryManagement.regKey_WriteSubkey(GlobalVariables.regKeyName, GlobalVariables.regCurrentEitor, "notepad"); } try { if (!arg.Contains("set")) { int argLenght = arg.Length - 5; file = arg.Substring(5, argLenght); file = FileSystem.SanitizePath(file, dlocation); ProcessCall(file, File.Exists(cEditor) ? cEditor : "notepad"); return; } set = arg.Replace("edit set ", ""); if (File.Exists(set)) { RegistryManagement.regKey_WriteSubkey(GlobalVariables.regKeyName, GlobalVariables.regCurrentEitor, set); Console.WriteLine("Your New editor is: " + set); return; } FileSystem.ErrorWriteLine($"File {set} dose not exist"); return; } catch { file = FileSystem.SanitizePath(file, dlocation); if (string.IsNullOrEmpty(file)) { Console.WriteLine("You must type the file name for edit!"); return; } ProcessCall(file, File.Exists(cEditor) ? cEditor : "notepad"); return; } }
public void Execute(string args) { try { GlobalVariables.eventCancelKey = false; string cTimeOut = RegistryManagement.regKey_Read(GlobalVariables.regKeyName, GlobalVariables.regCportTimeOut); if (FileSystem.IsNumberAllowed(cTimeOut) && !string.IsNullOrEmpty(cTimeOut)) { s_timeOut = Int32.Parse(cTimeOut); } else { s_timeOut = 500; RegistryManagement.regKey_WriteSubkey(GlobalVariables.regKeyName, GlobalVariables.regCportTimeOut, "500"); } if (args.StartsWith($"{Name} stimeout")) { string timeOut = args.SplitByText("stimeout ", 1); RegistryManagement.regKey_WriteSubkey(GlobalVariables.regKeyName, GlobalVariables.regCportTimeOut, timeOut); Console.Write("New check port time out is: "); FileSystem.ColorConsoleTextLine(ConsoleColor.Green, timeOut + " ms"); return; } if (args == $"{Name} rtimeout") { string timeOut = RegistryManagement.regKey_Read(GlobalVariables.regKeyName, GlobalVariables.regCportTimeOut); Console.Write("Check port time out is set to: "); FileSystem.ColorConsoleTextLine(ConsoleColor.Green, timeOut + " ms"); return; } if (args.Length == 5) { Console.WriteLine($"Use -h param for {Name} command usage!"); return; } if (args == $"{Name} -h") { Console.WriteLine(s_helpMessage); return; } string arg = args.Substring(6, args.Length - 6); string ipAddress = arg.SplitByText(" -p ", 0); if (!NetWork.PingHost(ipAddress)) { FileSystem.ColorConsoleTextLine(ConsoleColor.Yellow, $"{ipAddress} is offline"); return; } string portData = arg.SplitByText(" -p ", 1); if (portData.Contains("-")) { GlobalVariables.eventKeyFlagX = true; string[] portsRange = portData.Split('-'); int minPort = Int32.Parse(portsRange[0].Trim()); int maxPort = Int32.Parse(portsRange[1].Trim()); PortScan.RunPortScan(ipAddress, minPort, maxPort, s_timeOut); if (GlobalVariables.eventCancelKey) { FileSystem.ColorConsoleTextLine(ConsoleColor.Yellow, "Command stopped!"); } GlobalVariables.eventCancelKey = false; return; } int port = Int32.Parse(portData.Trim()); PortScan.RunPortScan(ipAddress, port, port, s_timeOut); if (GlobalVariables.eventCancelKey) { FileSystem.ColorConsoleTextLine(ConsoleColor.Yellow, "Command stopped!"); } GlobalVariables.eventCancelKey = false; } catch (Exception e) { FileSystem.ErrorWriteLine(e.Message); } }