From 74eb4cbcc825564f47b52b7a338330fcd4181eaa Mon Sep 17 00:00:00 2001 From: lapinou Date: Mon, 9 Dec 2024 22:35:02 +0100 Subject: [PATCH 1/4] Update rdp.py Signed-off-by: lapinou --- nxc/protocols/rdp.py | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/nxc/protocols/rdp.py b/nxc/protocols/rdp.py index f6d01d6e3..6a0d6784a 100644 --- a/nxc/protocols/rdp.py +++ b/nxc/protocols/rdp.py @@ -373,18 +373,22 @@ def screenshot(self): asyncio.run(self.screen()) async def nla_screen(self): - # Otherwise it crash - self.iosettings.supported_protocols = None - self.auth = NTLMCredential(secret="", username="", domain="", stype=asyauthSecret.PASS) - self.conn = RDPConnection(iosettings=self.iosettings, target=self.target, credentials=self.auth) - await self.connect_rdp() - await asyncio.sleep(int(self.args.screentime)) - - if self.conn is not None and self.conn.desktop_buffer_has_data is True: - buffer = self.conn.get_desktop_buffer(VIDEO_FORMAT.PIL) - filename = os.path.expanduser(f"~/.nxc/screenshots/{self.hostname}_{self.host}_{datetime.now().strftime('%Y-%m-%d_%H%M%S')}.png") - buffer.save(filename, "png") - self.logger.highlight(f"NLA Screenshot saved {filename}") + for proto in self.protoflags_nla: + try: + self.iosettings.supported_protocols = proto + self.auth = NTLMCredential(secret="", username="", domain="", stype=asyauthSecret.PASS) + self.conn = RDPConnection(iosettings=self.iosettings, target=self.target, credentials=self.auth) + await self.connect_rdp() + await asyncio.sleep(int(self.args.screentime)) + + if self.conn is not None and self.conn.desktop_buffer_has_data is True: + buffer = self.conn.get_desktop_buffer(VIDEO_FORMAT.PIL) + filename = os.path.expanduser(f"~/.nxc/screenshots/{self.hostname}_{self.host}_{datetime.now().strftime('%Y-%m-%d_%H%M%S')}.png") + buffer.save(filename, "png") + self.logger.highlight(f"NLA Screenshot saved {filename}") + return + except Exception: + pass def nla_screenshot(self): if not self.nla: From 5174ce4a6b37b55e6a0f5e33a96c9f43f7240950 Mon Sep 17 00:00:00 2001 From: lapinou Date: Mon, 9 Dec 2024 23:09:12 +0100 Subject: [PATCH 2/4] Update rdp.py Signed-off-by: lapinou --- nxc/protocols/rdp.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/nxc/protocols/rdp.py b/nxc/protocols/rdp.py index 6a0d6784a..d1e73d3ea 100644 --- a/nxc/protocols/rdp.py +++ b/nxc/protocols/rdp.py @@ -379,16 +379,16 @@ async def nla_screen(self): self.auth = NTLMCredential(secret="", username="", domain="", stype=asyauthSecret.PASS) self.conn = RDPConnection(iosettings=self.iosettings, target=self.target, credentials=self.auth) await self.connect_rdp() - await asyncio.sleep(int(self.args.screentime)) - - if self.conn is not None and self.conn.desktop_buffer_has_data is True: - buffer = self.conn.get_desktop_buffer(VIDEO_FORMAT.PIL) - filename = os.path.expanduser(f"~/.nxc/screenshots/{self.hostname}_{self.host}_{datetime.now().strftime('%Y-%m-%d_%H%M%S')}.png") - buffer.save(filename, "png") - self.logger.highlight(f"NLA Screenshot saved {filename}") - return except Exception: - pass + return + + await asyncio.sleep(int(self.args.screentime)) + if self.conn is not None and self.conn.desktop_buffer_has_data is True: + buffer = self.conn.get_desktop_buffer(VIDEO_FORMAT.PIL) + filename = os.path.expanduser(f"~/.nxc/screenshots/{self.hostname}_{self.host}_{datetime.now().strftime('%Y-%m-%d_%H%M%S')}.png") + buffer.save(filename, "png") + self.logger.highlight(f"NLA Screenshot saved {filename}") + return def nla_screenshot(self): if not self.nla: From 8a55f22dc0a709de6c0474e1a24988d9cd5debbc Mon Sep 17 00:00:00 2001 From: lapinou Date: Tue, 10 Dec 2024 19:31:17 +0100 Subject: [PATCH 3/4] Update rdp.py Signed-off-by: lapinou --- nxc/protocols/rdp.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/nxc/protocols/rdp.py b/nxc/protocols/rdp.py index d1e73d3ea..4f0277976 100644 --- a/nxc/protocols/rdp.py +++ b/nxc/protocols/rdp.py @@ -373,11 +373,13 @@ def screenshot(self): asyncio.run(self.screen()) async def nla_screen(self): + self.auth = NTLMCredential(secret="", username="", domain="", stype=asyauthSecret.PASS) + for proto in self.protoflags_nla: try: self.iosettings.supported_protocols = proto - self.auth = NTLMCredential(secret="", username="", domain="", stype=asyauthSecret.PASS) self.conn = RDPConnection(iosettings=self.iosettings, target=self.target, credentials=self.auth) + await self.connect_rdp() except Exception: return From 55c4cfd219fa0f0696a6ac1a07ceb29d60725493 Mon Sep 17 00:00:00 2001 From: Alexander Neff Date: Tue, 10 Dec 2024 17:42:38 -0500 Subject: [PATCH 4/4] Add log message and use NXC_PATH var --- nxc/protocols/rdp.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/nxc/protocols/rdp.py b/nxc/protocols/rdp.py index 4f0277976..9a8a5a469 100644 --- a/nxc/protocols/rdp.py +++ b/nxc/protocols/rdp.py @@ -22,6 +22,8 @@ from asyauth.common.constants import asyauthSecret from asysocks.unicomm.common.target import UniTarget, UniProto +from nxc.paths import NXC_PATH + class rdp(connection): def __init__(self, args, db, host): @@ -166,6 +168,7 @@ def create_conn_obj(self): return True def check_nla(self): + self.logger.debug(f"Checking NLA for {self.host}") for proto in self.protoflags_nla: try: self.iosettings.supported_protocols = proto @@ -381,13 +384,14 @@ async def nla_screen(self): self.conn = RDPConnection(iosettings=self.iosettings, target=self.target, credentials=self.auth) await self.connect_rdp() - except Exception: + except Exception as e: + self.logger.debug(f"Failed to connect for nla_screenshot with {proto} {e}") return await asyncio.sleep(int(self.args.screentime)) if self.conn is not None and self.conn.desktop_buffer_has_data is True: buffer = self.conn.get_desktop_buffer(VIDEO_FORMAT.PIL) - filename = os.path.expanduser(f"~/.nxc/screenshots/{self.hostname}_{self.host}_{datetime.now().strftime('%Y-%m-%d_%H%M%S')}.png") + filename = os.path.expanduser(f"{NXC_PATH}/screenshots/{self.hostname}_{self.host}_{datetime.now().strftime('%Y-%m-%d_%H%M%S')}.png") buffer.save(filename, "png") self.logger.highlight(f"NLA Screenshot saved {filename}") return