-
Notifications
You must be signed in to change notification settings - Fork 405
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
[Draft] POC ldap3 implementation for schannel authentication #412
Draft
LightxR
wants to merge
1
commit into
Pennyw0rth:main
Choose a base branch
from
LightxR:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+954
−219
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -219,7 +219,6 @@ def update_priv(self, user: User, exec_as=""): | |
""" | ||
if self.is_admin_user(user.username): | ||
user.is_sysadmin = True | ||
self.context.log.debug(f"Updated {user.username} to is_sysadmin") | ||
return True | ||
user.dbowner = self.check_dbowner_privesc(exec_as) | ||
return user.dbowner | ||
|
@@ -250,15 +249,11 @@ def is_admin(self, exec_as="") -> bool: | |
self.revert_context(exec_as) | ||
is_admin = res[0][""] | ||
self.context.log.debug(f"IsAdmin Result: {is_admin}") | ||
try: | ||
if int(is_admin): | ||
self.context.log.debug("User is admin!") | ||
self.admin_privs = True | ||
return True | ||
else: | ||
return False | ||
except ValueError: | ||
self.logger.fail(f"Error checking if user is admin, got {is_admin} as response. Expected 0 or 1.") | ||
if is_admin: | ||
self.context.log.debug("User is admin!") | ||
self.admin_privs = True | ||
return True | ||
else: | ||
return False | ||
|
||
def get_databases(self, exec_as="") -> list: | ||
|
@@ -447,15 +442,10 @@ def is_admin_user(self, username) -> bool: | |
""" | ||
res = self.query_and_get_output(f"SELECT IS_SRVROLEMEMBER('sysadmin', '{username}')") | ||
is_admin = res[0][""] | ||
try: | ||
if is_admin != "NULL" and int(is_admin): | ||
self.admin_privs = True | ||
self.context.log.debug(f"Updated: {username} is admin!") | ||
return True | ||
else: | ||
return False | ||
except ValueError: | ||
self.context.log.fail(f"Error checking if user is admin, got {is_admin} as response. Expected 0 or 1.") | ||
if is_admin: | ||
self.admin_privs = True | ||
return True | ||
else: | ||
Comment on lines
+445
to
+448
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same with this |
||
return False | ||
|
||
def revert_context(self, exec_as): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,16 @@ | ||
from impacket.ldap import ldapasn1 as ldapasn1_impacket | ||
|
||
def parse_result_attributes(ldap_response): | ||
parsed_response = [] | ||
for entry in ldap_response: | ||
# SearchResultReferences may be returned | ||
if not isinstance(entry, ldapasn1_impacket.SearchResultEntry): | ||
if entry["type"] != "searchResEntry": | ||
continue | ||
attribute_map = {} | ||
for attribute in entry["attributes"]: | ||
val = [str(val) for val in attribute["vals"].components] | ||
attribute_map[str(attribute["type"])] = val if len(val) > 1 else val[0] | ||
if "description" in attribute: | ||
attribute_map[str(attribute)] = "" if entry['attributes'][attribute] == [] else str(entry['attributes'][attribute][0]) | ||
elif "pwdLastSet" in attribute: | ||
attribute_map[str(attribute)] = str(entry['attributes'][attribute]) | ||
else: | ||
attribute_map[str(attribute)] = entry['attributes'][attribute] | ||
parsed_response.append(attribute_map) | ||
return parsed_response |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something is off here. Multiple lines are fixes introduced in the last months. Perhaps the commit containing this change reverted them.