Skip to content

Commit

Permalink
Merge pull request #502 from lap1nou/fix-nla-screen
Browse files Browse the repository at this point in the history
Fix RDP '--nla-screenshot' option
  • Loading branch information
NeffIsBack authored Dec 10, 2024
2 parents 2c5037f + 55c4cfd commit 3a44643
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions nxc/protocols/rdp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -373,18 +376,25 @@ 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.conn = RDPConnection(iosettings=self.iosettings, target=self.target, credentials=self.auth)

await self.connect_rdp()
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_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

def nla_screenshot(self):
if not self.nla:
Expand Down

0 comments on commit 3a44643

Please sign in to comment.