Trick

Recon

chevron-rightnmap_scan.loghashtag
Open 10.129.141.189:25
Open 10.129.141.189:22
Open 10.129.141.189:53
Open 10.129.141.189:80
[~] Starting Script(s)
[>] Running script "nmap -vvv -p {{port}} {{ip}} -sV -sC -Pn" on ip 10.129.141.189

PORT   STATE SERVICE REASON  VERSION
22/tcp open  ssh     syn-ack OpenSSH 7.9p1 Debian 10+deb10u2 (protocol 2.0)
| ssh-hostkey: 
|   2048 61:ff:29:3b:36:bd:9d:ac:fb:de:1f:56:88:4c:ae:2d (RSA)
| ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC5Rh57OmAndXFukHce0Tr4BL8CWC8yACwWdu8VZcBPGuMUH8VkvzqseeC8MYxt5SPL1aJmAsZSgOUreAJNlYNBBKjMoFwyDdArWhqDThlgBf6aqwqMRo3XWIcbQOBkrisgqcPnRKlwh+vqArsj5OAZaUq8zs7Q3elE6HrDnj779JHCc5eba+DR+Cqk1u4JxfC6mGsaNMAXoaRKsAYlwf4Yjhonl6A6MkWszz7t9q5r2bImuYAC0cvgiHJdgLcr0WJh+lV8YIkPyya1vJFp1gN4Pg7I6CmMaiWSMgSem5aVlKmrLMX10MWhewnyuH2ekMFXUKJ8wv4DgifiAIvd6AGR
|   256 9e:cd:f2:40:61:96:ea:21:a6:ce:26:02:af:75:9a:78 (ECDSA)
| ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBAoXvyMKuWhQvWx52EFXK9ytX/pGmjZptG8Kb+DOgKcGeBgGPKX3ZpryuGR44av0WnKP0gnRLWk7UCbqY3mxXU0=
|   256 72:93:f9:11:58:de:34:ad:12:b5:4b:4a:73:64:b9:70 (ED25519)
|_ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGY1WZWn9xuvXhfxFFm82J9eRGNYJ9NnfzECUm0faUXm
25/tcp open  smtp?   syn-ack
|_smtp-commands: Couldn't establish connection on port 25
53/tcp open  domain  syn-ack ISC BIND 9.11.5-P4-5.1+deb10u7 (Debian Linux)
| dns-nsid: 
|_  bind.version: 9.11.5-P4-5.1+deb10u7-Debian
80/tcp open  http    syn-ack nginx 1.14.2
|_http-title: Coming Soon - Start Bootstrap Theme
|_http-favicon: Unknown favicon MD5: 556F31ACD686989B1AFCF382C05846AA
|_http-server-header: nginx/1.14.2
| http-methods: 
|_  Supported Methods: GET HEAD
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

DNS (53)

└─$ dig -x 10.129.141.189 @10.129.141.189 | grep -vE '^$|;'
189.141.129.10.in-addr.arpa. 604800 IN  PTR     trick.htb.
141.129.10.in-addr.arpa. 604800 IN      NS      trick.htb.
trick.htb.              604800  IN      A       127.0.0.1
trick.htb.              604800  IN      AAAA    ::1

└─$ dig axfr trick.htb @10.129.141.189 | grep -vE '^$|;'
trick.htb.              604800  IN      SOA     trick.htb. root.trick.htb. 5 604800 86400 2419200 604800
trick.htb.              604800  IN      NS      trick.htb.
trick.htb.              604800  IN      A       127.0.0.1
trick.htb.              604800  IN      AAAA    ::1
preprod-payroll.trick.htb. 604800 IN    CNAME   trick.htb.
trick.htb.              604800  IN      SOA     trick.htb. root.trick.htb. 5 604800 86400 2419200 604800

└─$ dig ANY trick.htb @10.129.141.189 | grep -vE '^$|;'
trick.htb.              604800  IN      SOA     trick.htb. root.trick.htb. 5 604800 86400 2419200 604800
trick.htb.              604800  IN      NS      trick.htb.
trick.htb.              604800  IN      A       127.0.0.1
trick.htb.              604800  IN      AAAA    ::1
trick.htb.              604800  IN      A       127.0.0.1
trick.htb.              604800  IN      AAAA    ::1

HTTP (80)

Writeup.png

Main domain is just serving index.html.

Subdomain from DNS is serving PHP application, but it's protected with login form.

Writeup-1.png

Some pages display without authorization and some are just includes.

Writeup-2.png

In /employee.php source we see Javascript making calls to /view_employee.php?id=<ID>

Using EmployeeID doesn't show anything.

http://preprod-payroll.trick.htb/view_employee.php?id=9arrow-up-right

Writeup-3.png

Testing for SQLi:

Database is completely empty. Let's see what current user can do, --os-shell failed to work.

https://dev.mysql.com/doc/refman/8.4/en/privileges-provided.htmlarrow-up-right -> FILEarrow-up-right -- File_priv -- File access on server host


I thought sqlmap failed to read files, but no. It's just not displaying it on STDOUT


Do it manually

We leaked the application full path from Nginx configuration and then leaked the database configuration.

No luck on SSH, but we have another host

Writeup-4.png

The website is vulnerable to LFI, but we already have LFI with MySQL... (?)

It's doesn't mention, but other service might be running this.

SMTP is running, but there's no mail in /var/mail/USERNAME 🤔

If we can send mail and include it with PHP that would get us code execution!

Looks good, we are able to send emails.

SSH (22)

User.txt

Privilege Escaltion

As part of security we have write permissions in fail2ban directory.

Fail2Ban – Linux Privilege Escalationarrow-up-right

Change the rule and restart the service

fail2ban works by banning the IPs that try to bruteforce SSH for example, perform bruteforce so actionban will trigger

User.txt

Last updated