Skip to content

Gain FullControl on arbitrary objects trough ldapshell #1927

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

Merged
merged 1 commit into from
Jul 14, 2025

Conversation

dadevel
Copy link
Contributor

@dadevel dadevel commented Mar 19, 2025

This PR implements a new command in ldap_shell.py called gain_fullcontrol.
It appends a FullControl ACE to the security desriptor of an arbitrary LDAP object.
This target object is specified by a search filter and an optional search base.

In the example below the user jdoe is granted full control over a certificate template and a computer account.

image

image

@dadevel dadevel force-pushed the ldapshell-fullcontrol branch 2 times, most recently from 6be36a2 to 35a087b Compare March 20, 2025 06:22
@anadrianmanrique anadrianmanrique added the in review This issue or pull request is being analyzed label Apr 3, 2025
@gabrielg5
Copy link
Collaborator

Hello @dadevel,

This command is pretty much similar to the grant_control already in the shell...
Main difference is that in gain_fullcontrol you can define the target as a search filter; while in grant_control it's a sAMAccountName.

I think it's better to allow passing a search filter in the grant_control command and inferring this in the function in order to support both "targets definition", whether a search filter or a sAMAccountName
To avoid having many commands fulfilling "same" goal, what do you think?

@gabrielg5 gabrielg5 added waiting for response Further information is needed from people who opened the issue or pull request medium Medium priority item and removed in review This issue or pull request is being analyzed labels Jul 3, 2025
@dadevel
Copy link
Contributor Author

dadevel commented Jul 4, 2025

Yes, sounds good. I will update the PR in the next days.

@dadevel dadevel force-pushed the ldapshell-fullcontrol branch 2 times, most recently from 6e9f6df to ec88ef5 Compare July 9, 2025 22:57
@dadevel
Copy link
Contributor Author

dadevel commented Jul 9, 2025

Hi @gabrielg5, I updated the PR.

❯ nc localhost 11000
Type help for list of commands

# help
...
 grant_control [search_base] target grantee - Grant full control on a given target object (sAMAccountName or search filter plus search base) to the grantee (sAMAccountName).
...

# grant_control cn=configuration,dc=sentinel,dc=local (cn=webserver) jdoe
Resolved 'jdoe' to 'S-1-5-21-1074441319-913972020-3079788021-1103'
Resolved '(cn=webserver)' to 'CN=WebServer,CN=Certificate Templates,CN=Public Key Services,CN=Services,CN=Configuration,DC=sentinel,DC=local'
DACL modified successfully!
jdoe now has control of 'CN=WebServer,CN=Certificate Templates,CN=Public Key Services,CN=Services,CN=Configuration,DC=sentinel,DC=local'

# grant_control dc01$ jdoe
Resolved 'jdoe' to 'S-1-5-21-1074441319-913972020-3079788021-1103'
Resolved '(sAMAccountName=dc01$)' to 'CN=DC01,OU=Domain Controllers,DC=sentinel,DC=local'
DACL modified successfully!
jdoe now has control of 'CN=DC01,OU=Domain Controllers,DC=sentinel,DC=local'

# exit

@gabrielg5 gabrielg5 removed the waiting for response Further information is needed from people who opened the issue or pull request label Jul 10, 2025
@gabrielg5
Copy link
Collaborator

Hey @dadevel thanks!

Been testing it a bit and found a couple use cases that perhaps we could enhance. I tried these:

Target as ldap filter

grant_control (sAMAccountName=target) grantee

We could support setting the target both as a sAMAccountName or as an ldap filter (despite setting or not the search_base)

Target matching multiple objects

grant_control (objectClass=computer) grantee

Leveraging ability to set the target as an ldap filter, we could allow grating control over multiple objects...

@gabrielg5 gabrielg5 added the waiting for response Further information is needed from people who opened the issue or pull request label Jul 10, 2025
@dadevel
Copy link
Contributor Author

dadevel commented Jul 10, 2025

Hi, I'll implement the first idea, but I'm unsure about the second. It could easily lead to unintended/surprising changes.

@dadevel dadevel force-pushed the ldapshell-fullcontrol branch from ec88ef5 to a1ee9f0 Compare July 11, 2025 07:54
@dadevel
Copy link
Contributor Author

dadevel commented Jul 11, 2025

Target as LDAP filter is implemented.

# grant_control (samaccountname=dc01$) jdoe
Resolved 'jdoe' to 'S-1-5-21-1074441319-913972020-3079788021-1103'
Resolved '(samaccountname=dc01$)' to 'CN=DC01,OU=Domain Controllers,DC=sentinel,DC=local'
DACL modified successfully!
'jdoe' now has control of 'CN=DC01,OU=Domain Controllers,DC=sentinel,DC=local'

@gabrielg5
Copy link
Collaborator

Hi, thanks!

yeah, related to second bullet agree with you! Thinking better may lead to unwanted scenarios...

Last tiny detail and merging... if target or grantee are not found the error message is wrong. Now it is showing something like
Could not find user: success:
Could not find target: success:

Thank you!

@dadevel dadevel force-pushed the ldapshell-fullcontrol branch from a1ee9f0 to e282de3 Compare July 12, 2025 15:52
@dadevel
Copy link
Contributor Author

dadevel commented Jul 12, 2025

Hi, I improved the error handling now.

@gabrielg5 gabrielg5 merged commit b6ff7ac into fortra:master Jul 14, 2025
8 checks passed
@gabrielg5
Copy link
Collaborator

Thank you!
Merging now

@dadevel
Copy link
Contributor Author

dadevel commented Jul 14, 2025

Thank you! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
medium Medium priority item waiting for response Further information is needed from people who opened the issue or pull request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants