SMB2Dialect.SMB_3_1_1 only run withBufferSize(65536) on Windows system
abigliar opened this issue · comments
the latest SMBJ-RPC only run SMB2Dialect.SMB_3_1_1 withBufferSize(65536) max
65536 is the biggest buffer size SMBJ-RPC supports in SMB2Dialect.SMB_3_1_1, but the default buffer size in SMBJ is 1024x1024 = 1048576 = 65536x16
There is no such restriction when using SMB2Dialect.SMB_3_0_2 and blew, they run with the default buffer size well.
interesting, so was this the cause of the issue you were seeing in #164
It's specificically transact buffer size > 64K that cause stack trace above with 3.1.1 dialect.
So if you want to use this dialect, to fix this issue, you can use withTransactBufferSize(64*1024)
and independently whatever sizes you need or want for read and write.
Also, this issue seems specific to Windows, as it does not happen on my Samba server (a recent version) with 3.1.1 dialect.
yeah, you are right.
I tried 3.1.1 dialect in my NAS just now, it works successfully. There are something different in the Windows.
Thank you!
@abigliar Could you specify what release or which git head this is fixed in?
The lasted version.
@abigliar Could you specify what release or which git head this is fixed in?
The lasted version.
I can confirm that the issue still occurs, here is test code:
public static void main(String[] args) throws Exception {
SmbConfig cfg = SmbConfig.builder()
.withBufferSize(1024 * 1024) //it works if we put 64*1024 here!!!!!!!!!!!!!!!!!!!!
.withSecurityProvider(new BCSecurityProvider())
.build();
SMBClient client = new SMBClient(cfg);
Connection connection = client.connect("111.111.111.111");
AuthenticationContext ac = new AuthenticationContext("user", "password".toCharArray(), "");
Session session = connection.authenticate(ac);
final RPCTransport transport = SMBTransportFactories.SRVSVC.getTransport(session);
final ServerService serverService = new ServerService(transport);
// Get shares at information level 0
final List<NetShareInfo0> shares = serverService.getShares0();
for (final NetShareInfo0 share : shares) {
System.out.println(share);
}
}
pom.xml
<dependency>
<groupId>com.rapid7.client</groupId>
<artifactId>dcerpc</artifactId>
<version>0.12.0</version>
</dependency>
stacktrace:
{"message":"Initialized PacketEncryptor with Cipher << AES_128_GCM >>"}
{"message":"Successfully connected to: 111.111.111.111"}
{"message":"Successfully authenticated user on 111.111.111.111, session is 35189002603689"}
{"message":"Connecting to \\\\111.111.111.111\\IPC$ on session 35189002603689"}
{"message":"Decrypting packet Encrypted for session id << 35189002603689 >>"}
{"message":"Decrypting packet Encrypted for session id << 35189002603689 >>"}
{"message":"Decrypting packet Encrypted for session id << 35189002603689 >>"}
Exception in thread "main" com.rapid7.helper.smbj.io.SMB2Exception: SMB2_IOCTL returned 3221225485 (3221225485/3221225485): expected=[STATUS_SUCCESS, STATUS_BUFFER_OVERFLOW]
at com.rapid7.helper.smbj.io.SMB2SessionMessage.sendAndRead(SMB2SessionMessage.java:100)
at com.rapid7.helper.smbj.share.NamedPipe._ioctl(NamedPipe.java:109)
at com.rapid7.helper.smbj.share.NamedPipe.transact(NamedPipe.java:65)
at com.rapid7.client.dcerpc.transport.SMBTransport.transact(SMBTransport.java:33)
at com.rapid7.client.dcerpc.transport.RPCTransport.bind(RPCTransport.java:54)
at com.rapid7.client.dcerpc.transport.SMBTransportFactories.getTransport(SMBTransportFactories.java:61)
at com.mypackage.vergen.Main.main(Main.java:43)
note, that if we change withBufferSize to 64*1024 it works as expected!