PAM receives passwords in clear text. Although it is theoretically possible to write a PAM module, forcing the user to solve an example with data and a function known only to the user and enter the answer instead of the password. Passwords are usually stored in the form of hashes (it depends on the modules used) with the salt (an additional string that makes the hashes of the same passwords unique), which is calculated at the time of setting the new password depending on the time and other random data. A hash is the result of irreversible password encryption, for example, when the key is the password itself. PAM itself does not provide for the application to work with these hashes, they remain inside the modules.
Thus, you need to either intercept passwords through your own PAM module at the time of their installation, or use getspnam() to get the hash from /etc/shadow .
In the first case, the password hashes calculated in the module (so that the password itself could not be known) can be written to a file accessible only to the checking daemon for the web server. The web client will have to hash the password twice. The disadvantages of this method are that after installing the package so that the user can log in to the web service, he must first change the password. And if remote password storage is used, and the user changes his password from another computer, the old password will be valid in the web service.
The second case requires transferring the hash and the salt from /etc/shadow to the web client so that it can hash the password in the same way and then hash it again with random data from the server. If PAM is configured with modules other than pam_unix , the user whose password is stored in a different location must have a password in /etc/shadow as well in order to be able to use the web service. The hashing method must be configured so that the web client can reproduce it.
In the testing daemon itself, there is no need to use PAM.
This non-SSL authentication method is vulnerable to intercepting a password if an attacker can not only monitor traffic, but also interfere with it. By adding his code to the script, he can force the browser to send the password in clear text before hashing.