> 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/easy/internal.md).

# Internal

## 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 21,80 -sS -Pn -sCV`&#x20;

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

As we can see, it tries to redirect to `http://internal.dl` so we will add this domain to our `/etc/hosts:`

We tried to find exploits or shellcodes using `searchsploit` but there wasn't any. Our next step will be directory enumeration. Using our tool `ffuf-vhost`:

```
ffuf-vhost () {
	ffuf -H "Host: FUZZ.$1" -u http://$1 -w /usr/share/wordlists/seclists/Discovery/DNS/subdomains-top1million-20000.txt ${@: 2}
}
```

we did `ffuf-dir internal.dl` and we found the following subdomains, so we add it also to `/etc/hosts`:

<figure><img src="/files/3vqNBYGtSeCLNFmXeL2j" alt=""><figcaption></figcaption></figure>

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

Browsing `internal.dl` gives us little to no information, but `backup.internal.dl` give us a potential attack vector:

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

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

As we can see, there is a field where we input a path, and the server is executing a `ls -lah:`

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

## 3 - Exploitation

Trying to do `/etc/passwd | echo "test"` and many other operators get blacklisted, so we start trying all the potential ways to bypass the WAF. Finally, we found that with `$()` we can bypass the operator blacklist, but many commands like `echo` or `cat` are blacklisted too.

This is a minor problem, as usually we can bypass it via `c '' a '' t`, and this is a example of that situation.

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

Knowing this, we could craft a reverse shell to catch it with `penelope` . For this, we need to create it on our attacking host, and download it from the victim via wget.

<figure><img src="/files/8KTeSCH3pnseArqULvG2" alt=""><figcaption></figcaption></figure>

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

After setting up our listener with `penelope -p 3110` we will activate it via `$(b''a''s''h /opt/revshell)`.

<figure><img src="/files/8HcpzpYBezRT5smT04gk" alt=""><figcaption></figcaption></figure>

## 4 - Privilege Escalation

Doing `/find -type f -name "*.txt" 2>/dev/null` we will try to find any .txt file storing credentials or any useful data, and we found the following one:

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

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

We can see reading `/etc/passwd` that `vault` is a system user, so we'll try to perform an `hydra` attack on him using that set of passwords:

<figure><img src="/files/2ru5kC5r45hJDMpTdbsh" alt=""><figcaption></figcaption></figure>

We found `vault:Yk8$pZ5@cN4!` , so we will access via SSH.

Running the following commands trying to find useful information, we got this files:

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

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

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

As we saw on the SUID listing, we have `/usr/local/bin/vaultctl` with SUID bit activated, and after researching a bit, just by executing it we'll spawn a root shell:

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