-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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:
- Prevent users from using
-request-user
and-request-machine
at the same time - 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)
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$`') |
There was a problem hiding this comment.
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
)
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$`') |
# auto enable machineonly, and request flag on -request-machine | ||
if options.request_machine is not None: | ||
options.machine_only = True | ||
options.request = True | ||
|
There was a problem hiding this comment.
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
"):
impacket/examples/GetUserSPNs.py
Line 352 in c1ccbbf
if self.__requestTGS is True or self.__requestUser is not None: |
With that change, setting options.request
is not needed anymore
# 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 | |
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 useobjectCategory=computer
instead ofobjectCategory=person
-request-machine
functions the same as-request-user
, but for machine accounts. It also auto-enables-request
, and-machine-only