[Hack the box] #3 Cicada
Sea를 풀 때 정말 정말 짜증났다
Medium난이도를 풀고 싶었으나......Useer Rated Difficulty가 좀 낮아보이길래..
Cicada를 도전해본다.
뜻을 검색해보니 매미인 것 같다.
그림에도 매미가 있넹

Join machine을 눌러 ip가 나왔다. 드가자

침투 테스트의 기본 tmux을 열어준다.

포트가 열린게 심상치 않다. 구글에 검색해보니 AD 모듈인 것 같다. OS는 Windows 이고...또 ldap를 사용하고...어떻게 해야하지?

일단 어디부터 접근해야할지 모르겠어서 -sV 옵션을 주고 서버 정보를 수집했다.

88번 포트는 Kerberos가 사용하는 포트인 것 같다.
https://0xmh.tistory.com/24
이 링크를 통해 알아봤는데, Kerberos에는 Kerberoasting이라는 걸 시도해볼 수 있는 것 같다. 근데 이건 포스트 익스플로잇 공격이라 계정 정보를 한 개 알고 있다는 가정 하에 이용할 수 있어 처음 시도해볼만한 건 아닌 것 같다.
https://blog.sunggwanchoi.com/kor-keobeoroseuting-kerberoasting/
LDAP
ldapsearch를 진행했는데 결과가 자꾸 안 떴다. 뭐가 문제인 걸까?
이건 ladpsearch를 이용한 널 세션 가능 여부 체크라고 하는데 실패.

ladp 계정 브루트포스도 실패

ladp 관련 nmap 스크립트도 실패

타쿠대디분 블로그에서 본 nslookup을 입력해봐도 time out 에러가 난다.

아래 명령을 통해 널 세션 바인딩이 가능한지 알아보자.
인터넷에서 쉽게 검색되는 구문들과 조금 변경되었다. -H 옵션을 줘야 하고 ldap:// 아래로 주소를 줘야 에러가 나지 않는다. ip만 기입했을 경우 Coud not parse LDAP URI 어쩌구 에러가 난다.
ldapsearch -H ldap://10.10.11.35 -x -s base namingcontexts


SMB 연결 시도
??? 아니 다시 포트스캔을 해보니 445가 open 되어 있었다. 뭐지 ㅡㅡ

이게 막혀있는 줄 알고 ldapsearch로만 어떻게든 해보려고 했었던건데
이제 smbclinet를 한번 해볼 수 있을 것 같다.
아래 명령어를 통해 여러 가지 share가 확인이 된다.
smbclient -N -L \\10.10.11.35

여러 가지 share중 HR 이라는 share에 kali에 비밀번호 없이 enter를 쳐도 연결되었다.
다른 share에도 연결은 가능했으나 ls 명령어 입력 시 access denied가 출력되는 것이 대부분이었다.

get 명령어를 통해 공유 폴더에서 저 txt 파일을 받아주자.

잘 다운받아졌다.

Cicada 코퍼레이션에서 신입사원에서 보내는 안내 메시지인 것 같다.
내용에 default password가 존재한다.
Cicada$M6Corpb*@Lp#nZp!8
그런데 이걸 어떻게 써야 하지?

https://seahippocampus.tistory.com/236
호스트 기반 모의 해킹 - SMB 취약점 진단
seahippocampus.tistory.com
전에 SMB 취약점 진단 공부했을 때에 배웠던 걸 써봐야겠다.
그다음으로 해볼만한 enum4linux를 써볼 것이다.
enum4linux -a "IP 주소"
-a 옵션을 주면 정보를 싹 다 알아봐준다.

아까 해봤던 것처럼 Null session도 유효하다...그런덴 이거 외엔 소득이 없었다.

smbcacls를 실행하니 뭔가가 떴다. david...sarah등 사람 이름이 보인다.

msfconsole로 smb_version 체크도 해보았다.


소용이 없었다...
netexec
SMB 침투 시에 guest나 anonymous로 접근할 수 있는 지를 파악하는 것도 중요하다고 한다.
어라 가능한 것 같다 전에 본 HR에서 READ가 가능한 걸 리스팅해준다.

spider_plus 모듈도 사용이 가능한 것 같다.

RID 사이클링

아래 명령어를 입력하여 username.txt를 생성해준다.
netexec smb 10.10.11.35 -u guest -p '' --rid-brute 1000 | awk '{print $6}'| cut -d "\\" -f 2 >> username.txt
cat으로 읽어보자

어라 근데 위쪽 결과엔 david.orelious나 emily 같은 이름이 있는데

username.txt에선 거기까지 저장이 되지 않았다 뭐지?

구글에 getnpusers.py를 검색 후 github에서 코드를 다운받아주자.


아까 HR share에서 획득했던 초기 비밀번호를 가진 계정인 michael.wrightson을 찾았습니다 ㅋㅋㅋ

enum4linux의 Users 결과에서 david.orelious의 분실 시 비밀번호를 획득할 수 있었다.
aRt$Lp#7t*VQ!3

획득한 david.orelious의 계정 정보를 통해 다시 한번 enum4linux를 해줍시다

david.orelious의 권한을 보니 guest나 michael에 비해 DEV share에서 listing이 가능하군요

아래 명령어로 DEV share에 접근해봅시다.
smbclient "//10.10.11.35/DEV" -U 'david.orelious'

get으로 Backup_script.ps1을 다운받은 후 읽어보니 emily.oscars의 계정 정보를 획득했습니다
Q!3@Lp#M6b*7t*Vt


emily는 ADMIN$ share에 접근이 가능한 것 같네요

evil-winrm이라는 툴을 이용해 shell에 접속해줍니다.



user flag 해결!

ROOT 플래그
진짜 AD 모듈 처음해봐서 유저도 사람들의 흔적을 따라 따라 풀었는데 아직 root가 남았다니...
emily.oscars.CICADA 디렉토리에서 나갔더니 Administrator 디렉토리가 있었다.

그러고 Desktop 폴더에 root.txt 가 있었으나 역시나 cat으로는 Permission denied가 떴다.

whoami /priv 명령어를 통해 권한을 살펴보면,
SeBackupPrivilege권한이 있다. 상당히 위험한 권한이라고 한다.

Temp 디렉토리로 이동해보면 sam 과 system 파일이 있습니다.

이걸 해야 한다는데 왜 난 잘 안 됐지?

reg save를 입력하고 가만히 있으면 되는 건지 안되는건지 알 수가 없다 ㅋㅋ

일단 download 해보기로함.

sam도 다운이 잘되었고 download system도 잘되는 것 같다.

ls로 확인해보니 잘 다운로드 되었네요

아래 명령어를 통해 NT 해쉬값을 획득해봅시다. Administrator 항목에 뒤쪽 값이 NT 해쉬입니다.
impacket-secretsdump -sam sam -system system LOCAL

NT 해시를 의미하는 -H 플래그를 이용해서 Administrator 계정으로 로그인을 해줍시다.
로그인 성공!!

이제 root.txt를 읽어서 root 플래그를 획득했습니다

휴,,,,,,역대급 난감했던 Windows 서버 모의침투였던 것 같습니다
이게 어떻게 easy 냐고...
그래도 많이 배울 수 있어 만족합니다.

AD공략:https://takudaddy.tistory.com/557
Hack the box 모의해킹 침투 Sizzle : https://0xmh.tistory.com/24
Hackthebox 다른 박스 writeup : https://arth0s.medium.com/hackthebox-rebound-write-up-insane-ab8eb3679bff
Hackthebox cicada writeup : https://codingwoo.tistory.com/25