Skip to content

Commit b9d788b

Browse files
committed
Change Exception to DCERPCException and added debug log
1 parent b59f252 commit b9d788b

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

nxc/modules/hyperv-host.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,20 @@ class NXCModule:
1515
def __init__(self, context=None, module_options=None):
1616
self.context = context
1717
self.module_options = module_options
18-
1918

2019
def options(self, context, module_options):
2120
""""""
22-
23-
21+
2422
def on_admin_login(self, context, connection):
2523
self.context = context
26-
24+
2725
path = "SOFTWARE\Microsoft\Virtual Machine\Guest\Parameters"
2826
key = "HostName"
2927

3028
try:
3129
remote_ops = RemoteOperations(connection.conn, False)
3230
remote_ops.enableRegistry()
33-
31+
3432
ans = rrp.hOpenLocalMachine(remote_ops._RemoteOperations__rrp)
3533
reg_handle = ans["phKey"]
3634

@@ -43,16 +41,13 @@ def on_admin_login(self, context, connection):
4341
self.context.log.highlight(f"{key}: {reg_value}")
4442

4543
rrp.hBaseRegCloseKey(remote_ops._RemoteOperations__rrp, key_handle)
46-
47-
except Exception:
48-
#self.context.log.fail(f"Registry key {path}\\{key} does not exist")
49-
pass # Muted
5044

45+
except DCERPCException as e:
46+
self.context.log.debug(f"Registry key {path}\\{key} does not exist: {e}")
5147

5248
except DCERPCException as e:
5349
self.context.log.fail(f"DCERPC Error while querying registry: {e}")
5450
except Exception as e:
5551
self.context.log.fail(f"Error while querying registry: {e}")
5652
finally:
5753
remote_ops.finish()
58-

0 commit comments

Comments
 (0)