hierynomus / smbj

Server Message Block (SMB2, SMB3) implementation in Java
Other
707 stars 180 forks source link

STATUS_LOGON_FAILURE (0xc000006d): Authentication failed for 'amber' using com.hierynomus.smbj.auth.NtlmAuthenticator@8e0c3e4 #735

Closed XuQK closed 1 year ago

XuQK commented 2 years ago

I searched for relevant information on the Internet, and looked at all related issues, and none of them matched my situation.

This SMB service is enabled on my Mac computer, and the settings are as follows:

image image

I can use mature SMB tools to connect to this service, but I can't use smbj. My connection code is as follows:

val client = SMBClient()
val connection = client.connect("10.0.100.49", 445)
val ac = AuthenticationContext("amber", "password".toCharArray(), null)
val session = connection.authenticate(ac)

The third parameter of AuthenticationContext I have tried "DOMAIN", null, empty string, none of them work.

The log is as follows:

2022-09-07 19:18:10.381 1679-3360/ W/System.err: [DefaultDispatcher-worker-3] INFO com.hierynomus.smbj.connection.PacketEncryptor - Initialized PacketEncryptor with Cipher << AES_128_CCM >>
2022-09-07 19:18:10.383 1679-3360/ W/System.err: [DefaultDispatcher-worker-3] INFO com.hierynomus.smbj.connection.Connection - Successfully connected to: 10.0.100.49
2022-09-07 19:18:10.685 1679-1679/ E/AndroidRuntime: FATAL EXCEPTION: main
Process: , PID: 1679
com.hierynomus.mssmb2.SMBApiException: STATUS_LOGON_FAILURE (0xc000006d): Authentication failed for 'amber' using com.hierynomus.smbj.auth.NtlmAuthenticator@ff6986
at com.hierynomus.smbj.connection.SMBSessionBuilder.setupSession(SMBSessionBuilder.java:144)
at com.hierynomus.smbj.connection.SMBSessionBuilder.setupSession(SMBSessionBuilder.java:142)
at com.hierynomus.smbj.connection.SMBSessionBuilder.establish(SMBSessionBuilder.java:109)
at com.hierynomus.smbj.connection.Connection.authenticate(Connection.java:202)
at .utils.net.smb.TfSmbClient.connect-IoAF18A(TfSmbClient.kt:35)
at .ui.home.network.smb.SmbConnectViewModel$connectToSmb$2.invokeSuspend(SmbConnectViewModel.kt:137)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:749)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664)
Suppressed: kotlinx.coroutines.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@89149e0, Dispatchers.Main.immediate]
2022-09-07 19:18:10.744 1679-1679/ I/Process: Sending signal. PID: 1679 SIG: 9

I've been trying all day, but with little success, frustrated.

hierynomus commented 2 years ago

Have you tried using SMB protocol 2.1 (using the SMBConfig), or try disabling encryption? What have you done to try to pinpoint the problem?

XuQK commented 2 years ago

All I can do is try various SMBConfig combinations, I also tried what you said, but it didn't work. I just turned to an issue (#698) that I missed before, it seems to be related to my problem, I noticed that you didn't comment on the solution, why? I'll try the solution in this issue tomorrow (about 14 hours later) and see if it helps.

XuQK commented 2 years ago

The #698 not work for me. sad.

XuQK commented 2 years ago

0.10.0 work for me,but https://github.com/hierynomus/smbj/issues/698#issuecomment-1072309114 step3 not work for me.

XuQK commented 2 years ago

This pcap file for 0.11.5, may help you. DumpFile01.pcap.zip

XuQK commented 2 years ago

I tried some commit, 3dfc55362bb1f3216ba83e5467ecc73f279d2566 is work fine, but in next 0b6a5236b9c78c35151f1f3815931d68ec4bff86, I got the STATUS_LOGON_FAILURE (0xc000006d) fail.

olivierrivard commented 1 year ago

I had the same issue and rolling back to version 0.10.0 fixed the issue.

hierynomus commented 1 year ago

This is now fixed on master.