|
3 | 3 | from impacket.dcerpc.v5.rpcrt import RPC_C_AUTHN_GSS_NEGOTIATE |
4 | 4 | from impacket.smbconnection import SessionError |
5 | 5 | from nxc.helpers.misc import CATEGORY |
| 6 | +from impacket.nmb import NetBIOSError |
6 | 7 |
|
7 | 8 |
|
8 | 9 | class NXCModule: |
9 | 10 | # https://www.synacktiv.com/en/publications/ntlm-reflection-is-dead-long-live-ntlm-reflection-an-in-depth-analysis-of-cve-2025 |
| 11 | + # Modified by azoxlpf to handle BrokenPipe/transport errors gracefully |
10 | 12 | name = "ntlm_reflection" |
11 | 13 | description = "Attempt to check if the OS is vulnerable to CVE-2025-33073 (NTLM Reflection attack)" |
12 | 14 | supported_protocols = ["smb"] |
@@ -76,21 +78,27 @@ def on_login(self, context, connection): |
76 | 78 | self.context.log.info(f"RemoteRegistry is probably deactivated: {e}") |
77 | 79 | else: |
78 | 80 | self.context.log.debug(f"Unexpected error: {e}") |
| 81 | + except (BrokenPipeError, ConnectionResetError, NetBIOSError, OSError) as e: |
| 82 | + context.log.debug(f"ntlm_reflection: DCERPC transport error: {e.__class__.__name__}: {e}") |
79 | 83 |
|
80 | 84 | def trigger_winreg(self, connection, context): |
81 | 85 | # Original idea from https://twitter.com/splinter_code/status/1715876413474025704 |
82 | 86 | # Basically triggers the RemoteRegistry to start without admin privs |
83 | | - tid = connection.connectTree("IPC$") |
84 | 87 | try: |
85 | | - connection.openFile( |
86 | | - tid, |
87 | | - r"\winreg", |
88 | | - 0x12019F, |
89 | | - creationOption=0x40, |
90 | | - fileAttributes=0x80, |
91 | | - ) |
92 | | - except SessionError as e: |
93 | | - # STATUS_PIPE_NOT_AVAILABLE error is expected |
94 | | - context.log.debug(str(e)) |
95 | | - # Give remote registry time to start |
96 | | - time.sleep(1) |
| 88 | + tid = connection.connectTree("IPC$") |
| 89 | + try: |
| 90 | + connection.openFile( |
| 91 | + tid, |
| 92 | + r"\winreg", |
| 93 | + 0x12019F, |
| 94 | + creationOption=0x40, |
| 95 | + fileAttributes=0x80, |
| 96 | + ) |
| 97 | + except SessionError as e: |
| 98 | + # STATUS_PIPE_NOT_AVAILABLE error is expected |
| 99 | + context.log.debug(str(e)) |
| 100 | + # Give remote registry time to start |
| 101 | + time.sleep(1) |
| 102 | + return True |
| 103 | + except (SessionError, BrokenPipeError, ConnectionResetError, NetBIOSError, OSError): |
| 104 | + return False |
0 commit comments