Skip to content

Add badsuccessor attack example - #2010

Merged
gabrielg5 merged 10 commits into
fortra:masterfrom
fulc2um:badsuccessor
Aug 8, 2025
Merged

gabrielg5 merged 10 commits into
fortra:masterfrom
fulc2um:badsuccessor

Conversation

@fulc2um

@fulc2um fulc2um commented Jul 28, 2025 •

Copy link
Copy Markdown
Contributor

Added badsuccessor.py example based on the AKAMAI research (https://www.akamai.com/blog/security-research/abusing-dmsa-for-privilege-escalation-in-active-directory)

Examples:
Low privileged user info:

Screenshot 2025-07-28 at 10 33 32 AM

Search:
Screenshot 2025-07-28 at 10 12 34 AM

Add:
Screenshot 2025-07-28 at 10 15 12 AM

Delete:
Screenshot 2025-07-28 at 10 15 44 AM

Modify:
Screenshot 2025-08-08 at 11 50 40 AM

Ticket request and code execution:
Screenshot 2025-07-28 at 10 18 09 AM

Screenshot 2025-07-28 at 10 18 45 AM

@fulc2um
fulc2um marked this pull request as draft July 28, 2025 14:23
@fulc2um
fulc2um marked this pull request as ready for review July 28, 2025 14:23
@ThePirateWhoSmellsOfSunflowers

Copy link
Copy Markdown
Contributor

Good job! I was trying to implement this last weeks without success, mostly due to my lack of knowledge on (py)ASN1. Your solution helps me a lot thanks!

🌻

@fulc2um

fulc2um commented Jul 30, 2025

Copy link
Copy Markdown
Contributor Author

Good job! I was trying to implement this last weeks without success, mostly due to my lack of knowledge on (py)ASN1. Your solution helps me a lot thanks!

🌻

Thank you. I appreciate it. Will be here if any adjustments would be necessary to merge it.

@ThePirateWhoSmellsOfSunflowers

ThePirateWhoSmellsOfSunflowers commented Jul 31, 2025 •

Copy link
Copy Markdown
Contributor

Do you think it is possible to put the current/previous keys in an attribute of the GETST object ? This would allow these values to be used in a script for example. Thanks

EDIT: My bad, it is not possible to import an example, maybe it would be better in impacket/krb5/kerberosv5.py 🤷

🌻

@fulc2um

fulc2um commented Jul 31, 2025

Copy link
Copy Markdown
Contributor Author

Do you think it is possible to put the current/previous keys in an attribute of the GETST object ? This would allow these values to be used in a script for example. Thanks

EDIT: My bad, it is not possible to import an example, maybe it would be better in impacket/krb5/kerberosv5.py 🤷

🌻

I can move the key extraction process into the function in kerberosv5.py and just return a dict with keys. Is that the solution you were looking for?

@fulc2um

fulc2um commented Jul 31, 2025 •

Copy link
Copy Markdown
Contributor Author

EDIT: My bad, it is not possible to import an example, maybe it would be better in impacket/krb5/kerberosv5.py 🤷

I added additional message to error handling to match one in Rubeus: GhostPack/Rubeus#194.

Screenshot 2025-07-31 at 2 06 26 PM

On the keys question: Are you sure it is necessary? I was planning to use it as a "local solution" at least for the time being.

@anadrianmanrique anadrianmanrique added the high High priority item label Jul 31, 2025
@mpgn

mpgn commented Jul 31, 2025

Copy link
Copy Markdown
Contributor

Nice @fulc2um !!!

@fulc2um fulc2um changed the title Added badsuccessor attack changes Added badsuccessor attack example Jul 31, 2025
@fulc2um fulc2um changed the title Added badsuccessor attack example Add badsuccessor attack example Jul 31, 2025
@mpgn

mpgn commented Jul 31, 2025

Copy link
Copy Markdown
Contributor

Incredible work ! Works like a charm :)

image image

@ThePirateWhoSmellsOfSunflowers

Copy link
Copy Markdown
Contributor

On the keys question: Are you sure it is necessary? I was planning to use it as a "local solution" at least for the time being.

Because if someone wants to reuse this function ( doS4U , but the same goes for doS4U2ProxyWithAdditionalTicket for example) in a script, they have to copy/paste the entire function into the script. It would be nice to refactor getST to allow, but maybe it is way beyond this PR.

Anyway, I used your code to quickly poc a "domain dumper", it works flawlessly!
badsuccessordumper

@fulc2um

fulc2um commented Jul 31, 2025

Copy link
Copy Markdown
Contributor Author

On the keys question: Are you sure it is necessary? I was planning to use it as a "local solution" at least for the time being.

Because if someone wants to reuse this function ( doS4U , but the same goes for doS4U2ProxyWithAdditionalTicket for example) in a script, they have to copy/paste the entire function into the script. It would be nice to refactor getST to allow, but maybe it is way beyond this PR.

Anyway, I used your code to quickly poc a "domain dumper", it works flawlessly! badsuccessordumper

That is neat 🔥!

@ThePirateWhoSmellsOfSunflowers

Copy link
Copy Markdown
Contributor

Thanks, it is basically just a "for loop" around doS4U but it was fun to do. The code is here

🌻

@Cyb3rGh0st786

Copy link
Copy Markdown

Hello @fulc2um, as per my understanding, DMSA requires a 2025 DC server to exploit. When I run in an environment without the 2025 server using the search option, it shows vulnerable OUs and shows a few identities. What does it mean?

@fulc2um

fulc2um commented Aug 1, 2025 •

Copy link
Copy Markdown
Contributor Author

Hello @fulc2um, as per my understanding, DMSA requires a 2025 DC server to exploit. When I run in an environment without the 2025 server using the search option, it shows vulnerable OUs and shows a few identities. What does it mean?

I forgot to add the DC25/Schema Update check. Mainly because my testing environment is based on Server 2025. Search function is based on original .ps1 script from researchers from Akamai (you can see the link to the script and to the research in description to PR). They mention in their research:

Allowing users to create objects in an OU is a fairly common configuration. As this ability is viewed as benign, it is not likely that users with this privilege will be monitored and hardened appropriately.

So I would interpret that as you have OUs where certain identities are allowed to create objects. While I was thinking about it, you can interpret the results in the following way: if you get results back for a domain without server 2025, that means that when it gets introduced to the domain, there is an easy attack path to DA.

@gabrielg5 gabrielg5 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Hey @fulc2um, thanks for this PR! awesome work!!

Been reviewing the code and added a couple inline comments... also there a couple "global" suggestions I wanna make:

  • Can you change the print for leveraging the logging methods
  • There are 2 different parameters for setting ldaps. Perhaps is better unify both in 1? As they will need to be equal in all scenarios I guess right?
  • Some parameters description specify default values if ommited; but they are being validated as "mandatory" when running given action (-principal-allowed for add, ie)... these scenarios should be aligned so to not require them

Let me know your insights on this.. great work!
Thank you

Comment thread impacket/krb5/asn1.py Resolved
Comment thread impacket/krb5/asn1.py Resolved
Comment thread examples/badsuccessor.py Resolved
Comment thread examples/badsuccessor.py Resolved
Comment thread examples/badsuccessor.py Resolved
Comment thread examples/badsuccessor.py Resolved
Comment thread examples/badsuccessor.py Resolved
Comment thread examples/badsuccessor.py Resolved
Comment thread examples/badsuccessor.py Resolved
@gabrielg5 gabrielg5 added the waiting for response Further information is needed from people who opened the issue or pull request label Aug 7, 2025
fulc2um added 6 commits August 7, 2025 16:52
2. Unified ldaps parameters
3. Renamed PA_DMSA_KEY_PACKAGE to KRB_DMSA_KEY_PACKAGE
4. Refactored ldapConnection to utilize impacket.examples.utils.init_ldap_session
5. Removed "double try" for search_ous replacing with a single one with specified controls value
6. Additional minor fixes
…eviously modification of the entry was not impossible with INSUFF_RIGHTS

2. Added modify_dmsa function
3. Cleaned up unused imports
@gabrielg5
gabrielg5 merged commit 00f43cf into fortra:master Aug 8, 2025
@gabrielg5

Copy link
Copy Markdown
Collaborator

Merging now! 🚀
Thank you!!!

@fulc2um
fulc2um deleted the badsuccessor branch August 8, 2025 20:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

high High 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.

6 participants