Skip to content

Commit 5fe634d

Browse files
committed
Use SMBv1 in connection info to get hostname from smbv1
1 parent 800bc5e commit 5fe634d

2 files changed

Lines changed: 6 additions & 11 deletions

File tree

nxc/modules/maq.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def options(self, context, module_options):
2626
def on_login(self, context, connection):
2727
context.log.display("Getting the MachineAccountQuota")
2828

29-
ldap_response = connection.search("(objectClass=*)", ["ms-DS-MachineAccountQuota"])
29+
ldap_response = connection.search("(ms-DS-MachineAccountQuota=*)", ["ms-DS-MachineAccountQuota"])
3030
entries = parse_result_attributes(ldap_response)
3131

3232
if not entries:

nxc/protocols/smb.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,7 @@ def get_os_arch(self):
154154
dce.set_auth_type(RPC_C_AUTHN_GSS_NEGOTIATE)
155155
dce.connect()
156156
try:
157-
dce.bind(
158-
MSRPC_UUID_PORTMAP,
159-
transfer_syntax=("71710533-BEBA-4937-8319-B5DBEF9CCC36", "1.0"),
160-
)
157+
dce.bind(MSRPC_UUID_PORTMAP, transfer_syntax=("71710533-BEBA-4937-8319-B5DBEF9CCC36", "1.0"))
161158
except DCERPCException as e:
162159
if str(e).find("syntaxes_not_supported") >= 0:
163160
dce.disconnect()
@@ -174,6 +171,10 @@ def enum_host_info(self):
174171
self.local_ip = self.conn.getSMBServer().get_socket().getsockname()[0]
175172
self.is_host_dc()
176173

174+
# Create SMBv1 connection to get host info, connection will be reinitiated on login
175+
if not self.args.no_smbv1:
176+
self.smbv1 = self.create_smbv1_conn()
177+
177178
try:
178179
self.conn.login("", "")
179180
self.null_auth = True
@@ -274,10 +275,6 @@ def enum_host_info(self):
274275
except Exception as e:
275276
self.logger.debug(f"Error logging off system: {e}")
276277

277-
# Check smbv1
278-
if not self.args.no_smbv1:
279-
self.smbv1 = self.create_smbv1_conn(check=True)
280-
281278
try:
282279
self.db.add_host(
283280
self.host,
@@ -603,8 +600,6 @@ def create_conn_obj(self):
603600
Tries to create a connection object to the target host.
604601
On first try, it will try to create a SMBv3 connection.
605602
On further tries, it will remember which SMB version is supported and create a connection object accordingly.
606-
607-
:param no_smbv1: If True, it will not try to create a SMBv1 connection
608603
"""
609604
# Initial negotiation
610605
if self.smbv3 is None:

0 commit comments

Comments
 (0)