Implement shadow copy dumping for SAM and LSA#1064
Implement shadow copy dumping for SAM and LSA#1064azoxlpf wants to merge 3 commits intoPennyw0rth:mainfrom
Conversation
|
Thanks for the PR, but isn't that something that should be implemented on the impacket side? That's how ntds vss is implemented as well |
This is already implemented on the impacket side. We're using |
Got it okay! The code can probably be a bit more deduplicated tho. |
nxc/protocols/smb.py
Outdated
| SAM = SAMHashes(sam_path, bootkey, isRemote=False, perSecretCallback=lambda secret: add_sam_hash(secret, host_id)) | ||
| self.output_filename = self.output_file_template.format(output_folder="sam") | ||
| SAM.dump() | ||
| SAM.export(self.output_filename) | ||
| self.logger.success(f"Added {highlight(add_sam_hash.sam_hashes)} SAM hashes to the database") | ||
| SAM.finish() |
There was a problem hiding this comment.
This looks redundant to the code of the other methods. Without having access to a proper IDE I can't verify it, but could we move that out of the condition and group it with the others?
There was a problem hiding this comment.
I’ve applied the refactor: the shared logic (dump, export, success message, finish) is no longer inside each branch. Instead, it's now consolidated into a single if SAM: / if LSA: block after the vss vs regdump/secdump branches. I don’t see a cleaner way to do it. Does that sound good to you ?
nxc/protocols/smb.py
Outdated
| LSA = LSASecrets(security_path, bootkey, None, isRemote=False, perSecretCallback=lambda secret_type, secret: add_lsa_secret(secret)) | ||
| self.output_filename = self.output_file_template.format(output_folder="lsa") | ||
| LSA.dumpCachedHashes() | ||
| LSA.exportCached(self.output_filename) | ||
| LSA.dumpSecrets() | ||
| LSA.exportSecrets(self.output_filename) | ||
| self.logger.success(f"Dumped {highlight(add_lsa_secret.secrets)} LSA secrets to {self.output_filename + '.secrets'} and {self.output_filename + '.cached'}") | ||
| LSA.finish() |
Description
This PR extends the shadow copy implementation. Previously, this method was only available for NTDS dumping. I have added support for dumping SAM and LSA secrets using shadow copies as well
Type of change
Insert an "x" inside the brackets for relevant items (do not delete options)
Screenshots (if appropriate):
SAM :
LSA :
Checklist:
Insert an "x" inside the brackets for completed and relevant items (do not delete options)
poetry run python -m ruff check . --preview, use--fixto automatically fix what it can)tests/e2e_commands.txtfile if necessary (new modules or features are required to be added to the e2e tests)