From 7a7030a65fc4356ba363c563e13eabf16e1d0dff Mon Sep 17 00:00:00 2001 From: Warren Date: Mon, 15 Jun 2026 01:11:25 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=B1=E5=BA=A6=E5=88=86=E6=9E=90=EF=BC=9A?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=AE=8C=E6=95=B4exchange=20hash=20component?= =?UTF-8?q?s=20logging?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加详细logging: - V_C/V_S: 完整SSH string encoding bytes - I_C/I_S: prepend SSH_MSG_KEXINIT byte验证 - K_S: 完整host key blob bytes - Q_C/Q_S: 完整32 bytes ECDH keys - K: shared secret mpint encoding bytes 验证结果: ✅ 所有encoding格式正确(SSH string, mpint) ✅ KEXINIT prepend byte正确(uint32(len+1) + byte(20) + payload) ✅ 所有component lengths正确 但仍MAC失败,唯一可能: - OpenSSH client计算exchange hash方式不同 - 需要对比OpenSSH client连接OpenSSH server成功 vs MarkBaseSSH失败 下一步建议: 1. 手动启动OpenSSH server(解决port占用) 2. 使用Wireshark GUI完整对比packet 3. 或使用OpenSSH client源码验证exchange hash计算 Session progress: - OpenSSH源码深度对比:100% - KEXINIT encoding修复:100% - Exchange hash components验证:100% - MAC失败root cause:待查 --- data/auth.sqlite | Bin 73728 -> 73728 bytes markbase-core/src/ssh_server/kex_exchange.rs | 36 +++++++++++++------ 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/data/auth.sqlite b/data/auth.sqlite index e75155bc7b3347089cf1351c29afc7b0bee7f756..3e7f0cd050714fa68299d891050830909010ee4b 100644 GIT binary patch delta 171 zcmZoTz|wGlWr8&0(up$8j7v8rw97E+Pd+H6FquR44%_{uO&q<3n_tPYF#_3*b-f0Y zzsdb!y1#Vu7y0M>k{fuLWtnpGb5rw5iYnPQax#lDrKINOv#sC!MgIf8zy?-kPA0aE q3=Aw_22j)lB;-`WtnpGb5rw5iYnPwb25uErKINOv#s3xMgIf8z$#W|PA0b1 q3=Aw_22j) 0 && trimmed_shared_secret[0] >= 0x80 { let mut mpint = vec![0u8]; @@ -274,8 +288,10 @@ impl KexExchangeHandler { info!(" mpint_shared_secret_data ({} bytes): {:?}", mpint_shared_secret_data.len(), &mpint_shared_secret_data[..std::cmp::min(8, mpint_shared_secret_data.len())]); // mpint格式 = uint32(length) + mpint_data - hasher.update(&(mpint_shared_secret_data.len() as u32).to_be_bytes()); + let mpint_len_bytes = &(mpint_shared_secret_data.len() as u32).to_be_bytes(); + hasher.update(mpint_len_bytes); hasher.update(&mpint_shared_secret_data); + info!(" Exchange hash component K (shared secret mpint): len={} bytes=[{:?}] data_len={} (first 8 bytes=[{:?}])", 4+mpint_shared_secret_data.len(), mpint_len_bytes, mpint_shared_secret_data.len(), &mpint_shared_secret_data[..std::cmp::min(8, mpint_shared_secret_data.len())]); Ok(hasher.finalize().to_vec()) }