【问题标题】:How to make ldap evaluate clear text password vs DES stored password如何让 ldap 评估明文密码与 DES 存储密码
【发布时间】:2018-09-04 05:05:59
【问题描述】:

我在 CentoS 6.9 上使用 openldap slapd 2.4.40 和 postgresql9.2.23 作为 back-sql

LDAP uiduserPassword 的用户名和密码通过 DES 编码存储在 postgresql 中。

原始明文是JacicFk5

DES 编码/加密文本为IfjFxsltK/MPE,存储在 DB 中。

我可以通过存储的密码看到作为ldapseach结果的用户信息。

ldapsearch -x  -b "dc=example,dc=com" -D uid="HDZZZ0R0N,ou=people,dc=example,dc=com" -w IfjFxsltK/MPE '(&(uid= HDZZZ0R0N)(objectClass=*))'          
# extended LDIF
#
# LDAPv3
# base <dc=example,dc=com> with scope subtree
# filter: (&(uid= HDZZZ0R0N)(objectClass=*))
# requesting: ALL
#

# user01, people, example.com
dn: uid= HDZZZ0R0N,ou=people,dc=example,dc=com
objectClass: inetOrgPerson
cn:: W+aOkl3lia/nlKPnianjg6Hjg7Pjg4bjg4rjg7PjgrnvvIgzNu+8iVNURw==
sn:: W+aOkl3lia/nlKPnianjg6Hjg7Pjg4bjg4rjg7PjgrnvvIgzNu+8iVNURw==
uid: HDZZZ0R0N
userPassword:: SWZqRnhzbHRLL01QRQ==

但是,我无法通过原始明文密码进行 ldapsearch

ldapsearch -x -b "dc=example,dc=com" -D uid="HDZZZ0R0N,ou=people,dc=example,dc=com" -w JacicFk5 '(&(uid= HDZZZ0R0N)(objectClass=*))'
ldap_bind: Invalid credentials (49)

有没有人告诉我如何让 ldapsearch 以明文方式解析给定密码,并通过 DES 编码来存储密码?

我想知道如何从 ldapseach 命令行将纯文本 JacicFk5 制作成散列 IfjFxsltK/MPE 并使其与 DB 中的 IfjFxsltK/MPE 匹配为 userPassowrd

是否有适合ldap.confslapd.conf 的指令?

我已经检查了以下内容。

echo "SWZqRnhzbHRLL01QRQ==" |perl -MMIME::Base64 -ne 'print decode_base64($_) . "\n"'

它返回IfjFxsltK/MPE

perl -e 'print("userPassword: {crypt}".crypt("JacicFk5","If")."\n");'

它返回userPassword: {crypt}IfjFxsltK/MPE

更多信息。 我的 ldapseach 可以通过 ownclod 为存储在 AD 服务器中的用户解析密码文本。

【问题讨论】:

  • 嗯,我想将存储在 LDAP 中的所有密码转换为纯文本。我总是反过来做。由于我的回答对您没有帮助,因此我将其删除。
  • 根据 slapd2.4.40 ppolicy 的配置文件,除非 swich 打开,否则不会启用。 -enable-ppolicy Password Policy overlay no|yes|mod [no] 我的是 CentOS 的软件包。我无法改变。
  • 我通过启用 ppolicy 自行构建了相同版本的 slapd。没有任何变化。
  • 我现在准备自定义 slapd 源。有没有人告诉我哪个源文件最好添加 DES 加密以使明文密码与存储的密码匹配?
  • @tukan ,您的信息很重要。你不能删除。

标签: hash active-directory openldap des crypt


【解决方案1】:

您想要/需要的是一个 LDAP简单的身份验证。请首先注意,以明文形式存储密码是不安全的!

首先,您需要测试您支持/允许的身份验证机制。

一个例子:

tukanos@localhost:~# ldapsearch -H ldap:// -x -LLL -s base -b "" supportedSASLMechanisms
dn:
supportedSASLMechanisms: DIGEST-MD5
supportedSASLMechanisms: CRAM-MD5
supportedSASLMechanisms: NTLM

现在您想通过ldapmodify 更改配置。您准备一个带有配置的 LDIF 文件(LDIF 代表 LDAP 数据可交换格式)。

准备你的配置文件,你可以把它命名为olcSaslSecProps.ldif

dn: cn=config
replace: olcSaslSecProps
olcSaslSecProps: noanonymous,minssf=0,passcred

属性的含义:

noanonymous ... no anonymous connection allowed
minssf=0 ... that defines your effective encryption strength (0 ... no encryption)
passcred ... that would allow password to work as for credentials

引用OpenLDAP security considerations

安全强度因素

服务器使用安全强度因子 (SSF) 来指示 保护的相对强度。 SSF 为零 (0) 表示没有 保护措施到位。一 (1) 的 SSF 表示完整性 保护到位。 SSF 大约大于一 (>1) 与有效的加密密钥长度相关。例如,DES 是 56、3DES 是 112,而 AES 是 128、192 或 256。

许多管理控制依赖于与 TLS 关联的 SSF 和 LDAP 会话上的 SASL 保护。

当有适当的保护措施时,安全控制不允许操作 没有到位。例如:

    security ssf=1 update_ssf=112

需要对所有操作和加密进行完整性保护 保护,3DES 等效,用于更新操作(例如添加、删除、 修改等)。详见 slapd.conf(5)。

现在应用 LDIF 文件:

ldapmodify -Y EXTERNAL -H ldapi:// -f ./olcSaslSecProps.ldif

现在重新启动slapd 守护进程:

systemctl restart slapd

如果你现在检查你的配置,你应该得到LOGINPLAIN

ldapsearch -H ldap:// -x -LLL -s base -b "" supportedSASLMechanisms
dn:
supportedSASLMechanisms: PLAIN
supportedSASLMechanisms: LOGIN

现在您的搜索应该可以使用纯测试密码了:

ldapsearch -x  -b "dc=example,dc=com" -D uid="HDZZZ0R0N,ou=people,dc=example,dc=com" -w JacicFk5 '(&(uid= HDZZZ0R0N)(objectClass=*))'

【讨论】:

  • 谢谢。我试过了。但是,ldapsearch -H ldap:// -x -LLL -s base -b "" supportedSASLMechanisms 在应用 LDIF 之前和之后不会返回身份验证机制。而且我仍然无法使用原始密码登录。
  • @user1345414 您是否更改了389 以外的默认端口?你能试试ldapsearch -h localhost -p 389 -x -b "dc=example,dc=com" -s base -LLL supportedSASLMechanisms吗?
  • 我做到了。 slapd 只返回dn: dc=example,dc=com 我也试过ldapsearch -LLL -Y EXTERNAL -H ldapi:/// -b cn=config dn slapd 返回SASL/EXTERNAL authentication started ldap_sasl_interactive_bind_s: Authentication method not supported (7) additional info: SASL(-4): no mechanism available: security flags do not match required
  • @user1345414 嗯,你能分享一下配置文件吗? slapcat -F /etc/ldap/slapd.d -b cn=config -l config.ldif(请替换任何敏感信息)
  • 您的命令返回 5b990171 str2entry: entry -1 has no dn slapcat: bad configuration directory! 。但我有 cn=config.ldif 文件dn: cn=config objectClass: olcGlobal cn: config olcArgsFile: /var/run/openldap/slapd.args olcPidFile: /var/run/openldap/slapd.pid structuralObjectClass: olcGlobal entryUUID: 655d9802-393b-1038-89bd-8f0c8273e5e3 creatorsName: cn=config createTimestamp: 20180821030943Z olcPasswordHash: {CRYPT} olcSizeLimit: 5000 olcPasswordCryptSaltFormat: "_%s" olcSaslSecProps: noanonymous,minssf=0,passcred
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-04-16
  • 1970-01-01
  • 1970-01-01
  • 2010-11-09
  • 1970-01-01
  • 2015-05-14
  • 1970-01-01
相关资源
最近更新 更多