Giter Club home page Giter Club logo

wsdd2's Introduction

wsdd2 (1.8.x)

WSD/LLMNR Discovery/Name Service Daemon

With Microsoft turning off SMB1 feature completely on Windows 10, any Samba shares on the local network become invisible to Windows 10 computers. That's due to the fact that SMB1 is required for Computer Browser service to function.

Newer Windows systems can use WSD (Web Services for Devices) to discover shares hosted on other Windows computers while Linux systems normally utilize mNDS/DNS-SD for service discovery. Microsoft is moving to support mDNS/DNS-SD, but not yet there.

The primary purpose of this project is to enable WSD on Samba servers so that network shares hosted on a Unix box can appear in Windows File Explorer / Network.

NOTE: Make sure there is no firewall rule blocking WSD multicast address 239.255.255.250 and ff02::c, protocol UDP port 3702. Unicast SOAP HTTP WS-Discovery responder listens on TCP port 3702.

LLMNR responder listens on multicast 224.0.0.252 / ff02::1:3 UDP port 5355 and unicast TCP port 5355.

The original source code was taken from Netgear ReadyNAS OS v6.9.3 published at https://kb.netgear.com/2649/NETGEAR-Open-Source-Code-for-Programmers-GPL https://www.downloads.netgear.com/files/GPL/ReadyNASOS_V6.9.3_WW_src.zip

Consumed by this openwrt package: https://github.com/openwrt/packages/tree/master/net/wsdd2

Consumed by this archlinux user repository package: https://aur.archlinux.org/packages/wsdd2/

wsdd2's People

Contributors

andy2244 avatar daviey avatar golit avatar kochinc avatar levshutov avatar marcosfrm avatar mfvescovi avatar neheb avatar paul-chambers avatar rmerl avatar themiron avatar tmm1 avatar tripplet avatar vovcat avatar whlsxl avatar wongsyrone avatar xcom169 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

wsdd2's Issues

open_ep: SO_RCVBUFFORCE: Operation not permitted

jul 31 21:45:48 xxx systemd[1]: Started WSD/LLMNR Discovery/Name Service Daemon.
jul 31 21:45:48 xxx wsdd2[615]: cannot read additional dns hostnames from testparm
jul 31 21:45:49 xxx wsdd2[615]: cannot read netbios aliases from testparm
jul 31 21:45:49 xxx wsdd2[615]: starting.
jul 31 21:45:49 xxx wsdd2[615]: open_ep: SO_RCVBUFFORCE: Operation not permitted

From abc8153.

SO_RCVBUFFORCE needs CAP_NET_ADMIN (man 7 socket).

AmbientCapabilities=CAP_NET_RAW

AmbientCapabilities=CAP_NET_RAW CAP_NET_ADMIN

LLMNR does not seem to work

wsdd2 does not bind to port 5355? What is port 60180?

# ss -anp | grep wsdd2
u_dgr  UNCONN  0       0                                          * 22095                                                 * 10970                                users:(("wsdd2",pid=781,fd=3))                    
u_str  ESTAB   0       0                                          * 22069                                                 * 22093                                users:(("wsdd2",pid=781,fd=2),("wsdd2",pid=781,fd=1))
udp    UNCONN  0       0                                    0.0.0.0:3702                                            0.0.0.0:*                                    users:(("wsdd2",pid=781,fd=6))                    
udp    UNCONN  0       0                                    0.0.0.0:3702                                            0.0.0.0:*                                    users:(("wsdd2",pid=781,fd=5))                    
udp    UNCONN  0       0                                    0.0.0.0:3702                                            0.0.0.0:*                                    users:(("wsdd2",pid=781,fd=4))                    
udp    UNCONN  0       0                                    0.0.0.0:60180                                           0.0.0.0:*                                    users:(("wsdd2",pid=781,fd=18))                   
udp    UNCONN  0       0                                    0.0.0.0:60180                                           0.0.0.0:*                                    users:(("wsdd2",pid=781,fd=17))                   
udp    UNCONN  0       0                                    0.0.0.0:60180                                           0.0.0.0:*                                    users:(("wsdd2",pid=781,fd=16))                   
udp    UNCONN  0       0                                       [::]:3702                                               [::]:*                                    users:(("wsdd2",pid=781,fd=7))                    
udp    UNCONN  0       0                                       [::]:3702                                               [::]:*                                    users:(("wsdd2",pid=781,fd=8))                    
udp    UNCONN  0       0                                       [::]:3702                                               [::]:*                                    users:(("wsdd2",pid=781,fd=9))                    
udp    UNCONN  0       0                                       [::]:60180                                              [::]:*                                    users:(("wsdd2",pid=781,fd=19))                   
udp    UNCONN  0       0                                       [::]:60180                                              [::]:*                                    users:(("wsdd2",pid=781,fd=20))                   
udp    UNCONN  0       0                                       [::]:60180                                              [::]:*                                    users:(("wsdd2",pid=781,fd=21))                   
tcp    LISTEN  0       5                             0.0.0.0%enp0s9:60180                                           0.0.0.0:*                                    users:(("wsdd2",pid=781,fd=24))                   
tcp    LISTEN  0       5                             0.0.0.0%enp0s8:60180                                           0.0.0.0:*                                    users:(("wsdd2",pid=781,fd=23))                   
tcp    LISTEN  0       5                             0.0.0.0%enp0s3:60180                                           0.0.0.0:*                                    users:(("wsdd2",pid=781,fd=22))                   
tcp    LISTEN  0       5                             0.0.0.0%enp0s9:3702                                            0.0.0.0:*                                    users:(("wsdd2",pid=781,fd=12))                   
tcp    LISTEN  0       5                             0.0.0.0%enp0s8:3702                                            0.0.0.0:*                                    users:(("wsdd2",pid=781,fd=11))                   
tcp    LISTEN  0       5                             0.0.0.0%enp0s3:3702                                            0.0.0.0:*                                    users:(("wsdd2",pid=781,fd=10))                   
tcp    LISTEN  0       5                                [::]%enp0s3:60180                                              [::]:*                                    users:(("wsdd2",pid=781,fd=25))                   
tcp    LISTEN  0       5                                [::]%enp0s8:60180                                              [::]:*                                    users:(("wsdd2",pid=781,fd=26))                   
tcp    LISTEN  0       5                                [::]%enp0s9:60180                                              [::]:*                                    users:(("wsdd2",pid=781,fd=27))                   
tcp    LISTEN  0       5                                [::]%enp0s3:3702                                               [::]:*                                    users:(("wsdd2",pid=781,fd=13))                   
tcp    LISTEN  0       5                                [::]%enp0s8:3702                                               [::]:*                                    users:(("wsdd2",pid=781,fd=14))                   
tcp    LISTEN  0       5                                [::]%enp0s9:3702                                               [::]:*                                    users:(("wsdd2",pid=781,fd=15))

Windows requests are not answered:

# tcpdump -i enp0s9 port 5355
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on enp0s9, link-type EN10MB (Ethernet), capture size 262144 bytes
09:04:53.115228 IP6 fe80::d5e5:baaf:9db6:923d.64491 > ff02::1:3.hostmon: UDP, length 24
09:04:53.115319 IP 192.168.2.11.64491 > 224.0.0.252.hostmon: UDP, length 24
09:04:53.115469 IP6 fe80::d5e5:baaf:9db6:923d.56007 > ff02::1:3.hostmon: UDP, length 24
09:04:53.115554 IP 192.168.2.11.56007 > 224.0.0.252.hostmon: UDP, length 24
09:04:53.529688 IP6 fe80::d5e5:baaf:9db6:923d.56007 > ff02::1:3.hostmon: UDP, length 24
09:04:53.529745 IP6 fe80::d5e5:baaf:9db6:923d.64491 > ff02::1:3.hostmon: UDP, length 24
09:04:53.529757 IP 192.168.2.11.64491 > 224.0.0.252.hostmon: UDP, length 24
09:04:53.529777 IP 192.168.2.11.56007 > 224.0.0.252.hostmon: UDP, length 24

wsdd2 1.8.3.1, CentOS 8.

warning on startup

I get the following warning message on running wsdd2 -d

cannot read additional dns hostnames from testparm
cannot read netbios aliases from testparm

As there are no aliases or hostnames in smb.conf the messages are correct, although running as -d they should be logged to syslog rather than on stdout/err . I would like to suppress these information messages. I couldn't see an option to do so in the program parameters (only increasing the debug level). Is there a make/makefile option to suppress these messages which are likely to be shown on many samba setups, or a runtime way of suppressing them?

The binary gives a lot of Bindtodevice errors

Memory: 6.5M
CGroup: /system.slice/wsdd2.service
└─583 /usr/sbin/wsdd2

máj 19 08:30:02 x45 wsdd2[583]: error: llmnr-tcp-v6: open_ep: SO_BINDTODEVICE
máj 19 08:30:02 x45 wsdd2[583]: error: llmnr-tcp-v6: open_ep: SO_BINDTODEVICE
máj 19 08:30:04 x45 wsdd2[583]: error: wsdd-http-v4: open_ep: SO_BINDTODEVICE
máj 19 08:30:04 x45 wsdd2[583]: error: wsdd-http-v6: open_ep: SO_BINDTODEVICE
máj 19 08:30:04 x45 wsdd2[583]: error: wsdd-http-v6: open_ep: SO_BINDTODEVICE
máj 19 08:30:04 x45 wsdd2[583]: error: wsdd-http-v6: open_ep: SO_BINDTODEVICE
máj 19 08:30:04 x45 wsdd2[583]: error: llmnr-tcp-v4: open_ep: SO_BINDTODEVICE
máj 19 08:30:04 x45 wsdd2[583]: error: llmnr-tcp-v6: open_ep: SO_BINDTODEVICE
máj 19 08:30:04 x45 wsdd2[583]: error: llmnr-tcp-v6: open_ep: SO_BINDTODEVICE
máj 19 08:30:04 x45 wsdd2[583]: error: llmnr-tcp-v6: open_ep: SO_BINDTODEVICE

connected_if: Machine is not on the network.

When I create a bridge interface between a host (20.20.20.1) and a virtual machine (20.20.20.21), and listen with wsdd2 on that interface, it starts correctly:

starting.
ifname dockerbridge, ifindex 2
hostname 58581c09ba9a, netbios name 58581c09ba9a, workgroup WORKGROUP
wsdd-mcast-v4 udp port 3702 239.255.255.250 20.20.20.1 @ dockerbridge
wsdd-http-v4 tcp port 3702 - 20.20.20.1 @ dockerbridge
llmnr-mcast-v4 udp port 5355 224.0.0.252 20.20.20.1 @ dockerbridge
llmnr-tcp-v4 tcp port 5355 - 20.20.20.1 @ dockerbridge
netlink_recv: address addition/change/deletion detected.
restarting service.
ifname dockerbridge, ifindex 1927
hostname 58581c09ba9a, netbios name 58581c09ba9a, workgroup WORKGROUP
wsdd-mcast-v4 udp port 3702 239.255.255.250 20.20.20.1 @ dockerbridge
wsdd-http-v4 tcp port 3702 - 20.20.20.1 @ dockerbridge
llmnr-mcast-v4 udp port 5355 224.0.0.252 20.20.20.1 @ dockerbridge
llmnr-tcp-v4 tcp port 5355 - 20.20.20.1 @ dockerbridge

The when I try to discover the network inside the Windows VM I can see the incoming queries in the wsdd2 log:

llmnr: connected_if: 20.20.20.21: Machine is not on the network
wsd_recv: wsd_recv_action: connected_if: Machine is not on the network
wsd_recv: wsd_recv_action: connected_if: Machine is not on the network
wsd_recv: wsd_recv_action: connected_if: Machine is not on the network
wsd_recv: wsd_recv_action: connected_if: Machine is not on the network
wsd_recv: wsd_recv_action: connected_if: Machine is not on the network
wsd_recv: wsd_recv_action: connected_if: Machine is not on the network

But wsdd2 fails to send a reply back, everytime it reports Machine is not on the network.

What can be the cause of this? Clearly it is getting the request packets so why cannot send the reply back?

When using wsdd (the Python version of this tool) it works without any problem. So it seems like this a bug in wsdd2.

Windows 11 disappears for a long time Samba

On openwrt run /usr/bin/wsdd2 -i br-lan -N Echo -G WORKGROUP -b vendor:to-be-filled-by-oem-to-be-filled-by-oem,model:To_be_filled_by_O.EM _To_be_filled_by_O.EM
I use windows 11 to start wsdd2 and can find Samba in win11, after 10 minutes refresh File Explorer will disappear! Restarting win11 also fails to discover Samba.
Can only be restored after restarting wsdd2
there is a problem after using this commit

After Vpn client is connected to L2tp/Ipsec (PPPX) Vpn server with wsdd2 running, the server disappears from Neighborhoods !

There is Ubuntu 18.04 x64 LTS no-GUI server.
There is L2tp/Ipsec server is set up on the server, wsdd2 is launched here as well.
There are some Windows clients on local network where the server is sited.
And some Vpn clients - Android/Windows exists as well.
Initially the server is shown on local network Windows clients neighborhood.
But after establishing L2tp/Ipsec connection from Vpn clients (PPPX interface is added) ther server disaapears from local network Windows clients neighborhood.
Only wsdd2 daemon restarnig helps to return the server to neighborhood.

Why is os happened ?

Patch:

          Patch:
---
 wsd.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/wsd.c b/wsd.c
index 0b4b3d2..3593aa8 100644
--- a/wsd.c
+++ b/wsd.c
@@ -214,9 +214,9 @@ int set_getresp(const char *str, const char **next)
        val = p;

        /* Look for end of value. */
-       while (*p && *p != ':' && *p != ',')
+       while (*p && *p != ',')
                p++;
-       if (*p && *p != ',')
+       if (*p)
                goto exit;

        vallen = p - val;
@@ -225,7 +225,7 @@ int set_getresp(const char *str, const char **next)

        /* Look for key in lookup table. */
        for (i = 0; bootinfo[i].key; i++)
-               if (!strncasecmp(bootinfo[i].key, str, keylen))
+               if (keylen == strlen(bootinfo[i].key) - 1 && !strncasecmp(bootinfo[i].key, str, keylen))
                        break;

        if (!bootinfo[i].key)
--

Originally posted by @xnoreq in #16 (comment)

New interface bug

WSDD2 is running on a specific interface with -i key.

is_new_addr() is called when network is changed.
It changes ifindex to modifyed interface index by mistake.

if (!if_indextoname(ifindex, buf) || strcmp(buf, ifname) != 0)

should be

if (!if_indextoname(ifam->ifa_index, buf) || strcmp(buf, ifname) != 0)

bind interface '-i' incomplete

Connecting from an unprotected WAN still seems to succeed. I suppose the socket code will need to be amended to only bind to the interface's IP address, and not to 0.0.0.0.

netstat -an | egrep 3702
tcp        0      0 0.0.0.0:3702            0.0.0.0:*               LISTEN
tcp        0      0 :::3702                 :::*                    LISTEN
udp        0      0 0.0.0.0:3702            0.0.0.0:*
udp        0      0 :::3702                 :::*

wsdd-mcast-v6 init failed: wsd_init: uuid_endpoint: Invalid argument

Build on Ubuntu 20.04,

apt-get install -y \
  make \
  gcc \
  linux-libc-dev \
  linux-headers-$(uname -r) \

Build succeeded, but after execution, got this error:

wsdd-mcast-v6 init failed: wsd_init: uuid_endpoint: Invalid argument

Can't find samba file server on Windows Network

Adjust debian/rules for b2d1098

b2d1098 changed LIBDIR to /usr/lib (for systemd service file), default in the RPM world (Fedora/RH, SUSE, Mageia). But I forgot about the Debian packaging. AFAIK Debian is still using /lib, right?

Can anyone with expertise in Debian packaging adjust debian/rules if necessary? I think export LIBDIR=/lib is enough, please take a look.

Thanks.

tag request

hi andy, any chance could you tag or release the current version. it makes it easier to download a version with a known md5sum.

Interface -i ... switch does not work correctly.

There is Ubuntu18.04 x64 and 1.8.3.1 wsdd2 version.
There are lan0 and wa0 interfaces.
While wsdd2 -i lan0 starts I see:

connected_if: lo: if=127.0.0.1 sc=192.168.0.80 nm=255.0.0.0
connected_if: wan0: if=55.66.77.88 sc=192.168.0.80 nm=255.255.255.248
connected_if: lan0: if=192.168.0.254 sc=192.168.0.80 nm=255.255.255.0
connected_if: lo: if=127.0.0.1 sc=192.168.0.80 nm=255.0.0.0
connected_if: wan0: if=55.66.77.88 sc=192.168.0.80 nm=255.255.255.248
connected_if: lan0: if=192.168.0.254 sc=192.168.0.80 nm=255.255.255.0
connected_if: lo: if=127.0.0.1 sc=192.168.0.80 nm=255.0.0.0
connected_if: wan0: if=55.66.77.88 sc=192.168.0.80 nm=255.255.255.248
connected_if: lan0: if=192.168.0.254 sc=192.168.0.80 nm=255.255.255.0
connected_if: lo: if=127.0.0.1 sc=192.168.0.80 nm=255.0.0.0
connected_if: wan0: if=55.66.77.88 sc=192.168.0.80 nm=255.255.255.248
connected_if: lan0: if=192.168.0.254 sc=192.168.0.80 nm=255.255.255.0

Also there is Iptables with rule allowing outgoing multicas traffic from lan0 interface and no rule to allow it from wan0.
And when wsdd2 starts error is appeared:
wsdd2[22074]: error: wsdd-mcast-v4: wsd_send_soap_msg: send: Operation not permitted

Is it correct behaviour or incorrect that is issue ?

Wsdd2 with Samba as AD DC.

There is case when Samba4 where wsdd2 works is acting as AD DC.
As following wsdd2 should return not WORKGROUP:NAME but as DOMAIN:NAME.
I think so.
May be it;s worh to add it.

Correct usage of strncpy

Adding the debian CFLAGS option in the Makefile for improved security

CFLAGS = -g -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security

results in a warning from the strncpy call here
https://github.com/Andy2244/wsdd2/blob/3b2a6a476b47822e7231a0f209c725489da50801/wsdd2.c#L396

In file included from /usr/include/string.h:519,
                 from wsdd.h:30,
                 from wsdd2.c:23:
In function ‘strncpy’,
    inlined from ‘open_ep’ at wsdd2.c:396:3:
/usr/include/bits/string_fortified.h:106:10: warning: ‘__builtin_strncpy’ output may be truncated copying 15 bytes from a string of length 15 [-Wstringop-truncation]
  106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Context of the reported error:
https://github.com/Andy2244/wsdd2/blob/3b2a6a476b47822e7231a0f209c725489da50801/wsdd2.c#L393-L404

ifr.ifr_name is of size IFNAMSIZ and assuming ep->ifname also a size of IFNAMSIZ.

The call should be

strncpy(ifr.ifr_name, ep->ifname, IFNAMSIZ); 

Reference
https://en.cppreference.com/w/c/string/byte/strncpy

I'm not sure if this is the best approach or if a fix is even necessary as this would only lead to a problem if ep->ifname has exactly IFNAMSIZ-1 characters followed by the terminating 0 character:

Example:
http://cpp.sh/6xxiz

Can't be seen on the network in win10' s file resource manager

Hello, porting wsdd2 cross-compilation to arm platform has fully opened ports 3702 and 5355, but it still can't be seen on the network in win10' s file resource manager, but "win+R" can be displayed on the network by entering the host name. This step has proved that win10 triggered the netbios/llmnr protocol. Has anyone tried this? If so, can you tell me how to do it?

E7298FF9-236D-4323-BE35-03509F7C3667

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.