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

[tgssub.py] New example script: adding tgssub for SPN-jacking and manual sname manipulation #1256

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

ShutdownRepo
Copy link
Contributor

Example script to allow for SPN-jacking and manual manipulation of tickets to edit the sname (i.e. SPN) the ticket is issued for.
Python equivalent to Rubeus tgssub command (https://github.com/GhostPack/Rubeus#tgssub)

This can be done because the service name is not in the encrypted part of the ticket (cf. Wagging the Dog).

This is already done in Impacket internals with the AnySPN technique but now, attackers can use this standalone script, along with describeTicket.py from #1201 to manipulate (Rubeus tgssub) and inspect tickets (Rubeus describe) manually.

References

Screenshot from 2022-02-12 17-13-20

@ShutdownRepo
Copy link
Contributor Author

#1202 now handles -altservice, allowing for mirroring of Rubeus's ability to do so. Service substitution can then be conducted either separately with this standalone tool, or with getST's new feature brought in bdf6c0e

@wqreytuk
Copy link
Contributor

there is some problem when I integrate this PR to getST
the ticket it generated can not be used when the source ticket is returned by s4u2self

@wqreytuk
Copy link
Contributor

you need to change this too
image

@wqreytuk
Copy link
Contributor

and you will get error here
image

because ticket reutrned by s4u2self have no service class, so there is no '/'

@ShutdownRepo
Copy link
Contributor Author

and you will get error here image

because ticket reutrned by s4u2self have no service class, so there is no '/'

Can you use GitHub's review feature, or indicate lines where you think there are errors?

@ShutdownRepo
Copy link
Contributor Author

there is some problem when I integrate this PR to getST the ticket it generated can not be used when the source ticket is returned by s4u2self

Can you give more details (debug print, screenshot) of what you're trying to do?

@ShutdownRepo
Copy link
Contributor Author

and you will get error here image
because ticket reutrned by s4u2self have no service class, so there is no '/'

Can you use GitHub's review feature, or indicate lines where you think there are errors?

If you're referring to https://github.com/SecureAuthCorp/impacket/pull/1256/files#diff-6282295c24020ba24be7e2a8a1133327088ab06cd43bded706a193ec283ea1e7R49, as you can see this line is in an "if/else" statement checking the presence of "/" in the original ticket's sname. Have you even tried before pointing this out?

@wqreytuk
Copy link
Contributor

there is some problem when I integrate this PR to getST the ticket it generated can not be used when the source ticket is returned by s4u2self

Can you give more details (debug print, screenshot) of what you're trying to do?

I do s4u2self with this RP, and here is the command I use:
getST.py mother.fucker/test$:qwe123... -impersonate Administrator -dc-ip 192.168.56.145 -self -altservice CIFS/WIN-PADVTVG8OT8.mother.fucker -debug
here is the result:
image
seem like all is good, but when I use pass this ticket to smbclient, I got this:
image

@wqreytuk
Copy link
Contributor

and you will get error here image
because ticket reutrned by s4u2self have no service class, so there is no '/'

Can you use GitHub's review feature, or indicate lines where you think there are errors?

If you're referring to https://github.com/SecureAuthCorp/impacket/pull/1256/files#diff-6282295c24020ba24be7e2a8a1133327088ab06cd43bded706a193ec283ea1e7R49, as you can see this line is in an "if/else" statement checking the presence of "/" in the original ticket's sname. Have you even tried before pointing this out?

sorry, maybe I changed your code by accident

@wqreytuk
Copy link
Contributor

and you will get error here image
because ticket reutrned by s4u2self have no service class, so there is no '/'

Can you use GitHub's review feature, or indicate lines where you think there are errors?

If you're referring to https://github.com/SecureAuthCorp/impacket/pull/1256/files#diff-6282295c24020ba24be7e2a8a1133327088ab06cd43bded706a193ec283ea1e7R49, as you can see this line is in an "if/else" statement checking the presence of "/" in the original ticket's sname. Have you even tried before pointing this out?

turns out my code of your tgssub.py is outdated

@ShutdownRepo ShutdownRepo marked this pull request as ready for review February 19, 2022 16:53
…t/cccache credentials

Co-authored-by: wqreytuk <wochinijiamile@qq.com>
@ShutdownRepo
Copy link
Contributor Author

Worked with @wqreytuk, this feature needs further testing, but it now works on our end. The substitution wasn't complete. The information in the ticket wasn't replaced. Only the information in the credential object was. This is now fixed.

@wqreytuk
Copy link
Contributor

just finished testing to this commit, it works fine

@anadrianmanrique anadrianmanrique added the in review This issue or pull request is being analyzed label Feb 16, 2023
@0xdeaddood 0xdeaddood added the low Low priority item label Feb 23, 2023
@ShutdownRepo ShutdownRepo changed the title New example script: adding tgssub for SPN-jacking and manual sname manipulation [tgssub.py] New example script: adding tgssub for SPN-jacking and manual sname manipulation Aug 23, 2023
GeisericII added a commit to ThePorgs/impacket that referenced this pull request Jun 3, 2024
@anadrianmanrique anadrianmanrique self-assigned this Sep 19, 2024
@anadrianmanrique anadrianmanrique removed the low Low priority item label Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Examples in review This issue or pull request is being analyzed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants