DEV Community

Peppa
Peppa

Posted on

CBJS: Path Traversal 4

Mục Tiêu

  • Chiếm quyền điều khiển server và đọc một tập tin bí mật ở thư mục gốc (đường dẫn /)

Attack

  • Ban đầu cần create a account

Image description

  • Có thể upload file

Image description

  • Tên file không hề được filter nhưng sau khi lưu sẽ được đổi thành avarta.jpg

Image description

  • File sẽ tồn tại ở folder document_root/upload/name/avatar.jpg

  • Ta thấy có 1 đoạn code load game bằng include với biến $game là untrusted data không hề được sàng lọc

Image description

  • Thay đổi biến game gây ra lỗi server để tìm ra document_root

Image description

  • Include statement sẽ thực thi code php trong file nếu có, sau đó return result

Từ những dữ kiện trên ta có thể upload file bất kì nhưng có nội dung là đoạn code php lên server sau đó lợi dụng việc load game để thay đổi biến $game kết hợp với path traversal để thực thi file vừa upload do include statement thực hiện

  • Upload file bất kì

Image description

  • Sử dụng path traversal để gọi tới file vừa upload

Image description

Top comments (0)