Skip to content

Allow serviceaccount's name extraction with local secretsdump - #2124

Merged
anadrianmanrique merged 8 commits into
fortra:masterfrom
laxa:secretsdump_local_serviceaccount
Oct 19, 2026
Merged

anadrianmanrique merged 8 commits into
fortra:masterfrom
laxa:secretsdump_local_serviceaccount

Conversation

@laxa

@laxa laxa commented Feb 12, 2026

Copy link
Copy Markdown
Contributor

Currently, when running secretsdump.py on recovered hives, the LSASecrets for service accounts (starting with _SC_) does not handle retrieving the username:

$ secretsdump.py local -system SYSTEM -security SECURITY 
[...]
[*] _SC_wisvc 
(Unknown User):Password

This pull request fix this issue:

$ secretsdump.py local -system SYSTEM -security SECURITY 
[...]
[*] _SC_wisvc 
service1@TEST.LOCAL:Password

@anadrianmanrique anadrianmanrique added the medium Medium priority item label Feb 19, 2026
@anadrianmanrique anadrianmanrique self-assigned this Feb 19, 2026
@laxa

laxa commented Sep 18, 2026

Copy link
Copy Markdown
Contributor Author

Hello, any update on this PR?

@anadrianmanrique

Copy link
Copy Markdown
Collaborator

@laxa hello, I'll be checking this one this week. Thanks

@anadrianmanrique anadrianmanrique added the enhancement Implemented features can be improved or revised label Sep 25, 2026
Comment thread impacket/examples/secretsdump.py Resolved
@anadrianmanrique anadrianmanrique added the waiting for response Further information is needed from people who opened the issue or pull request label Sep 25, 2026
@laxa

laxa commented Sep 29, 2026

Copy link
Copy Markdown
Contributor Author

I forgot to implement the test you requested. Let me know if you prefer local or remote test. For the later case, are there any pointers? For local testing, I could use a lightweight SYSTEM and SECURITY hives to avoid uploading large hives to the repository.

@anadrianmanrique

Copy link
Copy Markdown
Collaborator

linked with #1861

@anadrianmanrique anadrianmanrique removed the waiting for response Further information is needed from people who opened the issue or pull request label Oct 2, 2026
@anadrianmanrique

Copy link
Copy Markdown
Collaborator
  • The fallback fix correctly addresses the original review request.
  • Unconditional .removesuffix("_history") is not safe because _history can be part of a real service name.
  • The code should distinguish OldVal structurally rather than infer it from the name.

A suitable direction is:

def __printSecret(self, name, secretItem, isHistory=False):
      ...
      serviceName = name[4:]
      if isHistory:
          serviceName = serviceName.removesuffix('_history')

      secret = self.getServiceUser(serviceName) + ':'

And at the call site:

  isHistory = valueType == 'OldVal'
  secretName = key + '_history' if isHistory else key
  self.__printSecret(secretName, secret, isHistory=isHistory)

This correctly handles all cases:

  • Current value for backup_history → looks up backup_history
  • Historical value for backup → display name backup_history, looks up backup
  • Historical value for backup_history → display name backup_history_history, looks up backup_history

@anadrianmanrique

Copy link
Copy Markdown
Collaborator

Regarding testcase, a synthetic blob hive would be enough. I can add it later if you want.

@anadrianmanrique anadrianmanrique added the waiting for response Further information is needed from people who opened the issue or pull request label Oct 2, 2026
@laxa
laxa requested a review from anadrianmanrique October 18, 2026 15:31
@laxa

laxa commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor Author

Hello @anadrianmanrique , sorry for the delay to treat such minimalists changes. I have modified the code to reflect the changes you requested.

I used claude to create a minimalist SYSTEM and SECURITY hives and to implement the test regarding this PR, hopefully it will be all good!

@laxa

laxa commented Oct 19, 2026

Copy link
Copy Markdown
Contributor Author

Last commit is to fix the behavior to be similar with remote + -history as the case was not handled correctly by default.

@anadrianmanrique

Copy link
Copy Markdown
Collaborator
  • Added tests for missing service accounts and service names ending in _history.
  • Updated the mock import to remain compatible with master.
  • Fixed empty remote service accounts to display (Unknown User) and added regression coverage.

@anadrianmanrique

Copy link
Copy Markdown
Collaborator

PR is ready to be merged now, thanks!

@anadrianmanrique
anadrianmanrique merged commit 4f0348e into fortra:master Oct 19, 2026
8 checks passed
@NeffIsBack

Copy link
Copy Markdown
Contributor

Very nice, can't wait to try it out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Implemented features can be improved or revised medium Medium priority item 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