Skip to content
This repository has been archived by the owner on Sep 2, 2022. It is now read-only.

Commit

Permalink
Filter out session domain names with spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
rvazarkar committed Feb 12, 2020
1 parent 52106b9 commit 1ba6ff2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions SharpHound3/ResolutionHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,10 @@ private static string GetDomainControllerForDomain(string domainName)
string accountDomain)
{
var domain = Helpers.NormalizeDomainName(accountDomain);
//If we have a space in the domain name, its most likely NT AUTHORITY or some other variation, and its not a valid name either way. Ignore it
if (domain.Contains(" "))
return (false, null, LdapTypeEnum.Unknown);

var key = new UserDomainKey
{
AccountDomain = domain,
Expand Down
6 changes: 5 additions & 1 deletion SharpHound3/Tasks/LoggedOnTasks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,11 @@ private static async Task<List<Session>> GetLoggedOnUsersAPI(Computer computer)
continue;

//Remove blank accounts and computer accounts
if (username.Trim() == "" || username.EndsWith("$"))
if (username.Trim() == "" || username.EndsWith("$") || username == "ANONYMOUS LOGON" || username == Options.Instance.CurrentUserName)
continue;

//Any domain with a space is unusable (ex: NT AUTHORITY, FONT DRIVER HOST)
if (domain.Contains(" "))
continue;

var (rSuccess, sid, _) = await ResolutionHelpers.ResolveAccountNameToSidAndType(username, domain);
Expand Down

0 comments on commit 1ba6ff2

Please sign in to comment.