Page cover

Lockdown (SQLI, FileUpload, Cracking, Yara)

First, we need to enumerate using nmap.

╭─hnl@hnl ~/Desktop/ctf/tryhackme/lockdown  
╰─➤  nmap -A 10.10.38.137 | tee nmap.log
Starting Nmap 7.80 ( https://nmap.org ) at 2022-04-25 20:33 +0630
Nmap scan report for 10.10.38.137
Host is up (0.30s latency).
Not shown: 998 filtered ports
PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 7.6p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey: 
|   2048 27:1d:c5:8a:0b:bc:02:c0:f0:f1:f5:5a:d1:ff:a4:63 (RSA)
|   256 ce:f7:60:29:52:4f:65:b1:20:02:0a:2d:07:40:fd:bf (ECDSA)
|_  256 a5:b5:5a:40:13:b0:0f:b6:5a:5f:21:60:71:6f:45:2e (ED25519)
80/tcp open  http    Apache httpd 2.4.29 ((Ubuntu))
| http-cookie-flags: 
|   /: 
|     PHPSESSID: 
|_      httponly flag not set
|_http-server-header: Apache/2.4.29 (Ubuntu)
|_http-title: Coronavirus Contact Tracer
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 50.95 seconds

Port 80

You will see error. You must be attach ip and domain in /etc/hosts file. After finished, you will see dashboard.

When you click Go to Admin Panel, it will redirect to http://contacttracer.thm/admin/login.php. You can easily bypass using sqli admin' or '1'='1. After this, you will find admin dashboard.

We will create new people with shell.php picture.

And again and again, we try it but no luck. Let's enumerate with gobuster. You will see uploads with 200 status. But noluck.

Let's check http://contacttracer.thm/admin/?page=system_info. Upload a php reverse shell file. Logout and check http://contacttracer.thm/login.php. In netcat session, we got a reverse shell.

User

In /var/www/html, you will found a file called config.php.

Check classes/DBConnection.php.

You can connect mysql using this credential.

Enumerate the database.

You will find admin hash on this databases. Let's crack this.

Switch to cyrus user using cracked password.

Root

Assign ssh key and login to ssh using our own private key.

Login ssh from our machine.

When you check privileges, you will find /opt/scan/scan.sh can run with root privileges.

Check file contents and permissions.

You can see clamav configuration file at /etc/clamav/freshclam.conf.

Database directory is /var/lib/clamav. Let's check this.

We can create our own yara rule file to check the string root and THM.

And then run it.

Finally we can read the root flag.

Root (Shadow)

Create yara rule file with is check shadow file.

Run this clamav.

Here is the shadow file of root.

Crack maxine password using hashcat.

Switch to maxine user and check privileges. Finally, we got root access.

Last updated