> For the complete documentation index, see [llms.txt](https://itszaiden.gitbook.io/pentesting/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://itszaiden.gitbook.io/pentesting/writeups/dockerlabs/very-easy/injection.md).

# Injection

SQL injection on the login panel revealed plaintext SSH credentials, allowing direct access to the system.

## 1 - Reconnaissance

We begin with a fast Nmap scan to identify open ports:

`nmap 172.17.0.2 -p- --open -sS -Pn --min-rate 5000 -T5`

**Result: ports 22 and 80 are open**

## 2 - Enumeration

Now we run a service/version detection scan, targeting only the open ports we found on the previous scan:

`nmap 172.17.0.2 -p 22,80 -sS -Pn -sCV`

**Result:**

<figure><img src="https://438683079-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIbHEScEP34huXd5EXNdb%2Fuploads%2FN965tzwIamZdUrGfHPc3%2F(Injection)%20Targeted%20Port%20Scan.png?alt=media&amp;token=3306205f-229f-4d70-a775-3dde34c0f672" alt=""><figcaption><p>(Injection) Targeted Port Scan</p></figcaption></figure>

We tried to find exploits or shellcodes using `searchsploit OpenSSH 8.9p1` and \`searchsploit Apache httpd 2.4.52 but there wasn't any. Our next step will be directory enumeration.

With the command `ffuf -w /path/to/wordlist/directory-list-2.3-medium.txt:FUZZ -u http://10.129.129.108/FUZZ` we didn't find anything useful, so we will browse the website,

<figure><img src="https://438683079-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIbHEScEP34huXd5EXNdb%2Fuploads%2FNwcWB6KFWfNFS0Np8FtD%2F(Injection)%20Web%20Content.png?alt=media&amp;token=0eee0ce7-cb0f-47b8-acf4-90671042ec81" alt=""><figcaption><p>(Injection) Web Content</p></figcaption></figure>

## 3 - Exploitation

As the machine name is `Injection` we will try a basic SQLi:

```
User: admin' or 1=1#
Password: test
```

We logged succesfully and we found potential SSH credentials:

<figure><img src="https://438683079-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIbHEScEP34huXd5EXNdb%2Fuploads%2FrpY6s8RBcVwLfCxbQ4bP%2F(Injection)%20Dylan%20Credentials.png?alt=media&amp;token=57c38f77-4c8b-4c48-89f0-6b65a707ecb7" alt=""><figcaption><p>(Injection) Dylan Credentials</p></figcaption></figure>

Trying them on SSH we log in successfully.

<figure><img src="https://438683079-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIbHEScEP34huXd5EXNdb%2Fuploads%2Fqo21Z3TbO6YozfOepRmx%2F(Injection)%20SSH%20Login.png?alt=media&amp;token=95979570-cb34-4249-8651-554717273e93" alt=""><figcaption><p>(Injection) SSH Login</p></figcaption></figure>

## 4 - Summary

**Initial Access:** Performed SQL injection on the website login form to bypass authentication and recover plaintext SSH credentials, which granted direct shell access.
