提问人:ymajoros 提问时间:10/14/2016 最后编辑:ymajoros 更新时间:1/13/2023 访问量:778
SMB 身份验证(74 字节与 24 字节?
smb authentication (74 bytes vs 24?)
问:
我需要实现一个虚拟文件系统,该文件系统将作为 Windows 共享进行访问。
看来Alfresco JLan正在做这项工作。到目前为止,我从这个答案开始有一些有希望的结果:如何将alfresco jlan文件服务器设置为独立的java包?
现在,我似乎无法真正进行身份验证。我的虚拟实现总是成功,但是一旦我尝试验证密码,它就会失败。
一些信息:
- 它在 Windows 机器上运行,端口 445 未被 Windows 本身使用(服务器服务禁用等)
- 在同一个 Windows 10 客户端中,JLan 似乎将其视为 ntlmv1 身份验证,这对我来说看起来很奇怪(我至少期望 ntlmv2)。alg == JLan 中的 NTLM1 .
CifsAuthenticator::validatePassword
- 加密使用的密码似乎是 74 字节,而它期望的密码是 24 字节,但它失败了。
- 不得不删除似乎不再存在的 CryptixCrypto,取而代之的是 JLan,因为它似乎是现代 Java 平台上的必经之路(MD4 默认未注册,如 MD4 类本身所述)。
getInstance("MD4")
MD4.getInstance()
我怎样才能再次检查我的密码,一些纯文本密码?
答:
0赞
queeg
12/28/2021
#1
我使用这两个库取得了巨大的成功。我能够向提供 SMB 共享的 Synology NAS 进行身份验证。
请注意,我使用的版本不一定是最新版本。
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-vfs2</artifactId>
<version>2.4.1</version>
</dependency>
<dependency>
<groupId>eu.agno3.jcifs</groupId>
<artifactId>jcifs-ng</artifactId>
<version>2.1.5</version>
</dependency>
身份验证代码如下所示:
final String smburl = ...;
final String username = ...;
final String password = ...;
final URI uri = new URI(smburl);
StaticUserAuthenticator auth = new StaticUserAuthenticator(null, username, password);
Properties jcifsProperties = new Properties();
// these settings are needed for 2.0.x to use anything but SMB1, 2.1.x enables by default and will ignore
jcifsProperties.setProperty("jcifs.smb.client.enableSMB2", "true");
jcifsProperties.setProperty("jcifs.smb.client.useSMB2Negotiation", "true");
CIFSContext jcifsContext = new BaseContext(new PropertyConfiguration(jcifsProperties));
FileSystemOptions options = new FileSystemOptions();
DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(options, auth);
SmbFileSystemConfigBuilder.getInstance().setCIFSContext(options, jcifsContext);
fsManager = VFS.getManager();
最后,使用 fsManager 将 URI 解析为 FileObjects 并执行必要的操作。
评论
0赞
ymajoros
12/29/2021
谢谢,但我正在寻找 SMB 服务器的实现。它已经工作了一段时间了,顺便说一句:-)
0赞
queeg
12/30/2021
哦,我误会了。我应该删除这个答案还是保留它供其他人找到?
0赞
ymajoros
1/11/2022
无论你的船漂浮在什么地方,但一个不成功的答案,除非它陈述了错误的事实,有时对转化是有用的。所以,谢谢:-)
0赞
queeg
1/11/2022
我完全同意!:-)
评论