Skip to content

added support for --generate-st and --delegate-spn flags #825

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

gatariee
Copy link

@gatariee gatariee commented Jul 25, 2025

Description

  1. Adds the --generate-st Option to save the kerberos tickets when doing RBCD #809 flag when doing RBCD (or CD) with --delegate, opted not to use --generate-tgt as suggested by @NeffIsBack as the resultant ticket is not a TGT and would probably cause some confusion.

  2. Fixed a minor bug in forming the Principal object for the delegation, modified to use the FQDN of the target instead of just the hostname

# serverName = Principal(f"cifs/{self.hostname}", type=constants.PrincipalNameType.NT_SRV_INST.value)
serverName = Principal(f"cifs/{self.hostname}.{self.domain}", type=constants.PrincipalNameType.NT_SRV_INST.value)
  1. Adds the --delegate-spn flag for abusing delegations to services that are not cifs.

Type of change

Insert an "x" inside the brackets for relevant items (do not delete options)

  • 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 not work as expected)
  • Deprecation of feature or functionality
  • This change requires a documentation update
  • This requires a third party update (such as Impacket, Dploot, lsassy, etc)

Setup guide for the review

A machine that is configured with either Constrained Delegation, or Resource-Based Constrained Delegation on another machine.

Screenshots (if appropriate):

FS01$ is allowed to act on behalf of any user to DC02$ on any protocol (RBCD)

25c276566782f156f6142aa490a817f4

Update: --delegate-spn flag, 28/7/2025

FS01$ can delegate to DC02$ on the snmp/dc02.asia.earth.local service.

9ed7d683eac8598d63fc1d52e3e424ba

When used with the --generate-st flag, the resultant CCache is also updated accordingly.

5145ef413b8d6cf540a838972e8f6d5c

Checklist:

Insert an "x" inside the brackets for completed and relevant items (do not delete options)

  • I have ran Ruff against my changes (via poetry: poetry run python -m ruff check . --preview, use --fix to automatically fix what it can)
  • I have added or updated the tests/e2e_commands.txt file if necessary (new modules or features are required to be added to the e2e tests)
  • New and existing e2e tests pass locally with my changes
  • If reliant on changes of third party dependencies, such as Impacket, dploot, lsassy, etc, I have linked the relevant PRs in those projects
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (PR here: https://github.com/Pennyw0rth/NetExec-Wiki)

@mpgn
Copy link
Collaborator

mpgn commented Jul 25, 2025

Why not --generate-st as option name ? 😊

@NeffIsBack NeffIsBack added the enhancement New feature or request label Jul 25, 2025
@NeffIsBack
Copy link
Member

Thanks for the PR! I will take a look at it when i got some time

@RajChowdhury240
Copy link

for SPN is it gonna do only cifs/ ? not others ?

@gatariee
Copy link
Author

for SPN is it gonna do only cifs/ ? not others ?

that was a design choice by whomever designed the --delegate flag, but it makes sense since the SMB service is provisioned using the cifs SPN. I guess you could add host as an alternative

@RajChowdhury240
Copy link

RajChowdhury240 commented Jul 27, 2025

service_types = ["cifs", "host", "http", "ldap", "rpcss", "wsman"]  

spns = []
for service in service_types:
    spn = Principal(f"{service}/{self.hostname}.{self.domain}", type=PrincipalNameType.NT_SRV_INST.value)
    spns.append(spn)
not sure if this would make sense ?

@gatariee
Copy link
Author

if the --delegate flag is ever extended to other protocols (ldap, winrm) then it would make sense, but for now cifs will suffice imo

@mpgn
Copy link
Collaborator

mpgn commented Jul 28, 2025

if the --delegate flag is ever extended to other protocols (ldap, winrm) then it would make sense, but for now cifs will suffice imo

maybe a flag --delegate-spn xxxx i don't think a delegate flag will make ever sense on other proto juste to change an spn

@gatariee
Copy link
Author

if the --delegate flag is ever extended to other protocols (ldap, winrm) then it would make sense, but for now cifs will suffice imo

maybe a flag --delegate-spn xxxx i don't think a delegate flag will make ever sense on other proto juste to change an spn

this was relatively simple, added it to the original PR since it doesn't affect any existing functionality

@gatariee gatariee changed the title added support for --store-st flag added support for --generate-st and --delegate-spn flags Jul 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants