From 6cd075d96a39b7daa1de4b30f632236a37068ad2 Mon Sep 17 00:00:00 2001 From: Michael Van Leeuwen Date: Thu, 22 Jun 2023 20:33:50 -0700 Subject: [PATCH 1/3] Request --LDAPPassword interactively --- src/Sharphound.cs | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/src/Sharphound.cs b/src/Sharphound.cs index 3da19fa..130ed60 100644 --- a/src/Sharphound.cs +++ b/src/Sharphound.cs @@ -21,6 +21,7 @@ using System.IO; using System.Linq; using System.Security.Principal; +using System.Text; using System.Threading; using System.Threading.Tasks; using CommandLine; @@ -389,8 +390,31 @@ await options.WithParsedAsync(async options => { if (options.LDAPPassword == null) { - logger.LogError("You must specify LDAPPassword if using the LDAPUsername options"); - return; + logger.LogInformation("Prompting for interactive LDAPPassword"); + StringBuilder passwordBuilder = new StringBuilder(); + Console.Write("LDAPPassword: "); + while (true) + { + ConsoleKeyInfo key = Console.ReadKey(true); + if (key.Key == ConsoleKey.Enter) + break; + + if (key.Key == ConsoleKey.Backspace) + { + // Don't allow user to backspace through prompt + if (passwordBuilder.Length > 0) + { + passwordBuilder.Length--; + Console.Write("\b \b"); + } + continue; + } + + passwordBuilder.Append(key.KeyChar); + Console.Write("*"); + } + Console.WriteLine(); + options.LDAPPassword = passwordBuilder.ToString(); } ldapOptions.Username = options.LDAPUsername; From a5f334e61bbc49f05bf0b33405a59d8edf117ad3 Mon Sep 17 00:00:00 2001 From: Michael Van Leeuwen Date: Sun, 25 Jun 2023 18:59:14 -0700 Subject: [PATCH 2/3] Update HelpText for LDAPUsername --- src/Options.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Options.cs b/src/Options.cs index 204c168..f41001b 100644 --- a/src/Options.cs +++ b/src/Options.cs @@ -73,7 +73,7 @@ public class Options [Option(HelpText = "Username for LDAP", Default = null)] public string LDAPUsername { get; set; } - [Option(HelpText = "Password for LDAP", Default = null)] + [Option(HelpText = "Password for LDAP. If not specified, an interactive prompt will be used", Default = null)] public string LDAPPassword { get; set; } [Option(HelpText = "Override domain controller to pull LDAP from. This option can result in data loss", From b567f883c0f28661d23e31e4e10bb5c3856e1bf1 Mon Sep 17 00:00:00 2001 From: Michael Van Leeuwen Date: Sun, 25 Jun 2023 19:09:16 -0700 Subject: [PATCH 3/3] Update README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 29fcf9b..d3f90b7 100644 --- a/README.md +++ b/README.md @@ -72,7 +72,7 @@ dotnet build --ldapusername Username for LDAP - --ldappassword Password for LDAP + --ldappassword Password for LDAP. If not specified, an interactive prompt will be used --domaincontroller Override domain controller to pull LDAP from. This option can result in data loss