Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial NTLM Implementation #177

Open
wants to merge 11 commits into
base: v4
Choose a base branch
from
Open

Initial NTLM Implementation #177

wants to merge 11 commits into from

Conversation

rvazarkar
Copy link
Contributor

Description

This is the initial implementation of the new NTLM modelling, courtesy of @leechristensen .

Motivation and Context

https://specterops.atlassian.net/browse/BED-5113

How Has This Been Tested?

Screenshots (if appropriate):

Types of changes

  • Chore (a change that does not modify the application functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • Documentation updates are needed, and have been made accordingly.
  • I have added and/or updated tests to cover my changes.
  • All new and existing tests passed.
  • My changes include a database migration.

Copy link

@mvlipka mvlipka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good, mostly style comments and naming conventions that I think we can improve on

src/CommonLib/OutputTypes/APIResult.cs Outdated Show resolved Hide resolved
src/CommonLib/OutputTypes/NtlmSession.cs Outdated Show resolved Hide resolved
src/CommonLib/OutputTypes/NtlmSession.cs Show resolved Hide resolved
src/CommonLib/OutputTypes/NtlmSession.cs Outdated Show resolved Hide resolved
src/CommonLib/OutputTypes/NtlmSession.cs Outdated Show resolved Hide resolved
src/CommonLib/ThirdParty/PSOpenAD/SSPI.cs Show resolved Hide resolved
src/CommonLib/ThirdParty/PSOpenAD/SSPI.cs Show resolved Hide resolved
src/CommonLib/Ntlm/LdapNative.cs Show resolved Hide resolved
src/CommonLib/ThirdParty/PSOpenAD/SSPI.cs Show resolved Hide resolved
@rvazarkar
Copy link
Contributor Author

recheck

@rvazarkar rvazarkar requested a review from mvlipka January 8, 2025 19:02
@rvazarkar rvazarkar changed the title WIP: NTLM Implementation Initial NTLM Implementation Jan 8, 2025
# Conflicts:
#	src/CommonLib/LdapConnectionPool.cs
throw new ArgumentException("Url property is null");

if (useBadChannelBindings == null && url.Scheme == "https")
throw new ArgumentException("When using HTTPS, useBadChannelBindings must be set");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpicking, but trinary args like this tend to create some funky logic flows that can be hard to follow if you're smooth-brained like I am.
Here I think we're taking on some complexity by managing arg validations that the callers could be doing instead.

I might split this into two functions for clarity: the public function that does everything up to this point, then a private EnsureRequiresAuth(Uri url, bool useBadChannelBindings) that this one calls, feeding the appropriate coerced useBadChannelBindings:

EnsureRequiresAuth(url, useBadChannelBindings ?? true);

return schemes;
}

private async Task AuthWithBadChannelBindings(Uri url, string authScheme) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could use "-Async" suffix

@@ -2,7 +2,7 @@

namespace SharpHoundCommonLib.OutputTypes
{
public class AceRegistryAPIResult : APIResult
public class AceRegistryAPIResult : APIResult.APIResult
Copy link
Contributor

@definitelynotagoblin definitelynotagoblin Feb 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer the namespace and class had different names but not a blocker

public TypedPrincipal[] AllowedToAct { get; set; } = Array.Empty<TypedPrincipal>();
public TypedPrincipal[] HasSIDHistory { get; set; } = Array.Empty<TypedPrincipal>();
public TypedPrincipal[] DumpSMSAPassword { get; set; } = Array.Empty<TypedPrincipal>();
public TypedPrincipal[] AllowedToDelegate { get; set; } = [];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This syntax may not compile with older dotnet sdks

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this syntax feature isn't available til dotnet 8
Feature 'collection expressions' is not available in C# 11.0. Please use language version 12.0 or greater.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks dotnet fiddle

Copy link
Contributor

@definitelynotagoblin definitelynotagoblin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants