Skip to content

Add -machine-only and -request-machine flags to GetUserSPNs.py #2011

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 17 commits into
base: master
Choose a base branch
from

Conversation

ryanq47
Copy link

@ryanq47 ryanq47 commented Jul 28, 2025

Add 2 flags to GetUserSPNs.py, which may be useful for machine account based cracking attempts (Pre2k, timeroasting, etc.)

-machine-only updates the LDAP filter to use objectCategory=computer instead of objectCategory=person

-request-machine functions the same as -request-user, but for machine accounts. It also auto-enables -request, and -machine-only

@anadrianmanrique anadrianmanrique added the in review This issue or pull request is being analyzed label Jul 31, 2025
Copy link
Collaborator

@alexisbalbachan alexisbalbachan left a comment

Choose a reason for hiding this comment

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

The code looks really good, almost ready to merge! I just requested a couple of changes to:

  1. Prevent users from using -request-user and -request-machine at the same time
  2. Keep the code consistent (-request-user does not set the -request flag but -request-machine does, both implementations are fine by themselves but we should keep them aligned)

Comment on lines 466 to +469
parser.add_argument('-request-user', action='store', metavar='username', help='Requests TGS for the SPN associated '
'to the user specified (just the username, no domain needed)')

parser.add_argument('-request-machine', metavar='machinename', help='Requests TGS for the SPN associated to the machine specified. Example: `workstation01$`')
Copy link
Collaborator

Choose a reason for hiding this comment

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

Now that we have the flags to request a single user or a single machine we should not allow both of them at the same time. The suggestion below will create that restriction, otherwise it could be manually checked after parsing the arguments (if options.request_machine is not None and options.request_user is not None: .... error and exit here)

Suggested change
parser.add_argument('-request-user', action='store', metavar='username', help='Requests TGS for the SPN associated '
'to the user specified (just the username, no domain needed)')
parser.add_argument('-request-machine', metavar='machinename', help='Requests TGS for the SPN associated to the machine specified. Example: `workstation01$`')
exclusive_request_group = parser.add_mutually_exclusive_group()
exclusive_request_group.add_argument('-request-user', action='store', metavar='username', help='Requests TGS for the SPN associated '
'to the user specified (just the username, no domain needed)')
exclusive_request_group.add_argument('-request-machine', metavar='machinename', help='Requests TGS for the SPN associated to the machine specified. Example: `workstation01$`')

Comment on lines +527 to +531
# auto enable machineonly, and request flag on -request-machine
if options.request_machine is not None:
options.machine_only = True
options.request = True

Copy link
Collaborator

Choose a reason for hiding this comment

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

Just to make this consistent with request_user: Setting the flag options.request when requesting a machine is not necessary, just check for the flag in line 352 (by adding "or self.__requestMachine is not None"):

if self.__requestTGS is True or self.__requestUser is not None:

With that change, setting options.request is not needed anymore

Suggested change
# auto enable machineonly, and request flag on -request-machine
if options.request_machine is not None:
options.machine_only = True
options.request = True
# auto enable machineonly, and request flag on -request-machine
if options.request_machine is not None:
options.machine_only = True

@alexisbalbachan alexisbalbachan added waiting for response Further information is needed from people who opened the issue or pull request and removed in review This issue or pull request is being analyzed labels Aug 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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