Skip to content

Commit 398716d

Browse files
authored
Merge pull request Pennyw0rth#376 from Pennyw0rth/neff-patch-2
Add try&except block for DCERPCExceptions to fix Pennyw0rth#373
2 parents 8ed4149 + a1ca269 commit 398716d

1 file changed

Lines changed: 26 additions & 25 deletions

File tree

nxc/modules/ioxidresolver.py

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
# Credit to https://airbus-cyber-security.com/fr/the-oxid-resolver-part-1-remote-enumeration-of-network-interfaces-without-any-authentication/
22
# Airbus CERT
33
# module by @mpgn_x64
4+
# updated by @NeffIsBack
45

56
from ipaddress import ip_address
67
from impacket.dcerpc.v5 import transport
7-
from impacket.dcerpc.v5.rpcrt import RPC_C_AUTHN_LEVEL_NONE
8+
from impacket.dcerpc.v5.rpcrt import RPC_C_AUTHN_LEVEL_NONE, DCERPCException
89
from impacket.dcerpc.v5.dcomrt import IObjectExporter
910

1011

@@ -13,31 +14,31 @@ class NXCModule:
1314
description = "This module helps you to identify hosts that have additional active interfaces"
1415
supported_protocols = ["smb", "wmi"]
1516
opsec_safe = True
16-
multiple_hosts = False
17+
multiple_hosts = True
1718

1819
def options(self, context, module_options):
19-
""" """
20+
"""No module options"""
2021

2122
def on_login(self, context, connection):
22-
authLevel = RPC_C_AUTHN_LEVEL_NONE
23-
24-
stringBinding = r"ncacn_ip_tcp:%s" % connection.host
25-
rpctransport = transport.DCERPCTransportFactory(stringBinding)
26-
rpctransport.setRemoteHost(connection.host)
27-
28-
portmap = rpctransport.get_dce_rpc()
29-
portmap.set_auth_level(authLevel)
30-
portmap.connect()
31-
32-
objExporter = IObjectExporter(portmap)
33-
bindings = objExporter.ServerAlive2()
34-
35-
context.log.debug("[*] Retrieving network interface of " + connection.host)
36-
37-
for binding in bindings:
38-
NetworkAddr = binding["aNetworkAddr"]
39-
try:
40-
ip_address(NetworkAddr[:-1])
41-
context.log.highlight("Address: " + NetworkAddr)
42-
except Exception as e:
43-
context.log.debug(e)
23+
try:
24+
rpctransport = transport.DCERPCTransportFactory(f"ncacn_ip_tcp:{connection.host}")
25+
rpctransport.setRemoteHost(connection.host)
26+
27+
portmap = rpctransport.get_dce_rpc()
28+
portmap.set_auth_level(RPC_C_AUTHN_LEVEL_NONE)
29+
portmap.connect()
30+
31+
objExporter = IObjectExporter(portmap)
32+
bindings = objExporter.ServerAlive2()
33+
34+
context.log.debug(f"Retrieving network interface of {connection.host}")
35+
36+
for binding in bindings:
37+
NetworkAddr = binding["aNetworkAddr"]
38+
try:
39+
ip_address(NetworkAddr[:-1])
40+
context.log.highlight(f"Address: {NetworkAddr}")
41+
except Exception as e:
42+
context.log.debug(e)
43+
except DCERPCException as e:
44+
context.log.error(f"DCERPCException error: {e}")

0 commit comments

Comments
 (0)