From b59d4a04231bd0aa9e0f07a4236c4145f6adbf17 Mon Sep 17 00:00:00 2001 From: Tijme Gommers Date: Fri, 4 Mar 2022 15:05:33 +0100 Subject: [PATCH 1/2] Allow users to spray an empty password. --- SharpHose/Program.cs | 16 +-- SharpHose/SharpHose.csproj | 212 ++++++++++++++++++------------------- 2 files changed, 115 insertions(+), 113 deletions(-) diff --git a/SharpHose/Program.cs b/SharpHose/Program.cs index c5786e9..8b07d67 100644 --- a/SharpHose/Program.cs +++ b/SharpHose/Program.cs @@ -19,6 +19,7 @@ static void Main(string[] args) config.HelpWriter = null; config.CaseInsensitiveEnumValues = true; }); + var parserResult = parser.ParseArguments(args); parserResult @@ -36,6 +37,7 @@ static void DisplayHelp(ParserResult result, IEnumerable errs) h.AddEnumValuesToHelpText = true; return h; }, e => e); + Console.WriteLine(helpText); foreach (var error in errs) @@ -66,20 +68,20 @@ static void DisplayHelp(ParserResult result, IEnumerable errs) static void Run(CLIOptions opts) { - if ((string.IsNullOrEmpty(opts.SprayPassword)) && (opts.Action == LDAPAction.SPRAY_USERS)) - { + if (opts.SprayPassword == null && opts.Action == LDAPAction.SPRAY_USERS) + { Console.WriteLine("Please supply a password to spray: "); var response = Console.ReadLine(); - if (!string.IsNullOrEmpty(response)) + if (opts.SprayPassword != null) { opts.SprayPassword = response; } else { Console.WriteLine($"Missing --spraypassword argument."); - Environment.Exit(0); - } + return; + } } if ((string.IsNullOrEmpty(opts.PolicyName)) && (opts.Action == LDAPAction.GET_POLICY_USERS)) @@ -94,7 +96,7 @@ static void Run(CLIOptions opts) else { Console.WriteLine($"Missing --policy argument."); - Environment.Exit(0); + return; } } @@ -110,7 +112,7 @@ static void Run(CLIOptions opts) else { Console.WriteLine($"Missing --output argument while using --quiet."); - Environment.Exit(0); + return; } } diff --git a/SharpHose/SharpHose.csproj b/SharpHose/SharpHose.csproj index fccd79e..1138253 100644 --- a/SharpHose/SharpHose.csproj +++ b/SharpHose/SharpHose.csproj @@ -1,107 +1,107 @@ - - - - - - Debug - AnyCPU - {51C6E016-1428-441D-82E9-BB0EB599BBC8} - Exe - SharpHose - SharpHose - v4.5 - 512 - true - true - - - - - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - false - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - false - - - SharpHose.Program - - - - ..\packages\CommandLineParser.2.8.0\lib\net45\CommandLine.dll - - - ..\packages\Costura.Fody.4.1.0\lib\net40\Costura.dll - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - + + + + + + Debug + AnyCPU + {51C6E016-1428-441D-82E9-BB0EB599BBC8} + Exe + SharpHose + SharpHose + v4.5 + 512 + true + true + + + + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + false + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + false + + + SharpHose.Program + + + + ..\packages\CommandLineParser.2.8.0\lib\net45\CommandLine.dll + + + ..\packages\Costura.Fody.4.1.0\lib\net40\Costura.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + \ No newline at end of file From 4d344695099537e9037d76f008bfa93f7c820f11 Mon Sep 17 00:00:00 2001 From: Tijme Gommers Date: Tue, 15 Mar 2022 09:36:58 +0100 Subject: [PATCH 2/2] Revert returns with exits. --- SharpHose/Program.cs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/SharpHose/Program.cs b/SharpHose/Program.cs index 8b07d67..d24650f 100644 --- a/SharpHose/Program.cs +++ b/SharpHose/Program.cs @@ -19,7 +19,6 @@ static void Main(string[] args) config.HelpWriter = null; config.CaseInsensitiveEnumValues = true; }); - var parserResult = parser.ParseArguments(args); parserResult @@ -37,7 +36,6 @@ static void DisplayHelp(ParserResult result, IEnumerable errs) h.AddEnumValuesToHelpText = true; return h; }, e => e); - Console.WriteLine(helpText); foreach (var error in errs) @@ -68,8 +66,8 @@ static void DisplayHelp(ParserResult result, IEnumerable errs) static void Run(CLIOptions opts) { - if (opts.SprayPassword == null && opts.Action == LDAPAction.SPRAY_USERS) - { + if (opts.SprayPassword == null && opts.Action == LDAPAction.SPRAY_USERS) + { Console.WriteLine("Please supply a password to spray: "); var response = Console.ReadLine(); @@ -80,8 +78,8 @@ static void Run(CLIOptions opts) else { Console.WriteLine($"Missing --spraypassword argument."); - return; - } + Environment.Exit(0); + } } if ((string.IsNullOrEmpty(opts.PolicyName)) && (opts.Action == LDAPAction.GET_POLICY_USERS)) @@ -96,7 +94,7 @@ static void Run(CLIOptions opts) else { Console.WriteLine($"Missing --policy argument."); - return; + Environment.Exit(0); } } @@ -112,7 +110,7 @@ static void Run(CLIOptions opts) else { Console.WriteLine($"Missing --output argument while using --quiet."); - return; + Environment.Exit(0); } } @@ -155,4 +153,4 @@ static void Run(CLIOptions opts) } } } -} +} \ No newline at end of file