为 Windows 实现 SMB 重定向器的最简单方法?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5115959/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Easiest way to implement a SMB redirector for Windows?
提问by flabdablet
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-molewith workarounds for the various Bad Things that Microsoft keeps adding to Windows to fsck up tunnelling SMB over SSH port forwarding.
我想实现一个小工具,让我可以在 Windows 上做我已经可以在任何其他操作系统上轻松完成的工作 - 通过 IP 地址和端口指定远程 SMB 服务器。本机,Windows将不会做SMB在比445或139(其选择)以外的任何端口,和我讨厌打捶痣与解决方法的各种坏事微软不断加入到Windows中的fsck了隧道SMB通过 SSH 端口转发。
What I have in mind is a little command line app that would let me do something like
我想到的是一个小命令行应用程序,它可以让我做类似的事情
netsubst servername -i IP -p PORT
netsubst 服务器名 -i IP -p 端口
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
这会与司机携手合作吗?dll?它作为 SMB 重定向器连接到 Windows,但会扫描由 netsubst 设置的服务器名称表,而不是在网络上查找它们以找出要连接的内容。所以我可以做
net use X: //servername/sharename /user:username *
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.
以通常的方式,除了 Windows 在它可以找到的任何机器的端口 445 或 139 上寻找 //servername 之外,它会直接转到地址 IP、端口 PORT;如果 IP 碰巧是 127.0.0.1 并且 PORT 碰巧是通过 ssh 转发到其他地方的东西,它就可以正常工作,我将不再需要处理 Windows 围绕访问本地主机端口 139 和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 onlyWindows 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?
我想我需要的东西类似于 VirtualBox 用来进行主机文件共享的 //vboxsvr 来宾添加,但可能更简单,因为它不需要完整的后端 - 在我的理想世界中,这是我唯一的Windows 功能d 需要更换的是与远程 SMB 服务器建立初始连接的部分。但是在我开始深入研究 VirtualBox 源代码之前,有人可以提出一种更简单的方法来完成这项工作,或者向我指出有关实施 SMB 重定向器的 Microsoft 文档吗?
回答by user3242520
\\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.
\\server@port\share
是 WebDAV 的有效语法。在您将@port
UNC 路径表示法放入的那一刻,网络使用从 SMB 更改为 WebDAV。您无法更改 SMB 正在使用的端口。
--Ben
——本
回答by Luke
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
如何编写 Windows 驱动
程序在 MSDN 上开发 Windows 驱动程序
WDK 文档
Good luck.
祝你好运。
You might also find this(PDF) helpful.
您可能还会发现这个(PDF) 很有帮助。
回答by IlPADlI
You may need to implement a network redirector by yourself.
您可能需要自己实现网络重定向器。
Looking TalAloni's SMBLibrary note
and PcapDotNet
, that can make some help.
寻找TalAloni's SMBLibrary note
和PcapDotNet
,这可以提供一些帮助。
回答by user2878907
net use * \\servername@XXXX\
where XXXX is a port number.
I've jast checked it on Windows 7. So it works perfect
net use * \\servername@XXXX\
其中 XXXX 是端口号。我刚刚在 Windows 7 上检查过它。所以它完美无缺