Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Easiest way to implement a SMB redirector for Windows?

Tags:

windows

smb

I would like to implement a little tool that lets me do on Windows what I can already do easily on any other OS - specify a remote SMB server by both IP address and port. Natively, Windows will not do SMB over any ports other than 445 or 139 (its choice), and I'm sick of playing whack-a-mole with workarounds for the various Bad Things that Microsoft keeps adding to Windows to fsck up tunnelling SMB over SSH port forwarding.

What I have in mind is a little command line app that would let me do something like

netsubst servername -i IP -p PORT

This would work hand in hand with a driver? dll? that hooks into Windows as an SMB redirector, but scans a table of server names set up by netsubst instead of looking them up on the network in order to find out what to connect to. So I'd be able to do

net use X: //servername/sharename /user:username *

in the usual way, except that instead of Windows looking for //servername on ports 445 or 139 of whatever machines it could find, it would go straight to address IP, port PORT; and if IP happened to be 127.0.0.1 and PORT happened to be something forwarded to somewhere else via ssh, it would All Just Work and I would no longer need to deal with the walls of stupid that Windows puts around access to localhost ports 139 and 445.

I figure what I need is something akin to the //vboxsvr guest addition that VirtualBox uses to do host file sharing, but probably rather simpler since it wouldn't need a full back end - in my ideal world, the only Windows functionality I'd need to replace is the part that establishes the initial connection to the remote SMB server. But before I start tearing into the VirtualBox source code, can somebody suggest an easier way to get this done, or perhaps point me to Microsoft documentation on implementing SMB redirectors?

like image 926
flabdablet Avatar asked Feb 25 '11 10:02

flabdablet


2 Answers

\\server@port\share is a valid syntax for WebDAV. The moment you put the @port in the UNC path notation, net use changes from SMB to WebDAV. You cannot change the port SMB is using.

--Ben

like image 158
user3242520 Avatar answered Sep 30 '22 19:09

user3242520


Writing a driver is not easy; it requires a lot of domain specific knowledge. Here are some links to get started:

How to Write a Windows Driver
Develop a Windows Driver
WDK Documentation on MSDN

Good luck.

You might also find this (PDF) helpful.

like image 25
Luke Avatar answered Sep 30 '22 19:09

Luke