public bool Run(ManagementScope connection) { CommandTable table = new CommandTable(); table.AddRow(table.AddRow("Name", "Value").MakeSeparator()); ManagementObjectSearcher searcher = new ManagementObjectSearcher(connection, new ObjectQuery(Sql)); foreach (ManagementObject q in searcher.Get()) { foreach (PropertyData p in q.Properties) { try { CommandTableRow row = table.AddRow(1, new string[] { p.Name, p.Value.ToString() }); row[0].ForeColor = ConsoleColor.DarkGray; row[1].Align = CommandTableCol.EAlign.None; } catch { } } table.AddSeparator(2, '-'); } WriteTable(table); return(true); }
public void cmdJobs(string args) { if (JobCollection.Current.Count <= 0) { _IO.WriteInfo(Lang.Get("Nothing_To_Show")); return; } CommandTable tb = new CommandTable(); _IO.WriteLine(""); tb.AddRow(tb.AddRow(Lang.Get("Id"), Lang.Get("Status"), Lang.Get("Module")).MakeSeparator()); foreach (Job j in JobCollection.Current) { CommandTableRow row; if (j.IsRunning) { row = tb.AddRow(j.Id.ToString(), Lang.Get("Running"), j.FullPathModule); row[0].Align = CommandTableCol.EAlign.Right; row[1].ForeColor = ConsoleColor.Green; } else { row = tb.AddRow(j.Id.ToString(), Lang.Get("Dead"), j.FullPathModule); row[0].Align = CommandTableCol.EAlign.Right; row[1].ForeColor = ConsoleColor.Red; } } tb.OutputColored(_IO); _IO.WriteLine(""); }
public void cmdSearch(string args) { args = args.Trim().ToLowerInvariant(); string[] pars = ArgumentHelper.ArrayFromCommandLine(args); if (pars != null && pars.Length > 0) { CommandTable tb = new CommandTable(); bool primera1 = false; foreach (Module m in ModuleCollection.Current.Search(pars)) { if (!primera1) { if (tb.Count > 0) { tb.AddRow("", "", ""); } CommandTableRow row = tb.AddRow(Lang.Get("Type"), Lang.Get("Path"), Lang.Get("Disclosure")); tb.AddRow(row.MakeSeparator()); tb.AddRow("", "", ""); primera1 = true; } tb.AddRow(Lang.Get("Modules"), m.FullPath, m.DisclosureDate.ToShortDateString()); } bool primera2 = false; foreach (IModule m in PayloadCollection.Current.Search(pars)) { if (!primera2) { if (tb.Count > 0) { tb.AddRow("", "", ""); } CommandTableRow row = tb.AddRow(Lang.Get("Type"), Lang.Get("Path"), ""); tb.AddRow(row.MakeSeparator()); tb.AddRow("", "", ""); primera2 = true; } tb.AddRow(Lang.Get("Payload"), m.FullPath, ""); } if (primera1 || primera2) { tb.OutputColored(_IO); } else { _IO.WriteInfo(Lang.Get("Nothing_To_Show")); } } else { _IO.WriteInfo(Lang.Get("Be_More_Specific")); } }
static void DisplayAvailableCommands(CommandMenuItem menu, bool inner) { if (menu == null) { throw new ArgumentNullException("menu"); } CommandTable tb = new CommandTable(); if (!inner) { menu.IO.WriteLine(Lang.Get("Available_Commands") + ":"); menu.IO.WriteLine(""); tb.AddRow(tb.AddRow(Lang.Get("Short"), Lang.Get("Command")).MakeSeparator()); } bool entra = false; var abbreviations = menu.CommandAbbreviations().OrderBy(it => it.Key); foreach (var ab in abbreviations) { //if (ab.Value == null) //{ // menu.IO.Write(" "); //} //else //{ // menu.IO.Write(ab.Value.PadRight(3) + " | "); //} tb.AddRow(ab.Value, ab.Key)[0].Align = CommandTableCol.EAlign.Right; //menu.IO.WriteLine(ab.Key); entra = true; } if (entra) { menu.IO.WriteLine(tb.Output()); } if (!inner) { menu.IO.WriteLine(Lang.Get("Type_Help")); } }
public void cmdVersion(string args) { _IO.WriteLine(""); CommandTable tb = new CommandTable(); _IO.WriteLine(Lang.Get("Version_Start")); _IO.WriteLine(""); tb.AddRow(tb.AddRow(Lang.Get("File"), Lang.Get("Version")).MakeSeparator()); foreach (Assembly asm in AppDomain.CurrentDomain.GetAssemblies()) { if (asm.GlobalAssemblyCache) { continue; } string file = "??"; if (string.IsNullOrEmpty(asm.Location)) { file = asm.ManifestModule.ScopeName; } else { file = Path.GetFileName(asm.Location); } tb.AddRow(file, asm.ImageRuntimeVersion); } tb.AddRow("", ""); tb.AddRow(tb.AddRow(Lang.Get("Module"), Lang.Get("Count")).MakeSeparator()); tb.AddRow(Lang.Get("Modules"), ModuleCollection.Current.Count.ToString()); tb.AddRow(Lang.Get("Encoders"), EncoderCollection.Current.Count.ToString()); tb.AddRow(Lang.Get("Payloads"), PayloadCollection.Current.Count.ToString()); tb.AddRow(Lang.Get("Nops"), NopCollection.Current.Count.ToString()); _IO.WriteLine(tb.Output()); }
static void DisplayAvailableCommands(CommandMenuItem menu, bool inner) { if (menu == null) { throw new ArgumentNullException("menu"); } CommandTable tb = new CommandTable(); if (!inner) { menu.IO.WriteLine(Lang.Get("Available_Commands") + ":"); menu.IO.WriteLine(""); tb.AddRow(tb.AddRow(Lang.Get("Short"), Lang.Get("Command")).MakeSeparator()); } bool entra = false; var abbreviations = menu.CommandAbbreviations().OrderBy(it => it.Key); foreach (var ab in abbreviations) { CommandTableRow row = tb.AddRow(ab.Value, ab.Key); row[0].Align = CommandTableCol.EAlign.Right; row[0].ForeColor = ConsoleColor.Yellow; entra = true; } if (entra) { tb.OutputColored(menu.IO); } if (!inner) { menu.IO.WriteLine(Lang.Get("Type_Help")); } }
public void cmdLoad(string args) { if (string.IsNullOrEmpty(args)) { _IO.WriteError(Lang.Get("Incorrect_Command_Usage")); return; } args = args.Trim(); if (!File.Exists(args)) { _IO.WriteError(Lang.Get("File_Not_Exists", args)); return; } try { _IO.SetForeColor(ConsoleColor.Gray); _IO.Write(Lang.Get("Reading_File", args)); Assembly.Load(File.ReadAllBytes(args)); //Assembly.LoadFile(args); _IO.SetForeColor(ConsoleColor.Green); _IO.WriteLine(Lang.Get("Ok").ToUpperInvariant()); } catch { _IO.SetForeColor(ConsoleColor.Red); _IO.WriteLine(Lang.Get("Error").ToUpperInvariant()); } CommandTable tb = new CommandTable(); _IO.WriteLine(""); tb.AddRow(tb.AddRow(Lang.Get("Type"), Lang.Get("Count")).MakeSeparator()); tb.AddRow(Lang.Get("Modules"), ModuleCollection.Current.Load().ToString())[1].Align = CommandTableCol.EAlign.Right; tb.AddRow(Lang.Get("Payloads"), PayloadCollection.Current.Load().ToString())[1].Align = CommandTableCol.EAlign.Right; tb.AddRow(Lang.Get("Encoders"), EncoderCollection.Current.Load().ToString())[1].Align = CommandTableCol.EAlign.Right; tb.AddRow(Lang.Get("Nops"), NopCollection.Current.Load().ToString())[1].Align = CommandTableCol.EAlign.Right; tb.OutputColored(_IO); _IO.WriteLine(""); }
public void cmdShow(string args) { if (!CheckModule(false, EModuleType.None)) return; args = args.Trim().ToLowerInvariant(); Module curM = _Current.ModuleType == EModuleType.Module ? (Module)_Current : null; switch (args) { case "": case "info": { cmdInfo(args); break; } case "options": case "config": { // set target id Target[] ps = null; if (curM != null) { ps = curM.Targets; if (ps != null) { int ix = 0; foreach (Target t in ps) { t.Id = ix; ix++; } } } CommandTable tb = new CommandTable(); string title = ""; for (int x = 0; x <= 2; x++) { PropertyInfo[] pis = null; object pv = _Current; switch (x) { case 0: { if (_Current.ModuleType == EModuleType.Payload) title = Lang.Get("Payload_Options", _Current.FullPath); else title = Lang.Get("Module_Options", _Current.FullPath); pis = ReflectionHelper.GetProperties(_Current, true, true, true); break; } case 1: { title = Lang.Get("Current_Target"); if (ps != null && ps.Length > 1) pis = ReflectionHelper.GetProperties(_Current, "Target"); break; } case 2: { if (curM != null) { if (curM.Payload != null) { pv = curM.Payload; pis = ReflectionHelper.GetProperties(curM.Payload, true, true, true); title = Lang.Get("Payload_Options", curM.Payload.FullPath); } else { if (curM.PayloadRequirements != null) { pis = ReflectionHelper.GetProperties(_Current, "Payload"); title = Lang.Get("Selected_Payload"); } } } break; } } if (pis != null) { bool primera = true;// (x != 1 || !hasX0); foreach (PropertyInfo pi in pis) { ConfigurableProperty c = pi.GetCustomAttribute<ConfigurableProperty>(); if (c == null) continue; if (primera) { if (tb.Count > 0) tb.AddRow("", "", ""); CommandTableRow row = tb.AddRow(0, title, "", ""); tb.AddRow("", "", ""); row[0].Align = CommandTableCol.EAlign.None; row[1].Align = CommandTableCol.EAlign.None; row[2].Align = CommandTableCol.EAlign.None; primera = false; } object val = pi.GetValue(pv); if (val == null) { val = "NULL"; CommandTableRow row = tb.AddRow(pi.Name, val.ToString(), c.Description); if (c.Required) row[1].ForeColor = ConsoleColor.Red; else { if (x == 0 || x == 3) row[1].ForeColor = ConsoleColor.Cyan; } } else { CommandTableRow row = tb.AddRow(pi.Name, val.ToString(), c.Description); if (x == 0 || x == 3) row[1].ForeColor = ConsoleColor.Cyan; } } } } string separator = tb.Separator; foreach (CommandTableRow row in tb) { foreach (CommandTableCol col in row) { if (col.ReplicatedChar == '\0') { switch (col.Index) { case 0: _IO.SetForeColor(ConsoleColor.DarkGray); break; case 1: _IO.SetForeColor(col.ForeColor); break; case 2: _IO.SetForeColor(ConsoleColor.Yellow); break; } } else _IO.SetForeColor(col.ForeColor); if (col.Index != 0) _IO.Write(separator); _IO.Write(col.GetFormatedValue()); } _IO.WriteLine(""); } break; } case "payloads": { Payload[] ps = curM == null ? null : PayloadCollection.Current.GetPayloadAvailables(curM.PayloadRequirements); if (ps == null || ps.Length == 0) _IO.WriteInfo(Lang.Get("Nothing_To_Show")); else { CommandTable tb = new CommandTable(); tb.AddRow(tb.AddRow(Lang.Get("Name"), Lang.Get("Description")).MakeSeparator()); foreach (Payload p in ps) tb.AddRow(p.FullPath, p.Description); _IO.Write(tb.Output()); } break; } case "targets": { Target[] ps = curM == null ? null : curM.Targets; if (ps == null || ps.Length <= 1) _IO.WriteInfo(Lang.Get("Nothing_To_Show")); else { CommandTable tb = new CommandTable(); tb.AddRow(tb.AddRow(Lang.Get("Name"), Lang.Get("Description")).MakeSeparator()); int ix = 0; foreach (Target p in ps) { p.Id = ix; ix++; tb.AddRow(p.Id.ToString(), p.Name); } _IO.Write(tb.Output()); } break; } default: { // incorrect use _IO.WriteError(Lang.Get("Incorrect_Command_Usage")); _IO.AddInput("help show"); break; } } }
public void cmdSearch(string args) { args = args.Trim().ToLowerInvariant(); string[] pars = ArgumentHelper.ArrayFromCommandLine(args); if (pars != null && pars.Length > 0) { CommandTable tb = new CommandTable(); bool primera1 = false; foreach (Module m in ModuleCollection.Current.Search(pars)) { if (!primera1) { if (tb.Count > 0) tb.AddRow("", "", ""); CommandTableRow row = tb.AddRow(Lang.Get("Type"), Lang.Get("Path"), Lang.Get("Disclosure")); tb.AddRow(row.MakeSeparator()); tb.AddRow("", "", ""); primera1 = true; } tb.AddRow(Lang.Get("Modules"), m.FullPath, m.DisclosureDate.ToShortDateString()); } bool primera2 = false; foreach (IModule m in PayloadCollection.Current.Search(pars)) { if (!primera2) { if (tb.Count > 0) tb.AddRow("", "", ""); CommandTableRow row = tb.AddRow(Lang.Get("Type"), Lang.Get("Path"), ""); tb.AddRow(row.MakeSeparator()); tb.AddRow("", "", ""); primera2 = true; } tb.AddRow(Lang.Get("Payload"), m.FullPath, ""); } if (primera1 || primera2) tb.OutputColored(_IO); else _IO.WriteInfo(Lang.Get("Nothing_To_Show")); } else { _IO.WriteInfo(Lang.Get("Be_More_Specific")); } }
public void cmdInfo(string args) { if (!CheckModule(false, EModuleType.None)) return; args = args.Trim().ToLowerInvariant(); Module curM = _Current.ModuleType == EModuleType.Module ? (Module)_Current : null; CommandTable tb = new CommandTable(); tb.AddRow(Lang.Get("Path"), _Current.Path, "")[0].ForeColor = ConsoleColor.DarkGray; tb.AddRow(Lang.Get("Name"), _Current.Name, "")[0].ForeColor = ConsoleColor.DarkGray; tb.AddRow("", "", ""); if (!string.IsNullOrEmpty(_Current.Author)) { CommandTableRow row = tb.AddRow(1, Lang.Get("Author"), _Current.Author, ""); row[0].ForeColor = ConsoleColor.DarkGray; row[1].Align = CommandTableCol.EAlign.None; row[2].Align = CommandTableCol.EAlign.None; } if (curM != null) { if (curM.DisclosureDate != DateTime.MinValue) tb.AddRow(Lang.Get("DisclosureDate"), curM.DisclosureDate.ToString(), "")[0].ForeColor = ConsoleColor.DarkGray; tb.AddRow(Lang.Get("IsLocal"), curM.IsLocal.ToString(), "")[0].ForeColor = ConsoleColor.DarkGray; tb.AddRow(Lang.Get("IsRemote"), curM.IsRemote.ToString(), "")[0].ForeColor = ConsoleColor.DarkGray; if (curM.References != null && curM.References.Length > 0) { tb.AddRow("", "", ""); StringBuilder sb = new StringBuilder(); foreach (Reference r in curM.References) { if (r == null) continue; sb.AppendLine(r.Type.ToString() + " - " + r.Value); } foreach (CommandTableRow row in tb.AddSplitRow(1, Lang.Get("References"), sb.ToString(), "")) { row[0].ForeColor = ConsoleColor.DarkGray; row[1].Align = CommandTableCol.EAlign.None; row[2].Align = CommandTableCol.EAlign.None; } } } if (!string.IsNullOrEmpty(_Current.Description)) { foreach (CommandTableRow row in tb.AddSplitRow(1, Lang.Get("Description"), _Current.Description, "")) { row[0].ForeColor = ConsoleColor.DarkGray; row[1].Align = CommandTableCol.EAlign.None; row[2].Align = CommandTableCol.EAlign.None; } } tb.OutputColored(_IO); }
public void cmdVersion(string args) { _IO.WriteLine(""); CommandTable tb = new CommandTable(); _IO.WriteLine(Lang.Get("Version_Start")); _IO.WriteLine(""); tb.AddRow(tb.AddRow(Lang.Get("File"), Lang.Get("Version")).MakeSeparator()); foreach (Assembly asm in AppDomain.CurrentDomain.GetAssemblies()) { if (asm.GlobalAssemblyCache) continue; string file = "??"; if (string.IsNullOrEmpty(asm.Location)) file = asm.ManifestModule.ScopeName; else file = Path.GetFileName(asm.Location); tb.AddRow(file, asm.ImageRuntimeVersion); } tb.AddRow("", ""); tb.AddRow(tb.AddRow(Lang.Get("Module"), Lang.Get("Count")).MakeSeparator()); tb.AddRow(Lang.Get("Modules"), ModuleCollection.Current.Count.ToString()); tb.AddRow(Lang.Get("Encoders"), EncoderCollection.Current.Count.ToString()); tb.AddRow(Lang.Get("Payloads"), PayloadCollection.Current.Count.ToString()); tb.AddRow(Lang.Get("Nops"), NopCollection.Current.Count.ToString()); _IO.WriteLine(tb.Output()); }
public void cmdInfo(string args) { if (!CheckModule(false, EModuleType.None)) { return; } args = args.Trim().ToLowerInvariant(); Module curM = _Current.ModuleType == EModuleType.Module ? (Module)_Current : null; CommandTable tb = new CommandTable(); tb.AddRow(Lang.Get("Path"), _Current.ModulePath, "")[0].ForeColor = ConsoleColor.DarkGray; tb.AddRow(Lang.Get("Name"), _Current.Name, "")[0].ForeColor = ConsoleColor.DarkGray; tb.AddRow("", "", ""); ModuleInfoAttribute mInfo = _Current == null ? null : _Current.GetType().GetCustomAttribute <ModuleInfoAttribute>(); if (mInfo != null && !string.IsNullOrEmpty(mInfo.Author)) { CommandTableRow row = tb.AddRow(1, Lang.Get("Author"), mInfo.Author, ""); row[0].ForeColor = ConsoleColor.DarkGray; row[1].Align = CommandTableCol.EAlign.None; row[2].Align = CommandTableCol.EAlign.None; } if (curM != null) { if (curM.DisclosureDate != DateTime.MinValue) { tb.AddRow(Lang.Get("DisclosureDate"), curM.DisclosureDate.ToString(), "")[0].ForeColor = ConsoleColor.DarkGray; } if (curM.References != null && curM.References.Length > 0) { tb.AddRow("", "", ""); StringBuilder sb = new StringBuilder(); foreach (Reference r in curM.References) { if (r == null) { continue; } sb.AppendLine(r.Type.ToString() + " - " + r.Value); } foreach (CommandTableRow row in tb.AddSplitRow(1, Lang.Get("References"), sb.ToString(), "")) { row[0].ForeColor = ConsoleColor.DarkGray; row[1].Align = CommandTableCol.EAlign.None; row[2].Align = CommandTableCol.EAlign.None; } } } if (mInfo != null && !string.IsNullOrEmpty(mInfo.Description)) { foreach (CommandTableRow row in tb.AddSplitRow(1, Lang.Get("Description"), mInfo.Description, "")) { row[0].ForeColor = ConsoleColor.DarkGray; row[1].Align = CommandTableCol.EAlign.None; row[2].Align = CommandTableCol.EAlign.None; } } tb.OutputColored(_IO); }
static void DisplayAvailableCommands(CommandMenuItem menu, bool inner) { if (menu == null) throw new ArgumentNullException("menu"); CommandTable tb = new CommandTable(); if (!inner) { menu.IO.WriteLine(Lang.Get("Available_Commands") + ":"); menu.IO.WriteLine(""); tb.AddRow(tb.AddRow(Lang.Get("Short"), Lang.Get("Command")).MakeSeparator()); } bool entra = false; var abbreviations = menu.CommandAbbreviations().OrderBy(it => it.Key); foreach (var ab in abbreviations) { //if (ab.Value == null) //{ // menu.IO.Write(" "); //} //else //{ // menu.IO.Write(ab.Value.PadRight(3) + " | "); //} tb.AddRow(ab.Value, ab.Key)[0].Align = CommandTableCol.EAlign.Right; //menu.IO.WriteLine(ab.Key); entra = true; } if (entra) menu.IO.WriteLine(tb.Output()); if (!inner) menu.IO.WriteLine(Lang.Get("Type_Help")); }
public bool Run(ManagementScope connection) { string wmiql = ""; int omit = -1; string[] fields = null; CommandTableCol.EAlign first = CommandTableCol.EAlign.Left; CommandTable table = new CommandTable(); switch (List) { case EList.Win32_Processor: { WriteInfo("------------------------"); WriteInfo("Win32_Processor instance"); WriteInfo("------------------------"); wmiql = "SELECT * FROM Win32_Processor"; fields = new string[] { "ProcessorId", "Caption", "Name", "Architecture" }; omit = -1; table.AddRow(table.AddRow("ProcessorId", "Caption", "Name", "Architecture").MakeSeparator()); break; } case EList.Win32_PhysicalMemory: { WriteInfo("----------------------------"); WriteInfo("Win32_PhysicalMemory instance"); WriteInfo("----------------------------"); wmiql = "SELECT * FROM Win32_PhysicalMemory"; fields = new string[] { "Caption", "PartNumber", "Speed", "Capacity" }; omit = -1; table.AddRow(table.AddRow("Caption", "PartNumber", "Speed", "Capacity").MakeSeparator()); break; } case EList.Win32_PhysicalMedia: { WriteInfo("----------------------------"); WriteInfo("Win32_PhysicalMedia instance"); WriteInfo("----------------------------"); wmiql = "SELECT * FROM Win32_PhysicalMedia"; fields = new string[] { "SerialNumber", "Tag" }; omit = -1; table.AddRow(table.AddRow("SerialNumber", "Tag").MakeSeparator()); break; } case EList.Win32_NetworkAdapterConfiguration: { WriteInfo("------------------------------------------"); WriteInfo("Win32_NetworkAdapterConfiguration instance"); WriteInfo("------------------------------------------"); wmiql = "SELECT * FROM Win32_NetworkAdapterConfiguration"; fields = new string[] { "Caption", "DHCPEnabled", "IPEnabled" }; omit = -1; table.AddRow(table.AddRow("Caption", "DHCPEnabled", "IPEnabled").MakeSeparator()); break; } case EList.Win32_MemoryDevice: { WriteInfo("---------------------------"); WriteInfo("Win32_MemoryDevice instance"); WriteInfo("---------------------------"); wmiql = "SELECT * FROM Win32_MemoryDevice"; fields = new string[] { "Caption", "StartingAddress", "EndingAddress" }; omit = -1; table.AddRow(table.AddRow("Caption", "StartingAddress", "EndingAddress").MakeSeparator()); break; } case EList.Win32_DiskDrive: { WriteInfo("------------------------"); WriteInfo("Win32_DiskDrive instance"); WriteInfo("------------------------"); wmiql = "SELECT * FROM Win32_DiskDrive"; fields = new string[] { "Name", "Model", "SerialNumber", "Size" }; omit = -1; table.AddRow(table.AddRow("Name", "Model", "SerialNumber", "Size").MakeSeparator()); break; } case EList.Win32_Process: { WriteInfo("----------------------"); WriteInfo("Win32_Process instance"); WriteInfo("----------------------"); wmiql = "SELECT * FROM Win32_Process"; fields = new string[] { "ProcessId", "Name", "CommandLine" }; omit = 2; first = CommandTableCol.EAlign.Right; table.AddRow(table.AddRow("ProcessId", "Name", "CommandLine").MakeSeparator()); break; } case EList.Win32_Product: { WriteInfo("----------------------"); WriteInfo("Win32_Product instance"); WriteInfo("----------------------"); wmiql = "SELECT * FROM Win32_Product"; fields = new string[] { "Version", "Name" }; omit = 1; first = CommandTableCol.EAlign.Right; table.AddRow(table.AddRow("Version", "Name").MakeSeparator()); break; } } int mx = fields.Length; ManagementObjectSearcher searcher = new ManagementObjectSearcher(connection, new ObjectQuery(wmiql)); foreach (ManagementObject q in searcher.Get()) { string[] data = new string[mx]; for (int x = 0; x < mx; x++) { try { data[x] = q[fields[x]].ToString().Trim(); } catch { } } CommandTableRow row = table.AddRow(omit, data); row[0].ForeColor = ConsoleColor.DarkGray; row[0].Align = first; if (omit >= 0) { row[omit].Align = CommandTableCol.EAlign.None; } } WriteTable(table); return(true); }
public void cmdShow(string args) { if (!CheckModule(false, EModuleType.None)) { return; } args = args.Trim().ToLowerInvariant(); Module curM = _Current.ModuleType == EModuleType.Module ? (Module)_Current : null; switch (args) { case "": case "info": { cmdInfo(args); break; } case "options": case "config": { // set target id Target[] ps = null; if (curM != null) { ps = curM.Targets; if (ps != null) { int ix = 0; foreach (Target t in ps) { t.Id = ix; ix++; } } } CommandTable tb = new CommandTable(); string title = ""; for (int x = 0; x <= 2; x++) { PropertyInfo[] pis = null; object pv = _Current; switch (x) { case 0: { if (_Current.ModuleType == EModuleType.Payload) { title = Lang.Get("Payload_Options", _Current.FullPath); } else { title = Lang.Get("Module_Options", _Current.FullPath); } pis = ReflectionHelper.GetProperties(_Current, true, true, true); break; } case 1: { title = Lang.Get("Current_Target"); if (ps != null && ps.Length > 1) { pis = ReflectionHelper.GetProperties(_Current, "Target"); } break; } case 2: { if (curM != null) { if (curM.Payload != null) { pv = curM.Payload; pis = ReflectionHelper.GetProperties(curM.Payload, true, true, true); title = Lang.Get("Payload_Options", curM.Payload.FullPath); } else { if (curM.PayloadRequirements != null && curM.PayloadRequirements.ItsRequired()) { pis = ReflectionHelper.GetProperties(_Current, "Payload"); title = Lang.Get("Selected_Payload"); } } } break; } } if (pis != null) { bool primera = true; // (x != 1 || !hasX0); foreach (PropertyInfo pi in pis) { ConfigurableProperty c = pi.GetCustomAttribute <ConfigurableProperty>(); if (c == null) { continue; } if (primera) { if (tb.Count > 0) { tb.AddRow("", "", ""); } CommandTableRow row = tb.AddRow(0, title, "", ""); tb.AddRow("", "", ""); row[0].Align = CommandTableCol.EAlign.None; row[1].Align = CommandTableCol.EAlign.None; row[2].Align = CommandTableCol.EAlign.None; primera = false; } object val = pi.GetValue(pv); if (val == null) { val = "NULL"; CommandTableRow row = tb.AddRow(pi.Name, val.ToString(), c.Description); if (!c.Optional) { row[1].ForeColor = ConsoleColor.Red; } else { //if (x == 0 || x == 3) row[1].ForeColor = ConsoleColor.DarkRed; } } else { val = ConvertHelper.ToString(val); CommandTableRow row = tb.AddRow(pi.Name, val.ToString(), c.Description); if (x == 0 || x == 3) { row[1].ForeColor = ConsoleColor.Cyan; } } } } } string separator = tb.Separator; foreach (CommandTableRow row in tb) { foreach (CommandTableCol col in row) { if (col.ReplicatedChar == '\0') { switch (col.Index) { case 0: _IO.SetForeColor(ConsoleColor.DarkGray); break; case 1: _IO.SetForeColor(col.ForeColor); break; case 2: _IO.SetForeColor(ConsoleColor.Yellow); break; } } else { _IO.SetForeColor(col.ForeColor); } if (col.Index != 0) { _IO.Write(separator); } _IO.Write(col.GetFormatedValue()); } _IO.WriteLine(""); } break; } case "payloads": { ModuleHeader <Payload>[] ps = curM == null ? null : PayloadCollection.Current.GetAvailables(curM.PayloadRequirements).ToArray(); if (ps == null || ps.Length <= 0) { _IO.WriteInfo(Lang.Get("Nothing_To_Show")); } else { CommandTable tb = new CommandTable(); tb.AddRow(tb.AddRow(Lang.Get("Name"), Lang.Get("Description")).MakeSeparator()); foreach (ModuleHeader <Payload> p in ps) { tb.AddRow(p.FullPath, p.Description); } _IO.Write(tb.Output()); } break; } case "targets": { Target[] ps = curM == null ? null : curM.Targets; if (ps == null || ps.Length <= 0) { _IO.WriteInfo(Lang.Get("Nothing_To_Show")); } else { CommandTable tb = new CommandTable(); tb.AddRow(tb.AddRow(Lang.Get("Name"), Lang.Get("Description")).MakeSeparator()); int ix = 0; foreach (Target p in ps) { p.Id = ix; ix++; tb.AddRow(p.Id.ToString(), p.Name); } _IO.Write(tb.Output()); } break; } default: { // incorrect use _IO.WriteError(Lang.Get("Incorrect_Command_Usage")); _IO.AddInput("help show"); break; } } }