videolabs / libdsm

Defective SMb: A minimalist implementation of a client library for SMBv1 using Plain'Ol C

Home Page:http://videolabs.github.io/libdsm

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Netbios reverse lookup & OSX

elthariel opened this issue · comments

OSX doesn't provides the file server entry all the time, so we need to return another name than the <20> if it isn't there

Which API are you using to retrieve the file sever entry? Could you isolate a corner case when it fails?

This entry is very different to the Bonjour localhost name, so we can't recycle that one, right?

This was more a personnal note not to forget to be honest ^^, i know how to solve it.

I'm using a Netbios trick to discover smb servers on the local network, using their yummy broadcast messages (i'm actually sending a broadcast udp packet, but the netbios broadcast flag not set). Most of the servers i've been able to test are responding to my packet saying they aren't the server i want to reach, then i do a reverse lookup on them.

For a given apparent netbios name, like 'TEST', a Netbios speaking box respond to many names on the wire, depending on the service it supports, the type of server it runs. There's 'TEST<0>' (this is a short notation, not the name on the wire) which says it's a workstation (i.e. it has some basic smb knowledge), 'TEST<20>' says it's a file server. There are plenty other for printing services, master browser, domain controller, etc.

The OSX box which was by coincidence on the same network than me didn't have the smb file sharing service activated i suppose (this isn't enabled by default on OSX), so it doesn't returns me any '<20>' name. Since my code is more at the PoC stage right now, i only check for <20> names (this is actually the purpose of the lib). But as a result of this shortcut, it appears the machine has no name.

As you see, this is not really a big deal :) I'm full of shame having you wasting some time on caring on this issue.

As a side note, the trick i'm using to avoir using the full Netbios Name Service to discover local machine, is working unexpectedly well as far as i was able to test. OSX gave me something on the first try (i was pretty happy since i was testing the support on some other box), Win7/8 boxes as well, idem for the SMB speaking NAS at VideoLabs office. The only devices which arent speaking correctly to me are the printers, and honestly, i don't give a fuck and hope you don't as well.

You've noticed by now that i'm in the mood of speaking a lot. I guess i should stop :)