Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions nxc/protocols/smb.py
Original file line number Diff line number Diff line change
Expand Up @@ -2093,16 +2093,8 @@ def sccm_callback(secret):
@requires_admin
def dpapi(self):
dump_system = "nosystem" not in self.args.dpapi

if self.args.pvk is not None:
try:
self.pvkbytes = open(self.args.pvk, "rb").read() # noqa: SIM115
self.logger.success(f"Loading domain backupkey from {self.args.pvk}")
except Exception as e:
self.logger.fail(str(e))

if self.pvkbytes is None:
self.pvkbytes = get_domain_backup_key(self)

self.pvkbytes = get_domain_backup_key(self)

target = Target.create(
domain=self.domain,
Expand Down
9 changes: 9 additions & 0 deletions nxc/protocols/smb/dpapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@

def get_domain_backup_key(context):
pvkbytes = None
if getattr(context.args, "pvk", None):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This should probably be if context.args.pvk is not None: because the arg always exists (so we don't have to check if it has that attr).

context.logger.display(f"Using provided PVK file: {context.args.pvk}")
try:
with open(context.args.pvk, "rb") as f:
context.logger.success("Loading domain backupkey from file...")
return f.read()
except Exception as e:
context.logger.fail(f"Failed to read PVK file ({context.args.pvk}): {e}")
return False
try:
results = context.db.get_domain_backupkey(context.domain)
except Exception:
Expand Down