Skip to content

Commit ac2dfc9

Browse files
authored
Merge pull request Pennyw0rth#422 from Pennyw0rth/neff-fix-maq
Fix maq module if MAQ not set
2 parents 99d4e49 + 6dbf14b commit ac2dfc9

2 files changed

Lines changed: 9 additions & 6 deletions

File tree

nxc/modules/hyperv-host.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def options(self, context, module_options):
2222
def on_admin_login(self, context, connection):
2323
self.context = context
2424

25-
path = "SOFTWARE\Microsoft\Virtual Machine\Guest\Parameters"
25+
path = "SOFTWARE\\Microsoft\\Virtual Machine\\Guest\\Parameters"
2626
key = "HostName"
2727

2828
try:

nxc/modules/maq.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from pyasn1.error import PyAsn1Error
2+
13

24
class NXCModule:
35
"""
@@ -21,9 +23,10 @@ def options(self, context, module_options):
2123
multiple_hosts = False
2224

2325
def on_login(self, context, connection):
24-
result = []
2526
context.log.display("Getting the MachineAccountQuota")
26-
searchFilter = "(objectClass=*)"
27-
attributes = ["ms-DS-MachineAccountQuota"]
28-
result = connection.search(searchFilter, attributes)
29-
context.log.highlight("MachineAccountQuota: %d" % result[0]["attributes"][0]["vals"][0])
27+
result = connection.search("(objectClass=*)", ["ms-DS-MachineAccountQuota"])
28+
try:
29+
maq = result[0]["attributes"][0]["vals"][0]
30+
context.log.highlight(f"MachineAccountQuota: {maq}")
31+
except PyAsn1Error:
32+
context.log.highlight("MachineAccountQuota: <not set>")

0 commit comments

Comments
 (0)