Skip to content

Conversation

gabrielg5
Copy link
Collaborator

This PR fixes #1787

  • smbserver -> added -6 (or --ipv6) flag parameter

It also fixes IPv6 support in ntlmrelayx

  • ntlmrelayx -> fixed case when -6 was set and a specific -ip was configured

Note: It has to be updated after merging #2023 to reuse the utils.get_address function.

@gabrielg5
Copy link
Collaborator Author

Lnking with #1811

@gabrielg5
Copy link
Collaborator Author

On 5c176fa didn't call same function utils.get_address in smbserver to not add a dependency between "examples" and "lib"

Added a comment explaining why repeated code in SMBSERVER constructor
@anadrianmanrique
Copy link
Collaborator

it seems passing -6 parameter without --interface-ip, got broken:

└─$ python3 ntlmrelayx.py -debug -6
Cannot determine Impacket version. If running from source you should at least run "python setup.py egg_info"
Impacket v? - Copyright Fortra, LLC and its affiliated companies

[+] Impacket Library Installation Path: /home/kali/impacket/PRs/2024/impacket/impacket
[*] Protocol Client RPC loaded..
[*] Protocol Client HTTPS loaded..
[*] Protocol Client HTTP loaded..
[*] Protocol Client IMAPS loaded..
[*] Protocol Client IMAP loaded..
[*] Protocol Client SMTP loaded..
[*] Protocol Client SMB loaded..
[*] Protocol Client MSSQL loaded..
[*] Protocol Client LDAPS loaded..
[*] Protocol Client LDAP loaded..
[*] Protocol Client DCSYNC loaded..
[+] Protocol Attack LDAP loaded..
[+] Protocol Attack LDAPS loaded..
[+] Protocol Attack HTTP loaded..
[+] Protocol Attack HTTPS loaded..
[+] Protocol Attack MSSQL loaded..
[+] Protocol Attack SMB loaded..
[+] Protocol Attack DCSYNC loaded..
[+] Protocol Attack IMAP loaded..
[+] Protocol Attack IMAPS loaded..
[+] Protocol Attack RPC loaded..
[*] Running in reflection mode
[*] Setting up SMB Server on port 445
[*] Setting up HTTP Server on port 80
Exception in thread Thread-2:
Traceback (most recent call last):
  File "/usr/lib/python3.12/threading.py", line 1075, in _bootstrap_inner
    self.run()
  File "/home/kali/impacket/PRs/2024/impacket/impacket/examples/ntlmrelayx/servers/httprelayserver.py", line 552, in run
    self.server = self.HTTPServer((self.config.interfaceIp, self.config.listeningPort), self.HTTPHandler, self.config)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kali/impacket/PRs/2024/impacket/impacket/examples/ntlmrelayx/servers/httprelayserver.py", line 47, in __init__
    socketserver.TCPServer.__init__(self, server_address, RequestHandlerClass)
  File "/usr/lib/python3.12/socketserver.py", line 457, in __init__
    self.server_bind()
  File "/usr/lib/python3.12/socketserver.py", line 473, in server_bind
    self.socket.bind(self.server_address)
TypeError: AF_INET address must be a pair (host, port)
[*] Setting up WCF Server on port 9389
[*] Setting up RAW Server on port 6666
Exception in thread Thread-3:
Traceback (most recent call last):
[*] Setting up RPC Server on port 135
  File "/usr/lib/python3.12/threading.py", line 1075, in _bootstrap_inner
Exception in thread Thread-4:
Traceback (most recent call last):
[*] Multirelay enabled

[*] Servers started, waiting for connections
  File "/usr/lib/python3.12/threading.py", line 1075, in _bootstrap_inner
Exception in thread Thread-5:
Traceback (most recent call last):
  File "/usr/lib/python3.12/threading.py", line 1075, in _bootstrap_inner
    self.run()
  File "/home/kali/impacket/PRs/2024/impacket/impacket/examples/ntlmrelayx/servers/rpcrelayserver.py", line 422, in run
    self.server = self.RPCSocketServer((self.config.interfaceIp, self.config.listeningPort), self.RPCHandler,
    self.run()
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kali/impacket/PRs/2024/impacket/impacket/examples/ntlmrelayx/servers/rawrelayserver.py", line 218, in run
  File "/home/kali/impacket/PRs/2024/impacket/impacket/examples/ntlmrelayx/servers/rpcrelayserver.py", line 41, in __init__
    self.run()
    self.server = self.RAWServer((self.config.interfaceIp, rawport), self.RAWHandler, self.config)
  File "/home/kali/impacket/PRs/2024/impacket/impacket/examples/ntlmrelayx/servers/wcfrelayserver.py", line 358, in run
    socketserver.TCPServer.__init__(self, server_address, RequestHandlerClass)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kali/impacket/PRs/2024/impacket/impacket/examples/ntlmrelayx/servers/rawrelayserver.py", line 48, in __init__
    self.server = self.WCFServer((self.config.interfaceIp, wcfport), self.WCFHandler, self.config)
  File "/usr/lib/python3.12/socketserver.py", line 457, in __init__
    socketserver.TCPServer.__init__(self, server_address, RequestHandlerClass)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/socketserver.py", line 457, in __init__
  File "/home/kali/impacket/PRs/2024/impacket/impacket/examples/ntlmrelayx/servers/wcfrelayserver.py", line 56, in __init__
    self.server_bind()
    self.server_bind()
    socketserver.TCPServer.__init__(self, server_address, request_handler_class)
  File "/usr/lib/python3.12/socketserver.py", line 473, in server_bind
  File "/usr/lib/python3.12/socketserver.py", line 473, in server_bind
  File "/usr/lib/python3.12/socketserver.py", line 457, in __init__
    self.socket.bind(self.server_address)
    self.server_bind()
    self.socket.bind(self.server_address)
TypeError: AF_INET address must be a pair (host, port)
TypeError: AF_INET address must be a pair (host, port)
  File "/usr/lib/python3.12/socketserver.py", line 473, in server_bind
    self.socket.bind(self.server_address)
TypeError: AF_INET address must be a pair (host, port)

@gabrielg5
Copy link
Collaborator Author

It was failing every time we configured it to use IPv6
One of the latest commits reverted setting right address_family in relay servers - Fixed in e2deb1f

Thanks!

@anadrianmanrique
Copy link
Collaborator

merging now, Thanks!

@anadrianmanrique anadrianmanrique merged commit 8426ec9 into master Sep 20, 2025
10 checks passed
@gabrielg5 gabrielg5 mentioned this pull request Sep 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

smbserver does not bind to IPv6 sockets
2 participants