NetExec icon indicating copy to clipboard operation
NetExec copied to clipboard

added support for `--generate-st` and `--delegate-spn` flags

Open gatariee opened this issue 5 months ago • 10 comments

Description

  1. Adds the --generate-st https://github.com/Pennyw0rth/NetExec/issues/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)
  • [x] 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
  • [x] 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)

  • [x] 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
  • [x] I have performed a self-review of my own code
  • [x] 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)

gatariee avatar Jul 25 '25 09:07 gatariee

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

mpgn avatar Jul 25 '25 10:07 mpgn

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

NeffIsBack avatar Jul 25 '25 12:07 NeffIsBack

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

RajChowdhury240 avatar Jul 27 '25 15:07 RajChowdhury240

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

gatariee avatar Jul 27 '25 15:07 gatariee

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 ?

RajChowdhury240 avatar Jul 27 '25 15:07 RajChowdhury240

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

gatariee avatar Jul 27 '25 16:07 gatariee

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

mpgn avatar Jul 28 '25 07:07 mpgn

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 avatar Jul 28 '25 09:07 gatariee

Thank tou Gatariee & nxc team this looks awesome! made RBCD more fun <3

RajChowdhury240 avatar Jul 29 '25 02:07 RajChowdhury240

image

RajChowdhury240 avatar Jul 29 '25 03:07 RajChowdhury240

is it gonna get merged anytime soon Team ??

RajChowdhury240 avatar Nov 15 '25 22:11 RajChowdhury240