Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

smbserver does not bind to IPv6 sockets #1787

Open
bert128 opened this issue Aug 7, 2024 · 1 comment
Open

smbserver does not bind to IPv6 sockets #1787

bert128 opened this issue Aug 7, 2024 · 1 comment

Comments

@bert128
Copy link

bert128 commented Aug 7, 2024

Configuration

impacket version: v0.12.0.dev1
Python version: 3.11.9
Target OS: Linux

Debug Output With Command String

impacket-smbserver -debug -ip :: tmp /tmp

# impacket-smbserver -debug -ip :: tmp /tmp
Impacket v0.12.0.dev1 - Copyright 2023 Fortra

[+] Impacket Library Installation Path: /usr/lib/python3/dist-packages/impacket
Traceback (most recent call last):
  File "/usr/share/doc/python3-impacket/examples/smbserver.py", line 71, in <module>
    server = smbserver.SimpleSMBServer(listenAddress=options.interface_address, listenPort=int(options.port))
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/impacket/smbserver.py", line 4891, in __init__
    self.__server = SMBSERVER((listenAddress, listenPort), config_parser=self.__smbConfig)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/impacket/smbserver.py", line 3986, in __init__
    socketserver.TCPServer.__init__(self, server_address, handler_class)
  File "/usr/lib/python3.11/socketserver.py", line 456, in __init__
    self.server_bind()
  File "/usr/lib/python3.11/socketserver.py", line 472, in server_bind
    self.socket.bind(self.server_address)
socket.gaierror: [Errno -9] Address family for hostname not supported

Additional context

In socketserver.py line 439 we have an explicit bind to a legacy socket:

address_family = socket.AF_INET

changing this to AF_INET6 is enough to make it support explicit bindings to ipv6 addresses.

It also by default only tries to bind to the legacy any address in examples/smbserver.py line 43:

parser.add_argument('-ip', '--interface-address', action='store', default='0.0.0.0', help='ip address of listening interface')

Changing the default to :: fixes it.

@anadrianmanrique
Copy link
Contributor

linked with #1811

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants