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] [string]", false, "[interface name] [MAC address]")); CMD_SETMAC = new Command("SETMAC", TABLE, false, "Changes MAC address of the specified network interface.", ExecutionLevel.Administrator, CLIMode.Default); CMD_SETMAC.SetFunction(() => { List <NetworkInterface> ifaces = new NetworkInterfaceDiscovery().GetInterfaces().Result.ToList(); if (ifaces.Exists(x => x.Name == CMD_SETMAC.InputArgumentEntry.Arguments[0].Value.ToString())) { PhysicalAddressManagement p_mgmt = new PhysicalAddressManagement(ifaces.Find(x => x.Name == CMD_SETMAC.InputArgumentEntry.Arguments[0].Value.ToString())); if (Regex.IsMatch(CMD_SETMAC.InputArgumentEntry.Arguments[1].Value.ToString(), "^[0-9a-fA-F:]*$")) { p_mgmt.SetAddress(CMD_SETMAC.InputArgumentEntry.Arguments[1].Value.ToString().Replace(":", "")); } else { return("\nInvalid address!"); } } else { return("\nInterface not found!"); } return(""); }); return(CMD_SETMAC); }
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, "[interface name]")); CMD_RESETMAC = new Command("RESETMAC", TABLE, false, "Resets the MAC address of the specified network interface.", ExecutionLevel.Administrator, CLIMode.Default); CMD_RESETMAC.SetFunction(() => { List <NetworkInterface> iface = new NetworkInterfaceDiscovery().GetInterfaces().Result.ToList(); if (iface.Exists(x => x.Name == CMD_RESETMAC.InputArgumentEntry.Arguments[0].Value.ToString())) { PhysicalAddressManagement p_mgmt = new PhysicalAddressManagement(iface.Find(x => x.Name == CMD_RESETMAC.InputArgumentEntry.Arguments[0].Value.ToString())); p_mgmt.ResetAddress(); return(""); } else { return("\nInterface not found!"); } }); return(CMD_RESETMAC); }