private static void ShowHelp() { Console.WriteLine("ysoserial.net generates deserialization payloads for a variety of .NET formatters."); Console.WriteLine(""); if (plugin_name == "") { Console.WriteLine("== GADGETS =="); foreach (string g in generators) { try { if (g != "Generic") { ObjectHandle container = Activator.CreateInstance(null, "ysoserial.Generators." + g + "Generator"); Generator gg = (Generator)container.Unwrap(); Console.Write("\t(*) "); if (string.IsNullOrEmpty(gg.AdditionalInfo())) { Console.Write(gg.Name()); } else { // we have additional info to add! Console.Write(gg.Name() + " [" + gg.AdditionalInfo() + "]"); } OptionSet extraOptions = gg.Options(); if (extraOptions != null && !show_fullhelp) { Console.Write(" (supports extra options: use the '--fullhelp' argument to view)"); } Console.WriteLine(); Console.Write("\t\tFormatters: "); Console.WriteLine(string.Join(" , ", gg.SupportedFormatters().OrderBy(s => s, StringComparer.OrdinalIgnoreCase)) + ""); if (show_fullhelp) { Console.WriteLine("\t\t\tLabels: " + string.Join(", ", gg.Labels())); } if (extraOptions != null && show_fullhelp) { StringWriter baseTextWriter = new StringWriter(); baseTextWriter.NewLine = "\r\n\t\t\t"; // this is easier than using string builder and adding spacing to each line! Console.WriteLine("\t\t\tExtra options:"); extraOptions.WriteOptionDescriptions(baseTextWriter); Console.Write("\t\t\t"); // this is easier than using string builder and adding spacing to each line! Console.WriteLine(baseTextWriter.ToString()); } } } catch { Console.WriteLine("Gadget not supported"); System.Environment.Exit(-1); } } Console.WriteLine(""); Console.WriteLine("== PLUGINS =="); foreach (string p in plugins) { try { if (p != "Generic") { ObjectHandle container = Activator.CreateInstance(null, "ysoserial.Plugins." + p + "Plugin"); Plugin pp = (Plugin)container.Unwrap(); Console.WriteLine("\t(*) " + pp.Name() + " (" + pp.Description() + ")"); OptionSet options = pp.Options(); if (options != null && show_fullhelp) { StringWriter baseTextWriter = new StringWriter(); baseTextWriter.NewLine = "\r\n\t\t"; // this is easier than using string builder and adding spacing to each line! Console.WriteLine("\t\tOptions:"); options.WriteOptionDescriptions(baseTextWriter); Console.Write("\t\t"); // this is easier than using string builder and adding spacing to each line! Console.WriteLine(baseTextWriter.ToString()); } } } catch { Console.WriteLine("Plugin not supported"); System.Environment.Exit(-1); } } Console.WriteLine(""); Console.WriteLine("Note: Machine authentication code (MAC) key modifier is not being used for LosFormatter in ysoserial.net. Therefore, LosFormatter (base64 encoded) can be used to create ObjectStateFormatter payloads."); Console.WriteLine(""); Console.WriteLine("Usage: ysoserial.exe [options]"); Console.WriteLine("Options:"); options.WriteOptionDescriptions(Console.Out); System.Environment.Exit(0); } else { try { plugin_name = plugins.Where(p => String.Equals(p, plugin_name, StringComparison.OrdinalIgnoreCase)).FirstOrDefault(); ObjectHandle container = Activator.CreateInstance(null, "ysoserial.Plugins." + plugin_name + "Plugin"); Plugin pp = (Plugin)container.Unwrap(); Console.WriteLine("Plugin:\n"); Console.WriteLine(pp.Name() + " (" + pp.Description() + ")"); Console.WriteLine("\nOptions:\n"); pp.Options().WriteOptionDescriptions(Console.Out); } catch { Console.WriteLine("Plugin not supported"); } System.Environment.Exit(-1); } }