> For the complete documentation index, see [llms.txt](https://venator17.gitbook.io/bibliotheque/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://venator17.gitbook.io/bibliotheque/linux/post-exploitation/cred-hunting.md).

# Cred Hunting

## Configuration Files

Configuration files are core of the functionality of services in Linux, so analyzing it would be very useful.

```bash
for l in $(echo ".conf .config .cnf");do echo -e "\nFile extension: " $l; find / -name *$l 2>/dev/null | grep -v "lib\|fonts\|share\|core" ;done
```

### **Credentials in Configuration Files**

```bash
for i in $(find / -name *.cnf 2>/dev/null | grep -v "doc\|lib");do echo -e "\nFile: " $i; grep "user\|password\|pass" $i 2>/dev/null | grep -v "\#";done
```

## &#x20;Databases

```bash
for l in $(echo ".sql .db .*db .db*");do echo -e "\nDB File extension: " $l; find / -name *$l 2>/dev/null | grep -v "doc\|lib\|headers\|share\|man";done
```

## Notes

```bash
find /home/* -type f -name "*.txt" -o ! -name "*.*"
```

## Scripts

```bash
for l in $(echo ".py .pyc .pl .go .jar .c .sh");do echo -e "\nFile extension: " $l; find / -name *$l 2>/dev/null | grep -v "doc\|lib\|headers\|share";done
```

## Cronjobs

```bash
cat /etc/crontab 
```

```bash
 ls -la /etc/cron.*/
```

## SSH Keys

### **Private Keys**

```bash
grep -rnw "PRIVATE KEY" /home/* 2>/dev/null | grep ":1"
```

***

### **Public Keys**

```bash
grep -rnw "ssh-rsa" /home/* 2>/dev/null | grep ":1"
```

## History

### Bash

```bash
tail -n5 /home/*/.bash*
```

### Logs

```bash
for i in $(ls /var/log/* 2>/dev/null);do GREP=$(grep "accepted\|session opened\|session closed\|failure\|failed\|ssh\|password changed\|new user\|delete user\|sudo\|COMMAND\=\|logs" $i 2>/dev/null); if [[ $GREP ]];then echo -e "\n#### Log file: " $i; grep "accepted\|session opened\|session closed\|failure\|failed\|ssh\|password changed\|new user\|delete user\|sudo\|COMMAND\=\|logs" $i 2>/dev/null;fi;done
```

## Memory

### Mimipenguin

<mark style="color:purple;">**Tool**</mark> to dump the login password from the current linux user from here [**\[LINK\]**](https://github.com/huntergregal/mimipenguin)

```
sudo python3 mimipenguin.py
```

### Lazagne

Very good <mark style="color:purple;">**credentials extraction tool**</mark>. Works for Linux and Windows and you can find it here [**\[LINK\]**](https://github.com/AlessandroZ/LaZagne)

```
sudo python3 laZagne.py all
```

***

## Passwd

The <mark style="color:green;">`/etc/passwd`</mark> file contains information about every existing user on the system and can be read by all users and services. `x` in password info section means that hash is stored in shadow file

<table data-header-hidden><thead><tr><th width="163"></th><th width="385"></th><th width="160"></th><th width="111"></th><th></th><th width="135"></th><th width="170"></th></tr></thead><tbody><tr><td><code>venator17:</code></td><td><code>x:</code></td><td><code>1000:</code></td><td><code>0:</code></td><td><code>carnifex17,,,:</code></td><td><code>/home/carnifex17:</code></td><td><code>/bin/bash</code></td></tr><tr><td><code>&#x3C;username>:</code></td><td><code>&#x3C;password info>:</code></td><td><code>&#x3C;UID>:</code></td><td><code>&#x3C;GUID>:</code></td><td><code>&#x3C;Full name/comments>:</code></td><td><code>&#x3C;home directory>:</code></td><td><code>&#x3C;shell>:</code></td></tr></tbody></table>

## Shadow

The <mark style="color:green;">`/etc/shadow`</mark> file contains hashes for users.

<table data-header-hidden><thead><tr><th width="163"></th><th width="385"></th><th width="160"></th><th width="111"></th><th></th><th width="135"></th><th width="170"></th><th width="159"></th><th></th></tr></thead><tbody><tr><td><code>venator17:</code></td><td><code>$y$j9T$3QSBB6CbHEu...SNIP...f8Ms:</code></td><td><code>18955:</code></td><td><code>0:</code></td><td><code>99999:</code></td><td><code>7:</code></td><td><code>:</code></td><td><code>:</code></td><td><code>:</code></td></tr><tr><td><code>&#x3C;username>:</code></td><td><code>&#x3C;encrypted password>:</code></td><td><code>&#x3C;day of last change>:</code></td><td><code>&#x3C;min age>:</code></td><td><code>&#x3C;max age>:</code></td><td><code>&#x3C;warning period>:</code></td><td><code>&#x3C;inactivity period>:</code></td><td><code>&#x3C;expiration date>:</code></td><td><code>&#x3C;reserved field></code></td></tr></tbody></table>

* Hash structure is <mark style="color:blue;">`$<type>$<salt>$<hashed>`</mark>
