399 words
2 minutes
Pentesting Diary - Hack with Me: [2] Photographer

Photographer|#

BOX: Photographer

Link: https://www.vulnhub.com/entry/photographer-1,519/

TO DO:#

  • Info gathering. Nmap, nikto
  • Exploit:
  • Privilege escalation: SUID
  • REPORT
  • Done!

Info gathering:#

Scan network để tìm ra IP của box.

Untitled

IP Box là: 10.10.10.9. Map local dns cho tiện.

Untitled

Ta chạy nmap và nikto xem thử:

Untitled

Untitled

Enum4linux:

Untitled

Cho chạy fuzz nè:

Untitled

Untitled

Untitled

Cho chạy fuzz tiếp trên port 8000

Untitled

Untitled

Check các file và các directory ta thấy có /admin có thể useful

Untitled

Tổng kết những thông tin useful sau khi chạy fuzz nmap nikto các kiểu con đà điểu nè:#

PORTServicesVersionVulnExploitable?Notes
Nmap80httpApache httpd 2.4.18CVE 2019-0211YesSẽ thử exploit theo cách này sau. Link exploit: https://www.exploit-db.com/exploits/46676
139netbios-ssnSamba smbd 3.X - 4.X (workgroup: WORKGROUP)No
445netbios-ssnSamba smbd 4.3.11-Ubuntu (workgroup: WORKGROUP)No
8000httpApache httpd 2.4.18CVE 2019-0211Yes
Niktonothing useful hereNo
Enum4linuxSMB//10.10.10.9/sambashareYes
PORTFile/DirectoryExploitable ?
FUZZING80nothing usefulNo
8000/adminYes

Exploit:#

Trước hết check smb share thử xem coi có gì đặc biệt hong.

Untitled

Untitled

Khi connect vào bằng smbclient thì ta thấy một file txt. Mở ra đọc thì ta thấy đây là nội dung của 1 email, dựa vào nội dung email này thì mình đoán được username && password như sau:

username = [daisa@photographer.com](mailto:daisa@photographer.com)

password = babygirl

Untitled

Ở trên ta check được form login admin dashboard(/admin) thử điền username&&password này vào thử thì thấy nó work. Ok fine!!!

login admin page

Theo kinh nghiệm của mình thì khi gặp các admin dashboard như này thì việc đầu tiên là check xem có chức năng upload không, nếu có thì tìm cách up shell(bypass filter nếu có). Khá may mắn là ở machine này chỉ filter mấy file hình ảnh cho nên mình dễ dàng bypass bằng cách đổi đuôi file bằng bủhsuite , gòi chỉ việc up lên ròi chiến hoiiii :<.

Shell upload:

Shell: https://raw.githubusercontent.com/pentestmonkey/php-reverse-shell/master/php-reverse-shell.php

Untitled

Untitled

Privilege escalation:#

Get root by SUID

Ta check thấy file php này có SUID:

Untitled

Get Flag! Enjoy ! !!

Untitled

PS:#

Linux privileges:

SUID :

  • Tìm files có SUID:
    • cmd: find / -perm -u=s -type f 2>/dev/null
  • Privileges
    • Khi SUID được gán cho lệnh copy.
      • Ta copy file etc/passwd về máy.
      • Tạo một user mới có quyền root bằng openssl . Cmd: openssl passwd -1 -salt [salt value] {password}.
      • Rồi thêm vào file cuối file passwd ở trên.
      • Upload lại file passwd lên target vào folder /tmp/ xong ghi đè vào file passwd của target.
      • cmd: su . Get root !!!
    • Khi SUID được gán cho lệnh find.
    • Khi SUID được gán cho vim
    • Khác: Ví dụ ở bài trên thì ta check thấy SUID được gán cho file excute php7.2 thì chỉ cần tạo ra 1 bản copy của shell rồi ghi đè lên bỏ qua flag -p đi là get root được.
      • cmd :
      CMD="/bin/sh"
      php -r "pcntl_exec('/bin/sh', ['-p']);"
Pentesting Diary - Hack with Me: [2] Photographer
https://fuwari.vercel.app/posts/photographer/photographer-fc186c93d00c4cbab4ac18c62b8c1a33/
Author
Yasna
Published at
2022-02-06