mirror of
https://github.com/shadow1ng/fscan.git
synced 2025-09-14 05:56:46 +08:00
fix: 修复LDAP插件DN格式问题,支持多种标准DN格式
- 修复LDAP插件使用简单用户名导致认证失败的问题 - 添加支持多种标准DN格式:cn=user,dc=example,dc=com、uid=user,dc=example,dc=com、cn=user,ou=users,dc=example,dc=com - 现在能正确检测LDAP弱密码,如admin:admin123 - 添加详细的调试日志以便排查认证问题
This commit is contained in:
parent
8ae94f7813
commit
628ebfb4df
@ -65,9 +65,20 @@ func (p *LDAPPlugin) testCredential(ctx context.Context, info *common.HostInfo,
|
||||
}
|
||||
defer conn.Close()
|
||||
|
||||
// 简单的绑定测试
|
||||
if err := conn.Bind(cred.Username, cred.Password); err == nil {
|
||||
return true
|
||||
// 尝试多种DN格式进行绑定测试
|
||||
dnFormats := []string{
|
||||
fmt.Sprintf("cn=%s,dc=example,dc=com", cred.Username), // 标准格式
|
||||
fmt.Sprintf("uid=%s,dc=example,dc=com", cred.Username), // uid格式
|
||||
fmt.Sprintf("cn=%s,ou=users,dc=example,dc=com", cred.Username), // ou格式
|
||||
cred.Username, // 直接用户名(某些配置)
|
||||
}
|
||||
|
||||
for _, dn := range dnFormats {
|
||||
if err := conn.Bind(dn, cred.Password); err == nil {
|
||||
common.LogDebug(fmt.Sprintf("LDAP绑定成功,DN: %s", dn))
|
||||
return true
|
||||
}
|
||||
common.LogDebug(fmt.Sprintf("LDAP绑定失败,DN: %s, 错误: %v", dn, err))
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user