Skip to content

Commit e77eb4e

Browse files
committed
loop over proto, remove RDP|SSL from proto
1 parent 6bf34c8 commit e77eb4e

1 file changed

Lines changed: 20 additions & 19 deletions

File tree

nxc/protocols/rdp.py

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,10 @@ def __init__(self, args, db, host):
3636
self.iosettings.video_out_format = VIDEO_FORMAT.RAW
3737
self.iosettings.clipboard_use_pyperclip = False
3838
self.protoflags_nla = [
39-
SUPP_PROTOCOLS.SSL | SUPP_PROTOCOLS.RDP,
4039
SUPP_PROTOCOLS.SSL,
4140
SUPP_PROTOCOLS.RDP,
4241
]
4342
self.protoflags = [
44-
SUPP_PROTOCOLS.SSL | SUPP_PROTOCOLS.RDP,
4543
SUPP_PROTOCOLS.SSL,
4644
SUPP_PROTOCOLS.RDP,
4745
SUPP_PROTOCOLS.SSL | SUPP_PROTOCOLS.HYBRID,
@@ -170,23 +168,26 @@ def create_conn_obj(self):
170168

171169
async def check_nla(self):
172170
self.logger.debug(f"Checking NLA for {self.host}")
173-
try:
174-
self.iosettings.supported_protocols = SUPP_PROTOCOLS.SSL | SUPP_PROTOCOLS.RDP
175-
self.conn = RDPConnection(
176-
iosettings=self.iosettings,
177-
target=self.target,
178-
credentials=None,
179-
)
180-
packetizer = TPKTPacketizer()
181-
client = UniClient(self.target, packetizer)
182-
self.conn._connection = await asyncio.wait_for(client.connect(), timeout=self.args.rdp_timeout)
183-
self.conn._x224net = X224Network(self.conn._connection)
184-
_, err = await asyncio.wait_for(self.conn._x224net.client_negotiate(0, SUPP_PROTOCOLS.SSL | SUPP_PROTOCOLS.RDP), timeout=self.args.rdp_timeout)
185-
if err is None or "HYBRID_REQUIRED_BY_SERVER" not in str(err):
186-
self.nla = False
187-
return
188-
except Exception:
189-
pass
171+
# Test protocols in order: SSL first, then pure RDP for legacy servers
172+
for proto in self.protoflags_nla:
173+
try:
174+
self.iosettings.supported_protocols = proto
175+
self.conn = RDPConnection(
176+
iosettings=self.iosettings,
177+
target=self.target,
178+
credentials=None,
179+
)
180+
packetizer = TPKTPacketizer()
181+
client = UniClient(self.target, packetizer)
182+
self.conn._connection = await asyncio.wait_for(client.connect(), timeout=self.args.rdp_timeout)
183+
self.conn._x224net = X224Network(self.conn._connection)
184+
_, err = await asyncio.wait_for(self.conn._x224net.client_negotiate(0, proto), timeout=self.args.rdp_timeout)
185+
# If no error, RDP or SSL is supported so no NLA
186+
if err is None:
187+
self.nla = False
188+
return
189+
except Exception:
190+
pass
190191

191192
async def connect_rdp(self):
192193
_, err = await asyncio.wait_for(self.conn.connect(), timeout=self.args.rdp_timeout)

0 commit comments

Comments
 (0)