# PAM - Pluggable Authentication Modules

<details>

<summary><strong>从零开始学习AWS黑客技术，成为专家</strong> <a href="https://training.hacktricks.xyz/courses/arte"><strong>htARTE（HackTricks AWS红队专家）</strong></a><strong>！</strong></summary>

支持HackTricks的其他方式：

* 如果您想看到您的**公司在HackTricks中做广告**或**下载PDF格式的HackTricks**，请查看[**订阅计划**](https://github.com/sponsors/carlospolop)!
* 获取[**官方PEASS & HackTricks周边产品**](https://peass.creator-spring.com)
* 探索[**PEASS家族**](https://opensea.io/collection/the-peass-family)，我们独家的[**NFTs**](https://opensea.io/collection/the-peass-family)
* **加入** 💬 [**Discord群**](https://discord.gg/hRep4RUj7f) 或 [**电报群**](https://t.me/peass) 或 **关注**我们的**Twitter** 🐦 [**@hacktricks\_live**](https://twitter.com/hacktricks_live)**。**
* 通过向[**HackTricks**](https://github.com/carlospolop/hacktricks)和[**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github仓库提交PR来分享您的黑客技巧。

</details>

#### [WhiteIntel](https://whiteintel.io)

<figure><img src="/files/YEhfJ0lgKxxdqFKA17yB" alt=""><figcaption></figcaption></figure>

[**WhiteIntel**](https://whiteintel.io)是一个由**暗网**支持的搜索引擎，提供免费功能，用于检查公司或其客户是否受到**窃取恶意软件**的**侵害**。

WhiteIntel的主要目标是打击由窃取信息恶意软件导致的账户劫持和勒索软件攻击。

您可以访问他们的网站并免费尝试他们的引擎：

{% embed url="<https://whiteintel.io>" %}

***

### 基本信息

\*\*PAM（可插拔认证模块）\*\*充当一个安全机制，**验证试图访问计算机服务的用户的身份**，根据各种标准控制他们的访问。它类似于数字看门人，确保只有经过授权的用户可以与特定服务互动，同时可能限制其使用以防止系统超载。

#### 配置文件

* **Solaris和基于UNIX的系统**通常使用位于`/etc/pam.conf`的中央配置文件。
* **Linux系统**更倾向于采用目录方式，将特定于服务的配置存储在`/etc/pam.d`中。例如，登录服务的配置文件位于`/etc/pam.d/login`。

登录服务的PAM配置示例可能如下所示：

```
auth required /lib/security/pam_securetty.so
auth required /lib/security/pam_nologin.so
auth sufficient /lib/security/pam_ldap.so
auth required /lib/security/pam_unix_auth.so try_first_pass
account sufficient /lib/security/pam_ldap.so
account required /lib/security/pam_unix_acct.so
password required /lib/security/pam_cracklib.so
password required /lib/security/pam_ldap.so
password required /lib/security/pam_pwdb.so use_first_pass
session required /lib/security/pam_unix_session.so
```

#### **PAM管理领域**

这些领域或管理组包括**auth**、**account**、**password**和**session**，每个负责认证和会话管理过程的不同方面：

* **Auth**：验证用户身份，通常通过提示输入密码。
* **Account**：处理账户验证，检查条件如组成员资格或时间限制。
* **Password**：管理密码更新，包括复杂性检查或防止字典攻击。
* **Session**：管理服务会话开始或结束期间的操作，如挂载目录或设置资源限制。

#### **PAM模块控制**

控制指导模块对成功或失败的响应，影响整体认证过程。这些包括：

* **Required**：必需模块失败会导致最终失败，但只在检查所有后续模块后才会发生。
* **Requisite**：失败会立即终止过程。
* **Sufficient**：成功会绕过同一领域的其余检查，除非后续模块失败。
* **Optional**：仅在堆栈中是唯一模块时才会导致失败。

#### 示例场景

在具有多个auth模块的设置中，流程遵循严格顺序。如果`pam_securetty`模块发现登录终端未经授权，则会阻止root登录，但由于其“required”状态，所有模块仍会被处理。`pam_env`设置环境变量，可能有助于用户体验。`pam_ldap`和`pam_unix`模块共同工作以对用户进行身份验证，其中`pam_unix`尝试使用先前提供的密码，增强了认证方法的效率和灵活性。

### 参考资料

* <https://hotpotato.tistory.com/434>

#### [WhiteIntel](https://whiteintel.io)

<figure><img src="/files/YEhfJ0lgKxxdqFKA17yB" alt=""><figcaption></figcaption></figure>

[**WhiteIntel**](https://whiteintel.io)是一个以**暗网**为动力的搜索引擎，提供**免费**功能，用于检查公司或其客户是否受到**窃取恶意软件**的**损害**。

WhiteIntel的主要目标是打击由信息窃取恶意软件导致的账户劫持和勒索软件攻击。

您可以访问他们的网站并免费尝试他们的引擎：

{% embed url="<https://whiteintel.io>" %}

<details>

<summary><strong>从零开始学习AWS黑客技术，成为专家</strong> <a href="https://training.hacktricks.xyz/courses/arte"><strong>htARTE（HackTricks AWS Red Team Expert）</strong></a><strong>！</strong></summary>

支持HackTricks的其他方式：

* 如果您想在HackTricks中看到您的**公司广告**或**下载PDF格式的HackTricks**，请查看[**订阅计划**](https://github.com/sponsors/carlospolop)！
* 获取[**官方PEASS & HackTricks周边产品**](https://peass.creator-spring.com)
* 发现[**PEASS家族**](https://opensea.io/collection/the-peass-family)，我们的独家[NFTs](https://opensea.io/collection/the-peass-family)收藏品
* **加入** 💬 [**Discord群**](https://discord.gg/hRep4RUj7f) 或 [**电报群**](https://t.me/peass) 或在**Twitter**上关注我们 🐦 [**@hacktricks\_live**](https://twitter.com/hacktricks_live)**。**
* 通过向[**HackTricks**](https://github.com/carlospolop/hacktricks)和[**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github仓库提交PR来分享您的黑客技巧。

</details>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://hacktricks.xsx.tw/linux-hardening/linux-post-exploitation/pam-pluggable-authentication-modules.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
