如何使用 PAM 以明文形式检索用户密码?
我正在编写一个 PAM 模块,它将用户名/密码写入文件中,以便其他应用程序进行进一步的事务处理。我只看到了 PAM_AUTHTOK 项,但我不确定它是哪种类型。有人知道获取明文密码的方法或其他方法吗?
I am writing a PAM module which writes the username/password in a file for further transaction by an other application. I only saw the PAM_AUTHTOK item but I'm not sure from which type is it. Anybody knows that or another way to get the cleartext password?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这是一个非常古老的线程,但也有 pam_exec:
https://linux.die.net/man/8/pam_exec
例如类似的东西PAM 配置中的以下内容:
myscript-example 的内容,回显所有变量:
This is a very old thread, but there is also pam_exec:
https://linux.die.net/man/8/pam_exec
e.g. Something like the following in the PAM Config:
Contents of myscript-example, echoing all the vars out:
您是否阅读过 Linux-PAM 应用程序开发人员指南?在 RHEL 类型的系统上,该文件位于
/usr/share/doc/pam-devel-/Linux-PAM_ADG.txt
中,或者您可以在 在各个地方在线。查看获取 PAM 项部分,其中记录了
pam_get_item()
函数。您可以使用PAM_AUTH_TOK
常量请求密码:Have you read the Linux-PAM Application Developer's Guide? On a RHEL-type system this will be in
/usr/share/doc/pam-devel-<version>/Linux-PAM_ADG.txt
, or you can find it online at online at various places.Take a look at the Getting PAM items section, which documents the
pam_get_item()
function. You can request the password with thePAM_AUTH_TOK
constant:在调试时只打印 PAM_AUTHTOK 的内容怎么样?为了有意义地使用它,无论如何,模块之间必须有某种契约或约定。
顺便说一句:将明文密码保留在内存中并尽快从那里删除它(或者更好:在 RAM 中锁定该区域,或进行加密交换)与将该明文密码写入磁盘之间是有区别的。后者太不安全了,不要这样做。
How about just printing the contents of PAM_AUTHTOK when you're debugging? To make a meaningful use of it you must have some sort of a contract or convention between modules anyway.
By the way: there is a difference between keeping a cleartext password in memory and erasing it from there as soon as possible (or better: locking that region in RAM, or having encrypted swap), and writing that cleartext password to disk. The latter is just sooo insecure, don't do that.