public Command GetCommand() { TABLE.Add(new CommandArgumentEntry("-load", false)); CMD_CONFIG_STARTUP = new Command("CONFIG-STARTUP", TABLE, false, "Displays or loads startup config.", ExecutionLevel.User, CLIMode.Default); CMD_CONFIG_STARTUP.SetFunction(() => { if (CMD_CONFIG_STARTUP.InputArgumentEntry.Arguments.Count == 0) { EnvironmentVariables.GetAll().ForEach((x) => { if (x.VarType == VariableType.Constant) { IOInteractLayer.StandardOutput(CMD_CONFIG_STARTUP, $"\n\t{x.Name} = {x.DefaultValue}"); } }); } else { List <string> names = EnvironmentVariables.FindAll(x => x.VarType == VariableType.Constant).Select(x => x.Name).ToList(); names.ForEach((x) => { EnvironmentVariables.ChangeCurrentValue(x, EnvironmentVariables.GetDefaultValue(x)); }); } return(""); }); return(CMD_CONFIG_STARTUP); }
public Command GetCommand() { TABLE.Add(new CommandArgumentEntry("[string]", false, "[result filter]")); CMD_HISTORY_SHLIST = new Command("HISTORY-SHLIST", TABLE, true, "Returns the input history of the current CLI mode.", ExecutionLevel.User, CLIMode.Any); CMD_HISTORY_SHLIST.SetFunction(() => { string var_name = (string)EnvironmentVariables.GetCurrentValue("CLI_MODE") == "Default" ? "DEF_HISTORY" : "REG_HISTORY"; if (CMD_HISTORY_SHLIST.InputArgumentEntry.Arguments.Count == 1) { Interpreter interpreter = new Interpreter((string)CMD_HISTORY_SHLIST.InputArgumentEntry.Arguments[0].Value); for (int i = 1; i < ((List <string>)EnvironmentVariables.GetCurrentValue(var_name)).Count; i++) { if (interpreter.GetResult(((List <string>)EnvironmentVariables.GetCurrentValue(var_name))[i])) { IOInteractLayer.StandardOutput(CMD_HISTORY_SHLIST, "\n\t" + i + " " + ((List <string>)EnvironmentVariables.GetCurrentValue(var_name))[i]); } } } else { for (int i = 1; i < ((List <string>)EnvironmentVariables.GetCurrentValue(var_name)).Count; i++) { IOInteractLayer.StandardOutput(CMD_HISTORY_SHLIST, "\n\t" + i + " " + ((List <string>)EnvironmentVariables.GetCurrentValue(var_name))[i]); } } return(""); }); return(CMD_HISTORY_SHLIST); }
public Command GetCommand() { TABLE.Add(new CommandArgumentEntry("[string]", false, "[name filter]")); CMD_HELP = new Command("HELP", TABLE, true, "Returns descriptions of all commands in the current CLI mode.", ExecutionLevel.User, CLIMode.Any); CMD_HELP.SetFunction(() => { string var_name = (string)EnvironmentVariables.GetCurrentValue("CLI_MODE") == "Default" ? "DEF_CMD_POOL" : "REG_CMD_POOL"; if (CMD_HELP.InputArgumentEntry.Arguments.Count == 0) { ((CommandPool)EnvironmentVariables.GetCurrentValue(var_name)).GetPool().ForEach((x) => { IOInteractLayer.StandardOutput(CMD_HELP, "\n" + x.Description); }); } else { Interpreter interpreter = new Interpreter((string)CMD_HELP.InputArgumentEntry.Arguments[0].Value); ((CommandPool)EnvironmentVariables.GetCurrentValue(var_name)).GetPool().ForEach((x) => { if (interpreter.GetResult(x.Call.ToLower())) { IOInteractLayer.StandardOutput(CMD_HELP, "\n" + x.Description); } }); } return(""); }); return(CMD_HELP); }
public Command GetCommand() { TABLE.Add(new CommandArgumentEntry("[string]", false, "[file path]")); CMD_OPEN = new Command("OPEN", TABLE, false, "Displays the editable contents of the specified file. Press 'F1' to save, press 'F2' to save and close, press 'ESC' to discard and colse.", ExecutionLevel.User, CLIMode.Default); CMD_OPEN.SetAsyncFunction(async() => { await Task.Delay(0); c = new CountdownEvent(1); if (File.Exists(CMD_OPEN.InputArgumentEntry.Arguments[0].Value.ToString()) && CMD_OPEN.InputArgumentEntry.Arguments[0].Value.ToString().Contains(":")) { path = CMD_OPEN.InputArgumentEntry.Arguments[0].Value.ToString(); } else if (File.Exists(EnvironmentVariables.GetCurrentValue("DIRECTORY") + CMD_OPEN.InputArgumentEntry.Arguments[0].Value.ToString())) { path = EnvironmentVariables.GetCurrentValue("DIRECTORY") + CMD_OPEN.InputArgumentEntry.Arguments[0].Value.ToString(); } else { return("\nFile not found!"); } EnvironmentVariables.ChangeCurrentValue("CLI_MODE", "Text", false); ((TextEditor)EnvironmentVariables.GetCurrentValue("IOFIELD")).Dispatcher.Invoke(() => { ((TextEditor)EnvironmentVariables.GetCurrentValue("IOFIELD")).Clear(); IOInteractLayer.StandardOutput(CMD_OPEN, File.ReadAllText(path)); ((TextEditor)EnvironmentVariables.GetCurrentValue("IOFIELD")).PreviewKeyDown += Main_PreviewKeyDown; }); c.Wait(); return(""); }); return(CMD_OPEN); }
public Command GetCommand() { TABLE.Add(new CommandArgumentEntry("[string]", false, "[name filter]")); CMD_DRIVER_NAMES = new Command("DRIVER-NAMES", TABLE, true, "Returns driver names.", ExecutionLevel.User, CLIMode.Default); CMD_DRIVER_NAMES.SetFunction(() => { DriverInfo inf = new DriverInfo(); if (CMD_DRIVER_NAMES.InputArgumentEntry.Arguments.Count == 0) { inf.GetDriverInfo().ToList().Select(x => x.DisplayName).ToList().ForEach(x => { IOInteractLayer.StandardOutput(CMD_DRIVER_NAMES, "\n" + x); }); } else { Interpreter interpreter = new Interpreter(CMD_DRIVER_NAMES.InputArgumentEntry.Arguments[0].Value.ToString()); inf.GetDriverInfo().ToList().Select(x => x.DisplayName).ToList().ForEach(x => { if (interpreter.GetResult(x)) { IOInteractLayer.StandardOutput(CMD_DRIVER_NAMES, "\n" + x); } }); } return(""); }); return(CMD_DRIVER_NAMES); }
public Command GetCommand() { TABLE.Add(new CommandArgumentEntry("-rhost", false, "-rhost(resolve hostnames)")); CMD_NMAP = new Command("NMAP", TABLE, false, "Attempts to discover all connacted devices on all connected networks.", ExecutionLevel.User, CLIMode.Default); CMD_NMAP.SetAsyncFunction(async() => { ((TextEditor)EnvironmentVariables.GetCurrentValue("IOFIELD")).Dispatcher.Invoke(() => { ((TextEditor)EnvironmentVariables.GetCurrentValue("IOFIELD")).IsReadOnly = true; ((TextEditor)EnvironmentVariables.GetCurrentValue("IOFIELD")).KeyDown += Main_KeyDown; IOInteractLayer.StandardOutput(CMD_NMAP, "\n"); }); NetworkInterfaceDiscovery nics = new NetworkInterfaceDiscovery(); ToolShed.ThisPC.NetworkInterface[] interfaces = await nics.GetInterfaces(); NetworkInfo inf = new NetworkInfo(); string[] ip_arr = inf.GetAddresses(interfaces); await GetDevices(ip_arr, interfaces, CMD_NMAP.InputArgumentEntry.Arguments.Exists(x => x.Call == "-rhost")); ((TextEditor)EnvironmentVariables.GetCurrentValue("IOFIELD")).Dispatcher.Invoke(() => { ((TextEditor)EnvironmentVariables.GetCurrentValue("IOFIELD")).KeyDown -= Main_KeyDown; ((TextEditor)EnvironmentVariables.GetCurrentValue("IOFIELD")).IsReadOnly = false; }); return(""); }); return(CMD_NMAP); }
public Command GetCommand() { TABLE.Add(new CommandArgumentEntry("[string]", false, "[name/filter]")); CMD_VAL_DELETE = new Command("VAL-DELETE", TABLE, true, "Removes all values that matches the specified filter in the current subkey.", ExecutionLevel.Administrator, CLIMode.Regedit); CMD_VAL_DELETE.SetFunction(() => { RegistryKey key = RegistryKey.OpenBaseKey((RegistryHive)Enum.Parse(typeof(RegistryHive), EnvironmentVariables.GetCurrentValue("SUBKEY").ToString().Substring(0, EnvironmentVariables.GetCurrentValue("SUBKEY").ToString().IndexOf("\\"))), RegistryView.Default).OpenSubKey(EnvironmentVariables.GetCurrentValue("SUBKEY").ToString().Substring(EnvironmentVariables.GetCurrentValue("SUBKEY").ToString().IndexOf("\\") + 1), true); Interpreter interpreter = new Interpreter(CMD_VAL_DELETE.InputArgumentEntry.Arguments[0].Value.ToString()); string[] names = key.GetValueNames(); int removed = 0; try { for (int i = 0; i < names.Length; i++) { if (interpreter.GetResult(names[i])) { key.DeleteValue(names[i]); removed++; } } } catch (Exception ex) { IOInteractLayer.StandardError(CMD_VAL_DELETE, ex); } return($"\nRemoved: {removed} values"); }); return(CMD_VAL_DELETE); }
public Command GetCommand() { TABLE.Add(new CommandArgumentEntry("[string]", false, "[subkey path]")); TABLE.Add(new CommandArgumentEntry("[string] -r", true, "[subkey path] -r(remove subkey and all child elements)")); CMD_SK_DELETE = new Command("SK-DELETE", TABLE, false, "Removes the specified subkey.", ExecutionLevel.Administrator, CLIMode.Regedit); CMD_SK_DELETE.SetFunction(() => { if (CMD_SK_DELETE.InputArgumentEntry.Arguments.Count == 0) { return("\nInvalid arguments!"); } RegistryHive hiveKey; string subKey = null; RegistryKey newKey = null; try { hiveKey = (RegistryHive)Enum.Parse(typeof(RegistryHive), CMD_SK_DELETE.InputArgumentEntry.Arguments[0].Value.ToString().Substring(0, CMD_SK_DELETE.InputArgumentEntry.Arguments[0].Value.ToString().IndexOf('\\'))); subKey = CMD_SK_DELETE.InputArgumentEntry.Arguments[0].Value.ToString().Substring(CMD_SK_DELETE.InputArgumentEntry.Arguments[0].Value.ToString().IndexOf('\\') + 1); } catch (Exception ex) { hiveKey = (RegistryHive)Enum.Parse(typeof(RegistryHive), EnvironmentVariables.GetCurrentValue("SUBKEY").ToString().Substring(0, EnvironmentVariables.GetCurrentValue("SUBKEY").ToString().IndexOf('\\'))); subKey = EnvironmentVariables.GetCurrentValue("SUBKEY").ToString().Substring(EnvironmentVariables.GetCurrentValue("SUBKEY").ToString().IndexOf('\\') + 1) + CMD_SK_DELETE.InputArgumentEntry.Arguments[0].Value.ToString(); } try { newKey = RegistryKey.OpenBaseKey(hiveKey, RegistryView.Default).OpenSubKey(subKey); if (newKey == null) { Debug.WriteLine(hiveKey.ToString() + " || " + CMD_SK_DELETE.InputArgumentEntry.Arguments[0].Value.ToString().Substring(CMD_SK_DELETE.InputArgumentEntry.Arguments[0].Value.ToString().IndexOf('\\') + 1)); return("\nSubkey not found!"); } else if (newKey == RegistryKey.OpenBaseKey((RegistryHive)Enum.Parse(typeof(RegistryHive), EnvironmentVariables.GetCurrentValue("SUBKEY").ToString().Substring(0, EnvironmentVariables.GetCurrentValue("SUBKEY").ToString().IndexOf('\\'))), RegistryView.Default).OpenSubKey(EnvironmentVariables.GetCurrentValue("SUBKEY").ToString().Substring(EnvironmentVariables.GetCurrentValue("SUBKEY").ToString().IndexOf('\\') + 1))) { return("\nCannot delete current subkey."); } else { if (CMD_SK_DELETE.InputArgumentEntry.Arguments.Exists(x => x.Call == "-r")) { RegistryKey.OpenBaseKey(hiveKey, RegistryView.Default).DeleteSubKeyTree(subKey); } else { RegistryKey.OpenBaseKey(hiveKey, RegistryView.Default).DeleteSubKey(subKey); } } } catch (Exception ex) { IOInteractLayer.StandardError(CMD_SK_DELETE, ex); } return(""); }); return(CMD_SK_DELETE); }
public Command GetCommand() { TABLE.Add(new CommandArgumentEntry("-a", false, "-a(show all information)")); TABLE.Add(new CommandArgumentEntry("[string]", false, "[name filter]")); TABLE.Add(new CommandArgumentEntry("[string] -a", true, "[name filter] -a(show all information)")); CMD_GETNICS = new Command("GETNICS", TABLE, true, "Returns interface information.", ExecutionLevel.User, CLIMode.Default); CMD_GETNICS.SetFunction(() => { NetworkInterfaceDiscovery nics = new NetworkInterfaceDiscovery(); NetworkInterface[] nic_array = nics.GetInterfaces().Result; if (CMD_GETNICS.InputArgumentEntry.Arguments.Count == 0) { for (int i = 0; i < nic_array.Length; i++) { IOInteractLayer.StandardOutput(CMD_GETNICS, $"\nName: {nic_array[i].Name}\nIP Address: {nic_array[i].IPAddress}\nDefault gateway: {nic_array[i].DefaultGateway}\nSubnet mask: {nic_array[i].SubnetMask}\n"); } } else if (CMD_GETNICS.InputArgumentEntry.Arguments.Count == 1) { if (CMD_GETNICS.InputArgumentEntry.Arguments[0].Call == "-a") { for (int i = 0; i < nic_array.Length; i++) { IOInteractLayer.StandardOutput(CMD_GETNICS, $"\nName: {nic_array[i].Name}\nIP address: {nic_array[i].IPAddress}\nDefault gateway: {nic_array[i].DefaultGateway}\nSubnet mask: {nic_array[i].SubnetMask}\nMAC address: {nic_array[i].MACAddress}\nInstance ID: {nic_array[i].InstanceID}\nSpeed: {nic_array[i].Speed}\nStatus: {nic_array[i].Status}\nType: {nic_array[i].Type}\nDescription: {nic_array[i].Description}\n"); } } else { Interpreter interpreter = new Interpreter(CMD_GETNICS.InputArgumentEntry.Arguments[0].Value.ToString()); for (int i = 0; i < nic_array.Length; i++) { if (interpreter.GetResult(nic_array[i].Name)) { IOInteractLayer.StandardOutput(CMD_GETNICS, $"\nName: {nic_array[i].Name}\nIP Address: {nic_array[i].IPAddress}\nDefault gateway: {nic_array[i].DefaultGateway}\nSubnet mask: {nic_array[i].SubnetMask}\n"); } } } } else { for (int i = 0; i < nic_array.Length; i++) { Interpreter interpreter = new Interpreter(CMD_GETNICS.InputArgumentEntry.Arguments[0].Value.ToString()); if (interpreter.GetResult(nic_array[i].Name)) { IOInteractLayer.StandardOutput(CMD_GETNICS, $"\nName: {nic_array[i].Name}\nIP address: {nic_array[i].IPAddress}\nDefault gateway: {nic_array[i].DefaultGateway}\nSubnet mask: {nic_array[i].SubnetMask}\nMAC address: {nic_array[i].MACAddress}\nInstance ID: {nic_array[i].InstanceID}\nSpeed: {nic_array[i].Speed}\nStatus: {nic_array[i].Status}\nType: {nic_array[i].Type}\nDescription: {nic_array[i].Description}\n"); } } } return(""); }); return(CMD_GETNICS); }
public Command GetCommand() { TABLE.Add(new CommandArgumentEntry("[string]", false, "[file path]")); CMD_EXEC = new Command("EXEC", TABLE, false, "Executes commands from the specified file(one command per line). Asynchronous commands will not wait for the previous command to finish.", ExecutionLevel.User, CLIMode.Default); CMD_EXEC.SetAsyncFunction(async() => { string path = null; if (File.Exists(CMD_EXEC.InputArgumentEntry.Arguments[0].Value.ToString()) && CMD_EXEC.InputArgumentEntry.Arguments[0].Value.ToString().Contains(":")) { path = CMD_EXEC.InputArgumentEntry.Arguments[0].Value.ToString(); } else if (File.Exists(EnvironmentVariables.GetCurrentValue("DIRECTORY") + CMD_EXEC.InputArgumentEntry.Arguments[0].Value.ToString())) { path = EnvironmentVariables.GetCurrentValue("DIRECTORY") + CMD_EXEC.InputArgumentEntry.Arguments[0].Value.ToString(); } else { return("\nInvalid path!"); } string[] lines = File.ReadAllLines(path); Command[] commands = new Command[lines.Length]; for (int i = 0; i < lines.Length; i++) { commands[i] = ((CommandManagement)EnvironmentVariables.GetCurrentValue("CMD_MGMT")).GetCommand(lines[i].Trim(), (CLIMode)Enum.Parse(typeof(CLIMode), (string)EnvironmentVariables.GetCurrentValue("CLI_MODE")) == CLIMode.Default ? (CommandPool)EnvironmentVariables.GetCurrentValue("DEF_CMD_POOL") : (CommandPool)EnvironmentVariables.GetCurrentValue("REG_CMD_POOL")); } for (int i = 0; i < commands.Length; i++) { try { if (commands[i].AsyncFunction == null) { ((TextEditor)EnvironmentVariables.GetCurrentValue("IOFIELD")).Dispatcher.Invoke(() => { ((CommandManagement)EnvironmentVariables.GetCurrentValue("CMD_MGMT")).ExecuteCommand(commands[i]); }); } else { await((CommandManagement)EnvironmentVariables.GetCurrentValue("CMD_MGMT")).ExecuteAsyncCommand(commands[i]); } } catch (Exception ex) { ((TextEditor)EnvironmentVariables.GetCurrentValue("IOFIELD")).Dispatcher.Invoke(() => { IOInteractLayer.StandardError(commands[i], ex); }); } } return(""); }); return(CMD_EXEC); }
private void Main_PreviewKeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Enter) { IOInteractLayer.StandardOutput(CMD_WORDGEN, $"\nGenerated: {processedWords}\nLast word: {currentWord}\nProgress: {progress:0.00}%\n"); } if (e.Key == Key.Escape) { CTS.Cancel(); IOInteractLayer.StandardOutput(CMD_WORDGEN, "\nProcess interrupted."); } }
private void Main_KeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Escape) { CTS.Cancel(); ((TextEditor)EnvironmentVariables.GetCurrentValue("IOFIELD")).IsReadOnly = false; ((TextEditor)EnvironmentVariables.GetCurrentValue("IOFIELD")).PreviewKeyDown -= Main_KeyDown; } if (e.Key == Key.Enter) { IOInteractLayer.StandardOutput(CMD_HASHCRACK, $"\nProcessed words: {processedWords}\nProgress: {progress:0.00}%\nLast word: {currentWord}\nLast hash: {currentResult}"); } }
public Command GetCommand() { TABLE.Add(new CommandArgumentEntry("[string]", false, "[file path]")); TABLE.Add(new CommandArgumentEntry("[string] [string]", true, "[file path] [arguments]")); CMD_START = new Command("START", TABLE, false, "Attempts to start the specified executable, with the specified arguments.", ExecutionLevel.User, CLIMode.Default); CMD_START.SetFunction(() => { if (CMD_START.InputArgumentEntry.Arguments.Count == 0) { return("\nInvalid arguments!"); } Process p = null; string path = null; if (File.Exists(CMD_START.InputArgumentEntry.Arguments[0].Value.ToString()) && CMD_START.InputArgumentEntry.Arguments[0].Value.ToString().Contains(":")) { path = CMD_START.InputArgumentEntry.Arguments[0].Value.ToString(); } else if (File.Exists(EnvironmentVariables.GetCurrentValue("DIRECTORY") + CMD_START.InputArgumentEntry.Arguments[0].Value.ToString())) { path = EnvironmentVariables.GetCurrentValue("DIRECTORY") + CMD_START.InputArgumentEntry.Arguments[0].Value.ToString(); } else { return("\nExecutable not found!"); } p = new Process(); p.StartInfo.FileName = path; p.StartInfo.WorkingDirectory = path.Replace(Path.GetFileName(path), ""); p.StartInfo.UseShellExecute = false; p.StartInfo.CreateNoWindow = false; if (CMD_START.InputArgumentEntry.Arguments.Count == 2) { p.StartInfo.Arguments = CMD_START.InputArgumentEntry.Arguments[1].Value.ToString(); } try { p.Start(); } catch (Exception ex) { IOInteractLayer.StandardError(CMD_START, ex); } return(""); }); return(CMD_START); }
public Command GetCommand() { TABLE.Add(new CommandArgumentEntry("[string]", false, "[driver name]")); CMD_DRIVER_INFO = new Command("DRIVER-INFO", TABLE, false, "Returns infromation about the specified driver.", ExecutionLevel.User, CLIMode.Default); CMD_DRIVER_INFO.SetFunction(() => { if (CMD_DRIVER_INFO.InputArgumentEntry.Arguments.Count == 0) { return("\nInvalid arguments!"); } DriverInfo inf = new DriverInfo(); List <DriverInfo> inf_list = inf.GetDriverInfo().ToList(); if (inf_list.Exists(x => x.DisplayName == CMD_DRIVER_INFO.InputArgumentEntry.Arguments[0].Value.ToString())) { inf = inf_list.Find(x => x.DisplayName == CMD_DRIVER_INFO.InputArgumentEntry.Arguments[0].Value.ToString()); IOInteractLayer.StandardOutput(CMD_DRIVER_INFO, $"\nAccept pause: {inf.AcceptPause}" + $"\nAccept stop: {inf.AcceptStop}" + $"\nCaption: {inf.Caption}" + $"\nCreation class name: {inf.CreationClassName}" + $"\nDescription: {inf.Description}" + $"\nDesktop interact: {inf.DesktopInteract}" + $"\nDisplay name: {inf.DisplayName}" + $"\nError control: {inf.ErrorControl}" + $"\nExit code: {inf.ExitCode}" + $"\nInstall date: {inf.InstallDate}" + $"\nName: {inf.Name}" + $"\nPath name: {inf.PathName}" + $"\nService specific exit code: {inf.ServiceSpecificExitCode}" + $"\nService type: {inf.ServiceType}" + $"\nStarted: {inf.Started}" + $"\nStart mode: {inf.StartMode}" + $"\nStart name: {inf.StartName}" + $"\nState: {inf.State}" + $"\nStatus: {inf.Status}" + $"\nSystem creation class name: {inf.SystemCreationClassName}" + $"\nSystem name: {inf.SystemName}" + $"\nTag ID: {inf.TagId}"); } else { IOInteractLayer.StandardOutput(CMD_DRIVER_INFO, "\nDriver not found!"); } return(""); }); return(CMD_DRIVER_INFO); }
public Command GetCommand() { TABLE.Add(new CommandArgumentEntry("[string] [string]", false, "[name] [value]")); CMD_VAL_SET = new Command("VAL-SET", TABLE, false, "Modifies an existing registry value in the current subkey.", ExecutionLevel.Administrator, CLIMode.Regedit); CMD_VAL_SET.SetFunction(() => { RegistryKey key = RegistryKey.OpenBaseKey((RegistryHive)Enum.Parse(typeof(RegistryHive), EnvironmentVariables.GetCurrentValue("SUBKEY").ToString().Substring(0, EnvironmentVariables.GetCurrentValue("SUBKEY").ToString().IndexOf("\\"))), RegistryView.Default).OpenSubKey(EnvironmentVariables.GetCurrentValue("SUBKEY").ToString().Substring(EnvironmentVariables.GetCurrentValue("SUBKEY").ToString().IndexOf("\\") + 1), true); if (CMD_VAL_SET.InputArgumentEntry.Arguments[0].Value.ToString().ToList().Contains('=') && !CMD_VAL_SET.InputArgumentEntry.Arguments[0].Value.ToString().EndsWith("=")) { string name = CMD_VAL_SET.InputArgumentEntry.Arguments[0].Value.ToString(); string value = CMD_VAL_SET.InputArgumentEntry.Arguments[1].Value.ToString(); RegistryValueKind type = key.GetValueKind(name); if (key.GetValueNames().Contains(name)) { try { if (type == RegistryValueKind.DWord || type == RegistryValueKind.QWord || type == RegistryValueKind.Binary) { key.SetValue(name, int.Parse(value), type); } else { key.SetValue(name, value); } } catch (Exception ex) { IOInteractLayer.StandardError(CMD_VAL_SET, ex); } } else { return("\nValue not found!"); } } else { return("\nIncorrect format!"); } return(""); }); return(CMD_VAL_SET); }
public Command GetCommand() { TABLE.Add(new CommandArgumentEntry("[string] [string]", false, "[old name] [new name]")); CMD_VAL_RENAME = new Command("VAL-RENAME", TABLE, false, "", ExecutionLevel.Administrator, CLIMode.Regedit); CMD_VAL_RENAME.SetFunction(() => { RegistryKey key = RegistryKey.OpenBaseKey((RegistryHive)Enum.Parse(typeof(RegistryHive), EnvironmentVariables.GetCurrentValue("SUBKEY").ToString().Substring(0, EnvironmentVariables.GetCurrentValue("SUBKEY").ToString().IndexOf("\\"))), RegistryView.Default).OpenSubKey(EnvironmentVariables.GetCurrentValue("SUBKEY").ToString().Substring(EnvironmentVariables.GetCurrentValue("SUBKEY").ToString().IndexOf("\\") + 1), true); string[] names = null; try { names = key.GetValueNames(); if (names.Contains(CMD_VAL_RENAME.InputArgumentEntry.Arguments[0].Value.ToString())) { if (names.Contains(CMD_VAL_RENAME.InputArgumentEntry.Arguments[1].Value.ToString())) { return("\nA value with the specified new name already exist!"); } else { string name = CMD_VAL_RENAME.InputArgumentEntry.Arguments[0].Value.ToString(); RegistryValueKind type = key.GetValueKind(name); object value = key.GetValue(name); key.DeleteValue(name); key.SetValue(CMD_VAL_RENAME.InputArgumentEntry.Arguments[1].Value.ToString(), value, type); } } else { return("\nValue not found!"); } } catch (Exception ex) { IOInteractLayer.StandardError(CMD_VAL_RENAME, ex); } return(""); }); return(CMD_VAL_RENAME); }
public Command GetCommand() { CMD_DRIVER_CHECK.SetFunction(() => { DriverInfo inf = new DriverInfo(); DriverInfo[] issues = inf.GetDriverIssues(); if (issues == null || issues.Length == 0) { return("\nNo issues found."); } for (int i = 0; i < issues.Length; i++) { IOInteractLayer.StandardOutput(CMD_DRIVER_CHECK, $"\nAccept pause: {issues[i].AcceptPause}" + $"\nAccept stop: {issues[i].AcceptStop}" + $"\nCaption: {issues[i].Caption}" + $"\nCreation class name: {issues[i].CreationClassName}" + $"\nDescription: {issues[i].Description}" + $"\nDesktop interact: {issues[i].DesktopInteract}" + $"\nDisplay name: {issues[i].DisplayName}" + $"\nError control: {issues[i].ErrorControl}" + $"\nExit code: {issues[i].ExitCode}" + $"\nInstall date: {issues[i].InstallDate}" + $"\nName: {issues[i].Name}" + $"\nPath name: {issues[i].PathName}" + $"\nService specific exit code: {issues[i].ServiceSpecificExitCode}" + $"\nService type: {issues[i].ServiceType}" + $"\nStarted: {issues[i].Started}" + $"\nStart mode: {issues[i].StartMode}" + $"\nStart name: {issues[i].StartName}" + $"\nState: {issues[i].State}" + $"\nStatus: {issues[i].Status}" + $"\nSystem creation class name: {issues[i].SystemCreationClassName}" + $"\nSystem name: {issues[i].SystemName}" + $"\nTag ID: {issues[i].TagId}\n"); } return(""); }); return(CMD_DRIVER_CHECK); }
public Command GetCommand() { TABLE.Add(new CommandArgumentEntry("[int]", false, "[entry index]")); TABLE.Add(new CommandArgumentEntry("[int] -r", false, "[entry index] -r(reverse search)")); CMD_HISTORY_GETENTRY = new Command("HISTORY-GETENTRY", TABLE, false, "Returns the specified history entry of the current CLI mode.", ExecutionLevel.User, CLIMode.Any); CMD_HISTORY_GETENTRY.SetFunction(() => { int entry = (int)CMD_HISTORY_GETENTRY.InputArgumentEntry.Arguments.Find(x => x.Call == "").Value; string var_name = (string)EnvironmentVariables.GetCurrentValue("CLI_MODE") == "Default" ? "DEF_HIST_SIZE" : "REG_HIST_SIZE"; if ((int)EnvironmentVariables.GetCurrentValue(var_name) >= entry && entry > 0) { if (CMD_HISTORY_GETENTRY.InputArgumentEntry.Arguments.Exists(x => x.Call == "-r")) { IOInteractLayer.StandardOutput(CMD_HISTORY_GETENTRY, "\n\t" + ((List <string>)EnvironmentVariables.GetCurrentValue(var_name))[((List <string>)EnvironmentVariables.GetCurrentValue(var_name)).Count - (int)CMD_HISTORY_GETENTRY.InputArgumentEntry.Arguments.Find(x => x.Call == "").Value]); } else { IOInteractLayer.StandardOutput(CMD_HISTORY_GETENTRY, "\n\t" + ((List <string>)EnvironmentVariables.GetCurrentValue(var_name))[(int)CMD_HISTORY_GETENTRY.InputArgumentEntry.Arguments.Find(x => x.Call == "").Value]); } } return(""); }); return(CMD_HISTORY_GETENTRY); }
public Command GetCommand() { TABLE.Add(new CommandArgumentEntry("[string]", false, "[registry path/filter]")); TABLE.Add(new CommandArgumentEntry("[string] [string]", false, "[registry path] [filter]")); CMD_SK_GET = new Command("SK-GET", TABLE, true, "Returns all subkeys in the specified subkey(current subkey if not specified).", ExecutionLevel.Administrator, CLIMode.Regedit); CMD_SK_GET.SetFunction(() => { RegistryHive hiveKey; string subKey = null; RegistryKey newKey = null; string[] keys = null; Interpreter interpreter = null; switch (CMD_SK_GET.InputArgumentEntry.Arguments.Count) { case 0: hiveKey = (RegistryHive)Enum.Parse(typeof(RegistryHive), EnvironmentVariables.GetCurrentValue("SUBKEY").ToString().Substring(0, EnvironmentVariables.GetCurrentValue("SUBKEY").ToString().IndexOf("\\"))); subKey = EnvironmentVariables.GetCurrentValue("SUBKEY").ToString().Substring(EnvironmentVariables.GetCurrentValue("SUBKEY").ToString().IndexOf("\\") + 1); newKey = RegistryKey.OpenBaseKey(hiveKey, RegistryView.Default).OpenSubKey(subKey); try { keys = newKey.GetSubKeyNames(); for (int i = 0; i < keys.Length; i++) { IOInteractLayer.StandardOutput(CMD_SK_GET, "\n" + keys[i]); } } catch (Exception ex) { IOInteractLayer.StandardError(CMD_SK_GET, ex); } break; case 1: try { //Check if input is full path hiveKey = (RegistryHive)Enum.Parse(typeof(RegistryHive), CMD_SK_GET.InputArgumentEntry.Arguments[0].Value.ToString().Substring(0, CMD_SK_GET.InputArgumentEntry.Arguments[0].Value.ToString().IndexOf("\\"))); subKey = CMD_SK_GET.InputArgumentEntry.Arguments[0].Value.ToString().Substring(CMD_SK_GET.InputArgumentEntry.Arguments[0].Value.ToString().IndexOf("\\") + 1); newKey = RegistryKey.OpenBaseKey(hiveKey, RegistryView.Default).OpenSubKey(subKey); } catch (Exception) { //Check if input is relative path hiveKey = (RegistryHive)Enum.Parse(typeof(RegistryHive), EnvironmentVariables.GetCurrentValue("SUBKEY").ToString().Substring(0, EnvironmentVariables.GetCurrentValue("SUBKEY").ToString().IndexOf("\\"))); subKey = EnvironmentVariables.GetCurrentValue("SUBKEY").ToString().Substring(EnvironmentVariables.GetCurrentValue("SUBKEY").ToString().IndexOf("\\") + 1) + CMD_SK_GET.InputArgumentEntry.Arguments[0].Value.ToString(); newKey = RegistryKey.OpenBaseKey(hiveKey, RegistryView.Default).OpenSubKey(subKey); if (newKey == null) { try { //Check if input is hive if (CMD_SK_GET.InputArgumentEntry.Arguments[0].Value.ToString().Contains("\\")) { hiveKey = (RegistryHive)Enum.Parse(typeof(RegistryHive), CMD_SK_GET.InputArgumentEntry.Arguments[0].Value.ToString().Substring(0, CMD_SK_GET.InputArgumentEntry.Arguments[0].Value.ToString().IndexOf("\\"))); } else { hiveKey = (RegistryHive)Enum.Parse(typeof(RegistryHive), CMD_SK_GET.InputArgumentEntry.Arguments[0].Value.ToString()); } subKey = ""; newKey = RegistryKey.OpenBaseKey(hiveKey, RegistryView.Default).OpenSubKey(subKey); } catch (Exception) { //Input is filter hiveKey = (RegistryHive)Enum.Parse(typeof(RegistryHive), EnvironmentVariables.GetCurrentValue("SUBKEY").ToString().Substring(0, EnvironmentVariables.GetCurrentValue("SUBKEY").ToString().IndexOf("\\"))); subKey = EnvironmentVariables.GetCurrentValue("SUBKEY").ToString().Substring(EnvironmentVariables.GetCurrentValue("SUBKEY").ToString().IndexOf("\\") + 1); newKey = RegistryKey.OpenBaseKey(hiveKey, RegistryView.Default).OpenSubKey(subKey); interpreter = new Interpreter(CMD_SK_GET.InputArgumentEntry.Arguments[0].Value.ToString()); } } } try { keys = newKey.GetSubKeyNames(); if (interpreter == null) { for (int i = 0; i < keys.Length; i++) { IOInteractLayer.StandardOutput(CMD_SK_GET, "\n" + keys[i]); } } else { for (int i = 0; i < keys.Length; i++) { if (interpreter.GetResult(keys[i])) { IOInteractLayer.StandardOutput(CMD_SK_GET, "\n" + keys[i]); } } } } catch (Exception ex) { IOInteractLayer.StandardError(CMD_SK_GET, ex); } break; case 2: try { //Check if input is full path hiveKey = (RegistryHive)Enum.Parse(typeof(RegistryHive), CMD_SK_GET.InputArgumentEntry.Arguments[0].Value.ToString().Substring(0, CMD_SK_GET.InputArgumentEntry.Arguments[0].Value.ToString().IndexOf("\\"))); subKey = CMD_SK_GET.InputArgumentEntry.Arguments[0].Value.ToString().Substring(CMD_SK_GET.InputArgumentEntry.Arguments[0].Value.ToString().IndexOf("\\") + 1); newKey = RegistryKey.OpenBaseKey(hiveKey, RegistryView.Default).OpenSubKey(subKey); } catch (Exception) { //Check if input relative full path hiveKey = (RegistryHive)Enum.Parse(typeof(RegistryHive), EnvironmentVariables.GetCurrentValue("SUBKEY").ToString().Substring(0, EnvironmentVariables.GetCurrentValue("SUBKEY").ToString().IndexOf("\\"))); subKey = EnvironmentVariables.GetCurrentValue("SUBKEY").ToString().Substring(EnvironmentVariables.GetCurrentValue("SUBKEY").ToString().IndexOf("\\") + 1) + CMD_SK_GET.InputArgumentEntry.Arguments[0].Value.ToString(); newKey = RegistryKey.OpenBaseKey(hiveKey, RegistryView.Default).OpenSubKey(subKey); if (newKey == null) { try { //Check if input is hive if (CMD_SK_GET.InputArgumentEntry.Arguments[0].Value.ToString().Contains("\\")) { hiveKey = (RegistryHive)Enum.Parse(typeof(RegistryHive), CMD_SK_GET.InputArgumentEntry.Arguments[0].Value.ToString().Substring(0, CMD_SK_GET.InputArgumentEntry.Arguments[0].Value.ToString().IndexOf("\\"))); } else { hiveKey = (RegistryHive)Enum.Parse(typeof(RegistryHive), CMD_SK_GET.InputArgumentEntry.Arguments[0].Value.ToString()); } subKey = ""; newKey = RegistryKey.OpenBaseKey(hiveKey, RegistryView.Default).OpenSubKey(subKey); } catch (Exception) { return("\nSubkey not found!"); } } } try { interpreter = new Interpreter(CMD_SK_GET.InputArgumentEntry.Arguments[1].Value.ToString()); keys = newKey.GetSubKeyNames(); for (int i = 0; i < keys.Length; i++) { if (interpreter.GetResult(keys[i])) { IOInteractLayer.StandardOutput(CMD_SK_GET, "\n" + keys[i]); } } } catch (Exception ex) { IOInteractLayer.StandardError(CMD_SK_GET, ex); } break; } return(""); }); return(CMD_SK_GET); }
public Command GetCommand() { TABLE.Add(new CommandArgumentEntry("[string]", false, "[path/result filter]")); TABLE.Add(new CommandArgumentEntry("[string] [string]", true, "[path] [result filter]")); CMD_DIR = new Command("DIR", TABLE, true, "Returns the file system entries contained by the current directory, or the provided relative/full path.", ExecutionLevel.User, CLIMode.Default); CMD_DIR.SetFunction(() => { string[] entries = null; if (CMD_DIR.InputArgumentEntry.Arguments.Count == 0) { entries = Directory.GetFileSystemEntries((string)EnvironmentVariables.GetCurrentValue("DIRECTORY")); for (int i = 0; i < entries.Length; i++) { IOInteractLayer.StandardOutput(CMD_DIR, "\n\t" + entries[i]); } } else { Interpreter interpreter; string dir = null; if (CMD_DIR.InputArgumentEntry.Arguments.Count == 1) { dir = Directory.Exists((string)CMD_DIR.InputArgumentEntry.Arguments[0].Value) && CMD_DIR.InputArgumentEntry.Arguments[0].Value.ToString().Contains(":") ? (string)CMD_DIR.InputArgumentEntry.Arguments[0].Value : Directory.Exists((string)EnvironmentVariables.GetCurrentValue("DIRECTORY") + (string)CMD_DIR.InputArgumentEntry.Arguments[0].Value) ? (string)EnvironmentVariables.GetCurrentValue("DIRECTORY") + (string)CMD_DIR.InputArgumentEntry.Arguments[0].Value : null; if (dir == null) { interpreter = new Interpreter((string)CMD_DIR.InputArgumentEntry.Arguments[0].Value); entries = Directory.GetFileSystemEntries((string)EnvironmentVariables.GetCurrentValue("DIRECTORY")); for (int i = 0; i < entries.Length; i++) { if (interpreter.GetResult(entries[i])) { IOInteractLayer.StandardOutput(CMD_DIR, "\n\t" + entries[i]); } } } else { entries = Directory.GetFileSystemEntries(dir); for (int i = 0; i < entries.Length; i++) { IOInteractLayer.StandardOutput(CMD_DIR, "\n\t" + entries[i]); } } } else { dir = Directory.Exists((string)CMD_DIR.InputArgumentEntry.Arguments[0].Value) && CMD_DIR.InputArgumentEntry.Arguments[0].Value.ToString().Contains(":") ? (string)CMD_DIR.InputArgumentEntry.Arguments[0].Value : Directory.Exists((string)EnvironmentVariables.GetCurrentValue("DIRECTORY") + (string)CMD_DIR.InputArgumentEntry.Arguments[0].Value) ? (string)EnvironmentVariables.GetCurrentValue("DIRECTORY") + (string)CMD_DIR.InputArgumentEntry.Arguments[0].Value : null; if (dir != null) { interpreter = new Interpreter((string)CMD_DIR.InputArgumentEntry.Arguments[1].Value); entries = Directory.GetFileSystemEntries(dir); for (int i = 0; i < entries.Length; i++) { if (interpreter.GetResult(entries[i])) { IOInteractLayer.StandardOutput(CMD_DIR, "\n\t" + entries[i]); } } } } } return(""); }); return(CMD_DIR); }
public Command GetCommand() { CT = CTS.Token; TABLE.Add(new CommandArgumentEntry("[string] [int]", true, "[charset] [word length]")); TABLE.Add(new CommandArgumentEntry("[string] [int] -out=[string]", true, "[charset] [word length], -out=[output path]")); CMD_WORDGEN = new Command("WORDGEN", TABLE, false, "Generates all possible combinations of the specified characters(duplcates will be removed) at the specified length. The output file can be specified using the argumet'-out'. If the output file is not specified, wordgen attempts to create one in the current directory by the name of 'wordgen.txt'.", ExecutionLevel.User, CLIMode.Default); CMD_WORDGEN.SetAsyncFunction(async() => { try { await Task.Delay(0); ((TextEditor)EnvironmentVariables.GetCurrentValue("IOFIELD")).Dispatcher.Invoke(() => { ((TextEditor)EnvironmentVariables.GetCurrentValue("IOFIELD")).IsReadOnly = true; ((TextEditor)EnvironmentVariables.GetCurrentValue("IOFIELD")).PreviewKeyDown += Main_PreviewKeyDown; IOInteractLayer.StandardOutput(CMD_WORDGEN, "\n"); }); char[] charset = ((string)CMD_WORDGEN.InputArgumentEntry.Arguments[0].Value).ToCharArray().Distinct().ToArray(); int wordLength = (int)CMD_WORDGEN.InputArgumentEntry.Arguments[1].Value; int[] indexArray = new int[wordLength]; for (int i = 0; i < indexArray.Length; i++) { indexArray[i] = 0; } double count = Math.Pow(charset.Length, wordLength); string filePath = string.Empty; StreamWriter sw = null; if (CMD_WORDGEN.InputArgumentEntry.Arguments.Count == 3) { string path = (string)CMD_WORDGEN.InputArgumentEntry.Arguments[2].Value; string full_path = (string)EnvironmentVariables.GetCurrentValue("DIRECTORY") + (string)CMD_WORDGEN.InputArgumentEntry.Arguments[2].Value; if (Directory.Exists(path.Remove(path.LastIndexOf("\\"))) && path.Contains(":")) { sw = new StreamWriter(path); filePath = path; } else if (Directory.Exists(full_path.Remove(full_path.LastIndexOf("\\")))) { sw = new StreamWriter(full_path); filePath = full_path; } } else { sw = new StreamWriter((string)EnvironmentVariables.GetCurrentValue("DIRECTORY") + "wordgen.txt"); filePath = (string)EnvironmentVariables.GetCurrentValue("DIRECTORY") + "wordgen.txt"; } StringBuilder sb = new StringBuilder(); for (int k = 0; k < count; k++) { if (!CT.IsCancellationRequested) { for (int i = 0; i < indexArray.Length; i++) { if (indexArray[i] == charset.Length) { indexArray[i] = 0; if (i + 1 < wordLength) { indexArray[i + 1]++; } } } for (int i = 0; i < wordLength; i++) { sb.Append(charset[indexArray[i]]); } sw.WriteLine(sb.ToString()); currentWord = sb.ToString(); sb.Clear(); processedWords++; progress = processedWords / count * 100; indexArray[0]++; } else { break; } } sw.Close(); ((TextEditor)EnvironmentVariables.GetCurrentValue("IOFIELD")).Dispatcher.Invoke(() => { ((TextEditor)EnvironmentVariables.GetCurrentValue("IOFIELD")).IsReadOnly = false; ((TextEditor)EnvironmentVariables.GetCurrentValue("IOFIELD")).PreviewKeyDown -= Main_PreviewKeyDown; }); if (!CT.IsCancellationRequested) { FileInfo inf = new FileInfo(filePath); processedWords = 0; progress = 0; currentWord = string.Empty; return($"Process completed.\nGenerated words: {count}\nFile size: {inf.Length} bytes\n{(string)EnvironmentVariables.GetCurrentValue("DIRECTORY")}> "); } return(""); } catch (Exception ex) { IOInteractLayer.StandardError(CMD_WORDGEN, ex); return(""); } }); return(CMD_WORDGEN); }
public async Task GetDevices(string[] ipAddresses, ToolShed.ThisPC.NetworkInterface[] interfaces, bool resolveHostnames) { await Task.Delay(0); cts = new CancellationTokenSource(); ct = cts.Token; countdown = new CountdownEvent(1); async Task GHE_TASK(string entry) { if (!ct.IsCancellationRequested) { await Task.Delay(0); string name = ""; try { IPHostEntry hostEntry = Dns.GetHostEntry(entry.Split(' ')[0]); name = hostEntry.HostName; } catch (Exception) { name = "Unknown"; } ((TextEditor)EnvironmentVariables.GetCurrentValue("IOFIELD")).Dispatcher.Invoke(() => { try { IOInteractLayer.StandardOutput(CMD_NMAP, $"\nName: {name} || IP address: {entry.Split(' ')[0]} || MAC address: {entry.Split(' ')[1].Replace("-", ":").ToUpper()}"); } catch (Exception) { } }); } } Regex spacefix = new Regex("[ ]{2,}"); for (int i = 0; i < ipAddresses.Length; i++) { if (!ct.IsCancellationRequested) { ping = new Ping(); ping.PingCompleted += Ping_PingCompleted; countdown.AddCount(); try { ping.SendAsync(ipAddresses[i], 100); } catch (Exception) {} GC.Collect(); } else { return; } } countdown.Signal(); countdown.Wait(); string[] entries = null; List <Task> taskList = new List <Task>(); List <string> checked_ips = new List <string>(); for (int i = 0; i < interfaces.Length; i++) { if (interfaces[i].Status == "Up" && interfaces[i].Type != "Loopback" && interfaces[i].Type != "Tunnel") { if (!ct.IsCancellationRequested) { cmdProcess = new Process(); cmdProcess.StartInfo.CreateNoWindow = true; cmdProcess.StartInfo.UseShellExecute = false; cmdProcess.StartInfo.FileName = "arp"; cmdProcess.StartInfo.Arguments = "-a -N " + interfaces[i].IPAddress; cmdProcess.StartInfo.RedirectStandardOutput = true; cmdProcess.Start(); entries = cmdProcess.StandardOutput.ReadToEnd().Split('\n'); cmdProcess.Close(); for (int j = 3; j < entries.Length - 1; j++) { if (!ct.IsCancellationRequested) { entries[j] = spacefix.Replace(entries[j].Trim(), " "); if (!checked_ips.Contains(entries[j].Split(' ')[0])) { checked_ips.Add(entries[j].Split(' ')[0]); if (resolveHostnames) { taskList.Add(GHE_TASK(entries[j])); } else { ((TextEditor)EnvironmentVariables.GetCurrentValue("IOFIELD")).Dispatcher.Invoke(() => { IOInteractLayer.StandardOutput(CMD_NMAP, $"\nIP address: {entries[j].Split(' ')[0]} || MAC address: {entries[j].Split(' ')[1].Replace("-", ":").ToUpper()}"); }); } } } else { ((TextEditor)EnvironmentVariables.GetCurrentValue("IOFIELD")).Dispatcher.Invoke(() => { IOInteractLayer.StandardOutput(CMD_NMAP, "\nProcess interrupted."); ((TextEditor)EnvironmentVariables.GetCurrentValue("IOFIELD")).KeyDown -= Main_KeyDown; ((TextEditor)EnvironmentVariables.GetCurrentValue("IOFIELD")).IsReadOnly = false; }); return; } } await Task.WhenAll(taskList); } else { ((TextEditor)EnvironmentVariables.GetCurrentValue("IOFIELD")).Dispatcher.Invoke(() => { IOInteractLayer.StandardOutput(CMD_NMAP, "\nProcess interrupted."); ((TextEditor)EnvironmentVariables.GetCurrentValue("IOFIELD")).KeyDown -= Main_KeyDown; ((TextEditor)EnvironmentVariables.GetCurrentValue("IOFIELD")).IsReadOnly = false; }); return; } } } }
public Command GetCommand() { TABLE.Add(new CommandArgumentEntry("[string]", false, "[subkey path]")); CMD_SK_MAKE = new Command("SK-MAKE", TABLE, false, "Creates a new subkey.", ExecutionLevel.Administrator, CLIMode.Regedit); CMD_SK_MAKE.SetFunction(() => { if (CMD_SK_MAKE.InputArgumentEntry.Arguments.Count == 0) { return("\nInvalid arguments!"); } RegistryHive hiveKey = (RegistryHive)Enum.Parse(typeof(RegistryHive), EnvironmentVariables.GetCurrentValue("SUBKEY").ToString().Substring(0, EnvironmentVariables.GetCurrentValue("SUBKEY").ToString().IndexOf("\\"))); string subKey = EnvironmentVariables.GetCurrentValue("SUBKEY").ToString().Substring(EnvironmentVariables.GetCurrentValue("SUBKEY").ToString().IndexOf("\\") + 1); RegistryKey newKey = null; try { if (CMD_SK_MAKE.InputArgumentEntry.Arguments[0].Value.ToString().Contains("\\")) { hiveKey = (RegistryHive)Enum.Parse(typeof(RegistryHive), CMD_SK_MAKE.InputArgumentEntry.Arguments[0].Value.ToString().Substring(0, CMD_SK_MAKE.InputArgumentEntry.Arguments[0].Value.ToString().IndexOf("\\"))); subKey = CMD_SK_MAKE.InputArgumentEntry.Arguments[0].Value.ToString().Substring(CMD_SK_MAKE.InputArgumentEntry.Arguments[0].Value.ToString().IndexOf("\\") + 1); } else { hiveKey = (RegistryHive)Enum.Parse(typeof(RegistryHive), CMD_SK_MAKE.InputArgumentEntry.Arguments[0].Value.ToString()); subKey = ""; } newKey = RegistryKey.OpenBaseKey(hiveKey, RegistryView.Default).OpenSubKey(subKey); if (newKey == null) { try { RegistryKey.OpenBaseKey(hiveKey, RegistryView.Default).CreateSubKey(subKey); } catch (Exception ex) { IOInteractLayer.StandardError(CMD_SK_MAKE, ex); } } else { return("\nSubkey already exists!"); } } catch (Exception) { subKey += CMD_SK_MAKE.InputArgumentEntry.Arguments[0].Value.ToString(); newKey = RegistryKey.OpenBaseKey(hiveKey, RegistryView.Default).OpenSubKey(subKey); if (newKey == null) { try { RegistryKey.OpenBaseKey(hiveKey, RegistryView.Default).CreateSubKey(subKey); } catch (Exception ex) { IOInteractLayer.StandardError(CMD_SK_MAKE, ex); } } else { return("\nSubkey already exists!"); } } return(""); }); return(CMD_SK_MAKE); }
public Command GetCommand() { TABLE.Add(new CommandArgumentEntry("[string]", false, "[IP address/hostname]")); TABLE.Add(new CommandArgumentEntry("[string] -t", true, "[IP address/hostname] -t(ping indefinitely)")); CMD_PING = new Command("PING", TABLE, false, "", ExecutionLevel.User, CLIMode.Default); CMD_PING.SetAsyncFunction(async() => { if (CMD_PING.InputArgumentEntry.Arguments.Count == 0) { return("Invalid arguments!"); } else { Times = new List <long>(); Sent = 0; Received = 0; Lost = 0; ((TextEditor)EnvironmentVariables.GetCurrentValue("IOFIELD")).Dispatcher.Invoke(() => { ((TextEditor)EnvironmentVariables.GetCurrentValue("IOFIELD")).IsReadOnly = true; ((TextEditor)EnvironmentVariables.GetCurrentValue("IOFIELD")).PreviewKeyDown += Main_PreviewKeyDown; }); CTS = new CancellationTokenSource(); CT = CTS.Token; Ping p = new Ping(); PingReply r = null; async Task PING_TASK() { try { Sent++; r = p.Send(CMD_PING.InputArgumentEntry.Arguments[0].Value.ToString(), 5000); ((TextEditor)EnvironmentVariables.GetCurrentValue("IOFIELD")).Dispatcher.Invoke(() => { IOInteractLayer.StandardOutput(CMD_PING, $"\nReply from {r.Address}: bytes={r.Buffer.Length} time={r.RoundtripTime}ms TTL={r.Options.Ttl}"); Times.Add(r.RoundtripTime); }); Received++; } catch (PingException ex) { Lost++; ((TextEditor)EnvironmentVariables.GetCurrentValue("IOFIELD")).Dispatcher.Invoke(() => { IOInteractLayer.StandardError(CMD_PING, ex); }); } if (!CT.IsCancellationRequested && CMD_PING.InputArgumentEntry.Arguments.Exists(x => x.Call == "-t")) { await Task.Delay(1000); await PING_TASK(); } } if (CMD_PING.InputArgumentEntry.Arguments.Exists(x => x.Call == "-t")) { await PING_TASK(); } else { for (int i = 0; i < 4; i++) { await PING_TASK(); await Task.Delay(1000); } } } ((TextEditor)EnvironmentVariables.GetCurrentValue("IOFIELD")).Dispatcher.Invoke(() => { ((TextEditor)EnvironmentVariables.GetCurrentValue("IOFIELD")).IsReadOnly = false; ((TextEditor)EnvironmentVariables.GetCurrentValue("IOFIELD")).PreviewKeyDown -= Main_PreviewKeyDown; }); return($"\nPing statistics for {CMD_PING.InputArgumentEntry.Arguments[0].Value}:\n\tPackets: Sent = {Sent}, Received = {Received}, Lost = {Lost}, ({Lost / Sent * 100:0.00}% loss),\nApproximate round trip times in milli-seconds:\n\tMinimum = {Times.Min()}ms, Maximum = {Times.Max()}ms, Average = {Times.Average():0}ms"); }); return(CMD_PING); }
public Command GetCommand() { CTS = new CancellationTokenSource(); CT = CTS.Token; TABLE.Add(new CommandArgumentEntry("[string] [string]", true, "[wordlist path] [hash]")); CMD_HASHCRACK = new Command("HASHCRACK", TABLE, false, "Starts a search for a matching hash value in the specified wordlist. Supported hash types: SHA1, SHA256, SHA384, SHA512.", ExecutionLevel.User, CLIMode.Default); CMD_HASHCRACK.SetAsyncFunction(async() => { processedWords = 0; progress = 0; count = 0; currentWord = null; currentResult = null; try { ((TextEditor)EnvironmentVariables.GetCurrentValue("IOFIELD")).Dispatcher.Invoke(() => { ((TextEditor)EnvironmentVariables.GetCurrentValue("IOFIELD")).IsReadOnly = true; ((TextEditor)EnvironmentVariables.GetCurrentValue("IOFIELD")).PreviewKeyDown += Main_KeyDown; }); HashType hashType; string result = null; async Task HASH_TASK(string word) { await Task.Delay(0); object hashingObject = null; string hash = null; if (result == null) { switch (hashType) { case HashType.SHA1: hashingObject = SHA1.Create(); hash = BitConverter.ToString(((SHA1)hashingObject).ComputeHash(Encoding.UTF8.GetBytes(word))).Replace("-", ""); break; case HashType.SHA256: hashingObject = SHA256.Create(); hash = BitConverter.ToString(((SHA256)hashingObject).ComputeHash(Encoding.UTF8.GetBytes(word))).Replace("-", ""); break; case HashType.SHA384: hashingObject = SHA384.Create(); hash = BitConverter.ToString(((SHA384)hashingObject).ComputeHash(Encoding.UTF8.GetBytes(word))).Replace("-", ""); break; case HashType.SHA512: hashingObject = SHA512.Create(); hash = BitConverter.ToString(((SHA512)hashingObject).ComputeHash(Encoding.UTF8.GetBytes(word))).Replace("-", ""); break; } if (hash == CMD_HASHCRACK.InputArgumentEntry.Arguments[1].Value.ToString().ToUpper()) { result = word; } } currentResult = hash; currentWord = word; processedWords++; progress = processedWords / count * 100; word = null; hash = null; hashingObject = null; } List <Task> taskList = new List <Task>(); Regex hexCheck = new Regex("^[a-fA-F0-9]*$"); switch (CMD_HASHCRACK.InputArgumentEntry.Arguments[1].Value.ToString().Length) { case 40 when hexCheck.IsMatch(CMD_HASHCRACK.InputArgumentEntry.Arguments[1].Value.ToString()): hashType = HashType.SHA1; break; case 64 when hexCheck.IsMatch(CMD_HASHCRACK.InputArgumentEntry.Arguments[1].Value.ToString()): hashType = HashType.SHA256; break; case 96 when hexCheck.IsMatch(CMD_HASHCRACK.InputArgumentEntry.Arguments[1].Value.ToString()): hashType = HashType.SHA384; break; case 128 when hexCheck.IsMatch(CMD_HASHCRACK.InputArgumentEntry.Arguments[1].Value.ToString()): hashType = HashType.SHA512; break; default: ((TextEditor)EnvironmentVariables.GetCurrentValue("IOFIELD")).Dispatcher.Invoke(() => { ((TextEditor)EnvironmentVariables.GetCurrentValue("IOFIELD")).IsReadOnly = false; ((TextEditor)EnvironmentVariables.GetCurrentValue("IOFIELD")).PreviewKeyDown -= Main_KeyDown; }); return("\nIncorrect hash format or unsupported type!"); } string path = null; if (File.Exists(CMD_HASHCRACK.InputArgumentEntry.Arguments[0].Value.ToString()) && CMD_HASHCRACK.InputArgumentEntry.Arguments[0].Value.ToString().Contains(":")) { path = CMD_HASHCRACK.InputArgumentEntry.Arguments[0].Value.ToString(); } else if (File.Exists(EnvironmentVariables.GetCurrentValue("DIRECTORY").ToString() + CMD_HASHCRACK.InputArgumentEntry.Arguments[0].Value.ToString())) { path = EnvironmentVariables.GetCurrentValue("DIRECTORY").ToString() + CMD_HASHCRACK.InputArgumentEntry.Arguments[0].Value.ToString(); } if (path == null) { ((TextEditor)EnvironmentVariables.GetCurrentValue("IOFIELD")).Dispatcher.Invoke(() => { ((TextEditor)EnvironmentVariables.GetCurrentValue("IOFIELD")).IsReadOnly = false; ((TextEditor)EnvironmentVariables.GetCurrentValue("IOFIELD")).PreviewKeyDown -= Main_KeyDown; }); return("\nFile not found!"); } string[] lines = File.ReadAllLines(path); count = lines.Length; taskList.Add(Task.Run(async() => { await HASH_TASK(lines[0]); })); for (int i = 0; i < lines.Length; i++) { if (CT.IsCancellationRequested) { ((TextEditor)EnvironmentVariables.GetCurrentValue("IOFIELD")).Dispatcher.Invoke(() => { ((TextEditor)EnvironmentVariables.GetCurrentValue("IOFIELD")).IsReadOnly = false; ((TextEditor)EnvironmentVariables.GetCurrentValue("IOFIELD")).PreviewKeyDown -= Main_KeyDown; }); return("\nProcess interrupted."); } if (result != null) { break; } taskList.RemoveAll(x => x.IsCompleted); taskList.Add(Task.Run(async() => { await HASH_TASK(lines[i]); })); } await Task.WhenAll(taskList).ContinueWith(t => t.Dispose()); ((TextEditor)EnvironmentVariables.GetCurrentValue("IOFIELD")).Dispatcher.Invoke(() => { ((TextEditor)EnvironmentVariables.GetCurrentValue("IOFIELD")).IsReadOnly = false; ((TextEditor)EnvironmentVariables.GetCurrentValue("IOFIELD")).PreviewKeyDown -= Main_KeyDown; }); if (result == null) { return("\nNo matching hash found!"); } return($"\nResult: {result}"); } catch (Exception ex) { ((TextEditor)EnvironmentVariables.GetCurrentValue("IOFIELD")).Dispatcher.Invoke(() => { ((TextEditor)EnvironmentVariables.GetCurrentValue("IOFIELD")).IsReadOnly = false; ((TextEditor)EnvironmentVariables.GetCurrentValue("IOFIELD")).PreviewKeyDown -= Main_KeyDown; IOInteractLayer.StandardError(CMD_HASHCRACK, ex); }); return(""); } }); return(CMD_HASHCRACK); }
public Command GetCommand() { TABLE.Add(new CommandArgumentEntry("[string]", false, "[name filter]")); CMD_FONTLIST = new Command("FONTLIST", TABLE, true, "Returns all installed and built-in font names.", ExecutionLevel.User, CLIMode.Default); CMD_FONTLIST.SetFunction(() => { System.Drawing.Text.InstalledFontCollection ifc = new System.Drawing.Text.InstalledFontCollection(); List <string> built_in_names = new List <string>(); List <string> installed_names = new List <string>(); built_in_names.Add("3270Medium"); built_in_names.Add("Amstrad"); built_in_names.Add("BIOS"); built_in_names.Add("CGA"); built_in_names.Add("EGA8"); built_in_names.Add("EGA9"); built_in_names.Add("MDA"); built_in_names.Add("TandyNew225"); built_in_names.Add("TandyNewTV"); built_in_names.Add("VGA8"); built_in_names.Add("VGA9"); Interpreter interpreter = null; if (CMD_FONTLIST.InputArgumentEntry.Arguments.Count == 1) { interpreter = new Interpreter((string)CMD_FONTLIST.InputArgumentEntry.Arguments[0].Value); } if (CMD_FONTLIST.InputArgumentEntry.Arguments.Count == 1) { for (int i = 0; i < built_in_names.Count; i++) { if (!interpreter.GetResult(built_in_names[i])) { built_in_names.RemoveAt(i); i--; } } } for (int i = 0; i < ifc.Families.Length; i++) { if (CMD_FONTLIST.InputArgumentEntry.Arguments.Count == 0 || interpreter.GetResult(ifc.Families[i].Name)) { installed_names.Add(ifc.Families[i].Name); } } if (built_in_names.Count > 0) { IOInteractLayer.StandardOutput(CMD_FONTLIST, "\nBuilt-in fonts:"); for (int i = 0; i < built_in_names.Count; i++) { IOInteractLayer.StandardOutput(CMD_FONTLIST, "\n\t" + built_in_names[i]); } } if (installed_names.Count > 0) { IOInteractLayer.StandardOutput(CMD_FONTLIST, "\nInstalled fonts:"); for (int i = 0; i < installed_names.Count; i++) { IOInteractLayer.StandardOutput(CMD_FONTLIST, "\n\t" + installed_names[i]); } } return(""); }); return(CMD_FONTLIST); }
public Command GetCommand() { TABLE.Add(new CommandArgumentEntry("[string]", false, "[subkey path]")); TABLE.Add(new CommandArgumentEntry("[string] -s", true, "[subkey path] -s(save to startup)")); TABLE.Add(new CommandArgumentEntry("[string] -b", true, "[subkey path] -b(save to running and startup)")); CMD_CSK = new Command("CSK", TABLE, false, "Changes the current subkey.", ExecutionLevel.Administrator, CLIMode.Regedit); CMD_CSK.SetFunction(() => { if (CMD_CSK.InputArgumentEntry.Arguments.Count == 0) { return("\nInvalid arguments!"); } RegistryHive hiveKey; string subKey = null; if (CMD_CSK.InputArgumentEntry.Arguments[0].Value.ToString() == "\\stsk") { EnvironmentVariables.SetToDefault("SUBKEY"); } else if (CMD_CSK.InputArgumentEntry.Arguments[0].Value.ToString() == "..") { if (EnvironmentVariables.GetCurrentValue("SUBKEY").ToString().Count(x => x == '\\') > 1) { string path = EnvironmentVariables.GetCurrentValue("SUBKEY").ToString(); path = path.Remove(path.Length - 1, 1); path = path.Remove(path.LastIndexOf("\\")); if (CMD_CSK.InputArgumentEntry.Arguments.Count == 1) { EnvironmentVariables.ChangeCurrentValue("SUBKEY", path + "\\"); } else if (CMD_CSK.InputArgumentEntry.Arguments[1].Call == "-s") { EnvironmentVariables.ChangeDefaultValue("SUBKEY", path + "\\"); } else { EnvironmentVariables.ChangeDefaultValue("SUBKEY", path + "\\"); EnvironmentVariables.ChangeCurrentValue("SUBKEY", path + "\\"); } } } else { try { if (CMD_CSK.InputArgumentEntry.Arguments[0].Value.ToString().Contains("\\")) { hiveKey = (RegistryHive)Enum.Parse(typeof(RegistryHive), CMD_CSK.InputArgumentEntry.Arguments[0].Value.ToString().Substring(0, CMD_CSK.InputArgumentEntry.Arguments[0].Value.ToString().IndexOf("\\"))); subKey = CMD_CSK.InputArgumentEntry.Arguments[0].Value.ToString().Substring(CMD_CSK.InputArgumentEntry.Arguments[0].Value.ToString().IndexOf("\\") + 1); } else { hiveKey = (RegistryHive)Enum.Parse(typeof(RegistryHive), CMD_CSK.InputArgumentEntry.Arguments[0].Value.ToString()); subKey = ""; } } catch (Exception) { hiveKey = (RegistryHive)Enum.Parse(typeof(RegistryHive), EnvironmentVariables.GetCurrentValue("SUBKEY").ToString().Substring(0, EnvironmentVariables.GetCurrentValue("SUBKEY").ToString().IndexOf("\\"))); subKey = EnvironmentVariables.GetCurrentValue("SUBKEY").ToString().Substring(EnvironmentVariables.GetCurrentValue("SUBKEY").ToString().IndexOf("\\") + 1) + CMD_CSK.InputArgumentEntry.Arguments[0].Value.ToString(); } try { RegistryKey newKey = RegistryKey.OpenBaseKey(hiveKey, RegistryView.Default).OpenSubKey(subKey); if (newKey == null) { return("\nSubkey not found!"); } if (CMD_CSK.InputArgumentEntry.Arguments.Count == 1) { EnvironmentVariables.ChangeCurrentValue("SUBKEY", hiveKey.ToString() + "\\" + subKey + ((hiveKey.ToString() + "\\" + subKey).EndsWith("\\") ? "" : "\\")); } else if (CMD_CSK.InputArgumentEntry.Arguments[1].Call == "-s") { EnvironmentVariables.ChangeDefaultValue("SUBKEY", hiveKey.ToString() + "\\" + subKey + ((hiveKey.ToString() + "\\" + subKey).EndsWith("\\") ? "" : "\\")); } else { EnvironmentVariables.ChangeDefaultValue("SUBKEY", hiveKey.ToString() + "\\" + subKey + ((hiveKey.ToString() + "\\" + subKey).EndsWith("\\") ? "" : "\\")); EnvironmentVariables.ChangeCurrentValue("SUBKEY", hiveKey.ToString() + "\\" + subKey + ((hiveKey.ToString() + "\\" + subKey).EndsWith("\\") ? "" : "\\")); } } catch (Exception ex) { IOInteractLayer.StandardError(CMD_CSK, ex); } } return(""); }); return(CMD_CSK); }
public Command GetCommand() { TABLE.Add(new CommandArgumentEntry("-save", false)); TABLE.Add(new CommandArgumentEntry("-save=[string]", false, "-save=[file path]")); TABLE.Add(new CommandArgumentEntry("-load=[string]", false, "-load=[file path]")); CMD_CONFIG_RUNNING = new Command("CONFIG-RUNNING", TABLE, false, "Saves/loads running config from/to the specified file.", ExecutionLevel.User, CLIMode.Default); CMD_CONFIG_RUNNING.SetFunction(() => { if (CMD_CONFIG_RUNNING.InputArgumentEntry.Arguments.Count == 0) { EnvironmentVariables.GetAll().ForEach((x) => { if (x.VarType == VariableType.Constant) { IOInteractLayer.StandardOutput(CMD_CONFIG_RUNNING, $"\n\t{x.Name} = {x.CurrentValue}"); } }); } else if (CMD_CONFIG_RUNNING.InputArgumentEntry.Arguments[0].Value != null && CMD_CONFIG_RUNNING.InputArgumentEntry.Arguments[0].Value.ToString() != "") { if (CMD_CONFIG_RUNNING.InputArgumentEntry.Arguments[0].Call == "-save") { string path = string.Empty; if (CMD_CONFIG_RUNNING.InputArgumentEntry.Arguments[0].Value.ToString().Contains("\\")) { if (Directory.Exists(CMD_CONFIG_RUNNING.InputArgumentEntry.Arguments[0].Value.ToString().Remove(CMD_CONFIG_RUNNING.InputArgumentEntry.Arguments[0].Value.ToString().LastIndexOf('\\'))) && CMD_CONFIG_RUNNING.InputArgumentEntry.Arguments[0].Value.ToString().Contains(':')) { path = CMD_CONFIG_RUNNING.InputArgumentEntry.Arguments[0].Value.ToString(); } else if (Directory.Exists(EnvironmentVariables.GetCurrentValue("DIRECTORY").ToString() + CMD_CONFIG_RUNNING.InputArgumentEntry.Arguments[0].Value.ToString().Remove(CMD_CONFIG_RUNNING.InputArgumentEntry.Arguments[0].Value.ToString().LastIndexOf('\\')))) { path = EnvironmentVariables.GetCurrentValue("DIRECTORY").ToString() + CMD_CONFIG_RUNNING.InputArgumentEntry.Arguments[0].Value.ToString(); } } else { path = EnvironmentVariables.GetCurrentValue("DIRECTORY").ToString() + CMD_CONFIG_RUNNING.InputArgumentEntry.Arguments[0].Value.ToString(); } if (path != string.Empty) { using (StreamWriter sw = new StreamWriter(CMD_CONFIG_RUNNING.InputArgumentEntry.Arguments[0].Value.ToString())) { EnvironmentVariables.FindAll(x => x.VarType == VariableType.Constant).ForEach((x) => { sw.WriteLine($"{x.ValueType.FullName}:{x.Name}={x.CurrentValue}"); }); sw.Close(); } return($"\nRunning config saved at: {Path.GetFullPath(path)}"); } else { IOInteractLayer.StandardOutput(CMD_CONFIG_RUNNING, "\nInvalid path!"); } } else { string path = string.Empty; if (File.Exists(CMD_CONFIG_RUNNING.InputArgumentEntry.Arguments[0].Value.ToString()) && CMD_CONFIG_RUNNING.InputArgumentEntry.Arguments[0].Value.ToString().Contains(':')) { path = CMD_CONFIG_RUNNING.InputArgumentEntry.Arguments[0].Value.ToString(); } else if (File.Exists(EnvironmentVariables.GetCurrentValue("DIRECTORY").ToString() + CMD_CONFIG_RUNNING.InputArgumentEntry.Arguments[0].Value.ToString())) { path = EnvironmentVariables.GetCurrentValue("DIRECTORY").ToString() + CMD_CONFIG_RUNNING.InputArgumentEntry.Arguments[0].Value.ToString(); } if (path != string.Empty) { List <string> lines = File.ReadAllLines(path).ToList(); Type currentType; string name; string value; lines.ForEach((x) => { currentType = Type.GetType(x.Split(':')[0]); x = x.Remove(0, x.IndexOf(':') + 1); name = x.Split('=')[0]; value = x.Split('=')[1]; try { EnvironmentVariables.ChangeCurrentValue(name, value); } catch (EnvironmentVariableException ex) { IOInteractLayer.StandardError(CMD_CONFIG_RUNNING, ex); } }); return($"\nRunning config loaded from: {Path.GetFullPath(path)}"); } else { IOInteractLayer.StandardOutput(CMD_CONFIG_RUNNING, "\nConfig file not found!"); } } } else { using (StreamWriter sw = new StreamWriter("config.ini")) { List <string> names = new List <string>(); EnvironmentVariables.FindAll(x => x.VarType == VariableType.Constant).ForEach((x) => { sw.WriteLine($"{x.ValueType.FullName}:{x.Name}={x.CurrentValue}"); names.Add(x.Name); }); sw.Close(); names.ForEach((x) => { EnvironmentVariables.ChangeDefaultValue(x, EnvironmentVariables.GetCurrentValue(x), false); }); } return($"\nRunning config saved at: {Path.GetFullPath("config.ini")}"); } return(""); }); return(CMD_CONFIG_RUNNING); }