Convert Figma logo to code with AI

Ne0nd0g logomerlin

Merlin is a cross-platform post-exploitation HTTP/2 Command & Control server and agent written in golang.

5,064
803
5,064
17

Top Related Projects

Metasploit Framework

4,228

Empire is a post-exploitation and adversary emulation framework that is used to aid Red Teams and Penetration Testers.

Covenant is a collaborative .NET C2 framework for red teamers.

A swiss army knife for pentesting networks

1,801

A proxy aware C2 framework used to aid red teamers with post-exploitation and lateral movement.

Quick Overview

Merlin is an open-source command and control (C2) post-exploitation framework. It is designed to be a flexible and customizable platform for red team operations, penetration testing, and adversary emulation. Merlin utilizes HTTP/2 for communication and is written in Go.

Pros

  • Cross-platform support (Windows, Linux, macOS)
  • Utilizes HTTP/2 for stealthy communication
  • Highly customizable and extensible
  • Active development and community support

Cons

  • Requires Go knowledge for advanced customization
  • Limited built-in modules compared to some other C2 frameworks
  • Potential for misuse by malicious actors
  • Steeper learning curve for beginners in C2 operations

Getting Started

  1. Clone the repository:

    git clone https://github.com/Ne0nd0g/merlin.git
    
  2. Build the server:

    cd merlin/cmd/merlinserver
    go build
    
  3. Generate a self-signed TLS certificate:

    openssl req -x509 -newkey rsa:4096 -keyout server.key -out server.crt -days 365 -nodes
    
  4. Start the server:

    ./merlinserver -i 0.0.0.0 -p 443 -cert server.crt -key server.key
    
  5. Build the agent:

    cd ../../cmd/merlinagent
    GOOS=windows GOARCH=amd64 go build -ldflags "-X main.url=https://example.com:443" -o merlin.exe
    
  6. Deploy the agent on the target system and execute it to establish a connection with the server.

Competitor Comparisons

Metasploit Framework

Pros of Metasploit-Framework

  • Extensive library of exploits and modules
  • Large community support and regular updates
  • Well-documented and widely used in the industry

Cons of Metasploit-Framework

  • Larger footprint and more complex setup
  • More likely to be detected by antivirus software
  • Steeper learning curve for beginners

Code Comparison

Merlin (Go):

func (a *Agent) executeCommand(cmd string) ([]byte, error) {
    command := exec.Command("cmd.exe", "/C", cmd)
    return command.CombinedOutput()
}

Metasploit-Framework (Ruby):

def cmd_execute(cmd, opts = {})
  Rex::Compat.execute_command(cmd, opts)
end

Summary

Metasploit-Framework is a comprehensive penetration testing tool with a vast array of exploits and modules, backed by a large community. However, it has a larger footprint and may be more easily detected. Merlin, on the other hand, is a lightweight post-exploitation agent focused on stealth and flexibility, written in Go. The code comparison shows the difference in language and approach to command execution between the two projects.

4,228

Empire is a post-exploitation and adversary emulation framework that is used to aid Red Teams and Penetration Testers.

Pros of Empire

  • More extensive feature set and modules for post-exploitation
  • Larger community and longer development history
  • Better documentation and support resources

Cons of Empire

  • Larger codebase and more complex setup
  • Higher likelihood of detection due to popularity
  • Less focus on evasion techniques

Code Comparison

Empire (PowerShell-based agent):

$wc = New-Object System.Net.WebClient
$wc.Headers.Add("User-Agent", "Mozilla/5.0")
$data = $wc.DownloadData("http://empire.server/get_tasking")

Merlin (Go-based agent):

client := &http.Client{}
req, _ := http.NewRequest("GET", "https://merlin.server/", nil)
req.Header.Set("User-Agent", "Mozilla/5.0")
resp, _ := client.Do(req)

Both projects are open-source post-exploitation frameworks, but they differ in their approach and implementation. Empire is more established and feature-rich, while Merlin focuses on being lightweight and evasive. Empire uses PowerShell extensively, whereas Merlin is written in Go. Empire offers a wider range of modules and capabilities, but Merlin's simplicity and cross-platform nature make it attractive for specific scenarios. The choice between them depends on the specific requirements of the engagement and the target environment.

Covenant is a collaborative .NET C2 framework for red teamers.

Pros of Covenant

  • Built-in GUI for easier management and visualization
  • Supports multiple users and collaborative operations
  • Extensive built-in modules and post-exploitation capabilities

Cons of Covenant

  • Larger footprint and potentially easier to detect
  • Less flexible in terms of custom communication protocols
  • May require more setup and configuration

Code Comparison

Merlin (Go):

func (a *Agent) executeCommand(cmd string) ([]byte, error) {
    command := exec.Command("cmd.exe", "/c", cmd)
    return command.CombinedOutput()
}

Covenant (C#):

public static string ExecuteCommand(string command)
{
    Process proc = new Process();
    proc.StartInfo.FileName = "cmd.exe";
    proc.StartInfo.Arguments = "/c " + command;
    proc.StartInfo.UseShellExecute = false;
    proc.StartInfo.RedirectStandardOutput = true;
    proc.Start();
    return proc.StandardOutput.ReadToEnd();
}

Both projects implement command execution, but Covenant's approach is more verbose and provides additional control over the process.

Merlin focuses on simplicity and stealth, using Go for cross-platform compatibility and easier compilation. Covenant offers a more feature-rich environment with its .NET-based architecture, making it suitable for Windows-centric operations and teams requiring collaborative features.

A swiss army knife for pentesting networks

Pros of CrackMapExec

  • More focused on network enumeration and lateral movement
  • Extensive built-in modules for various attack techniques
  • Active development with frequent updates and community contributions

Cons of CrackMapExec

  • Less stealthy compared to Merlin's HTTP/2 and DNS communication methods
  • Primarily designed for Windows environments, while Merlin is more versatile
  • Requires more setup and dependencies compared to Merlin's single binary

Code Comparison

Merlin (server-side listener setup):

// Start HTTP/2 Listener
srv := &http.Server{
    Addr:    ":" + strconv.Itoa(port),
    Handler: router,
}
err := srv.ListenAndServeTLS(certPath, keyPath)

CrackMapExec (basic usage):

from crackmapexec import CME

cme = CME()
cme.run('smb', '192.168.1.0/24', 'Administrator', 'password123')

Both tools are powerful in their respective domains. Merlin excels in covert operations and cross-platform support, while CrackMapExec shines in Windows-centric environments and offers a wide range of attack modules. The choice between them depends on the specific requirements of the penetration testing or red team engagement.

1,801

A proxy aware C2 framework used to aid red teamers with post-exploitation and lateral movement.

Pros of PoshC2

  • Written in PowerShell, making it highly compatible with Windows environments
  • Extensive built-in modules for various post-exploitation tasks
  • Strong focus on operational security with features like AMSI bypass

Cons of PoshC2

  • Limited cross-platform support compared to Merlin's Go-based architecture
  • Steeper learning curve for users not familiar with PowerShell
  • Less frequent updates and potentially slower development cycle

Code Comparison

PoshC2 (PowerShell):

$Proxy = [System.Net.WebRequest]::GetSystemWebProxy()
$Proxy.Credentials = [System.Net.CredentialCache]::DefaultCredentials
$wc = New-Object System.Net.WebClient
$wc.Proxy = $Proxy

Merlin (Go):

client := &http.Client{
    Transport: &http.Transport{
        Proxy: http.ProxyFromEnvironment,
    },
}

Both examples show how each project handles proxy settings, demonstrating the language differences and approach to network communication. PoshC2 uses PowerShell's native WebClient, while Merlin leverages Go's http package for more cross-platform compatibility.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

CodeQL GoReportCard License: GPL v3 Release Downloads Twitter Follow

Merlin

Merlin Logo

Merlin is a cross-platform post-exploitation Command & Control server and agent written in Go.

Highlighted features:

  • merlin-cli command line interface over gRPC to connect to the Merlin Server facilitating multi-user support
  • Supported Agent C2 Protocols: http/1.1 clear-text, http/1.1 over TLS, HTTP/2, HTTP/2 clear-text (h2c), http/3 (http/2 over QUIC)
  • Peer-to-peer (P2P) communication between Agents with bind or reverse for SMB, TCP, and UDP
  • Configurable agent data encoding and encryption transforms: AES, Base64, gob, hex, JWE, RC4, and XOR
    • JWE transform use PBES2_HS512_A256KW PBES2 (RFC 2898) with HMAC SHA-512 as the PRF and AES Key Wrap (RFC 3394) using 256-bit keys for the encryption scheme
  • Configurable agent authenticators:
    • None: No authentication
    • OPAQUE: Asymmetric Password Authenticated Key Exchange (PAKE)
  • Encrypted JWT for message authentication
  • Configurable Agent message data padding to combat beaconing detections based on a fixed message size
  • Execute .NET assemblies in-process with invoke-assembly or in a sacrificial process with execute-assembly
  • Execute arbitrary Windows executables (PE) in a sacrificial process with execute-pe
  • Various shellcode execution techniques: CreateThread, CreateRemoteThread, RtlCreateUserThread, QueueUserAPC
  • Integrated Donut, sRDI, and SharpGen support
  • Dynamically change the Agent's JA3 hash
  • Mythic support
  • Documentation & Wiki

An introductory blog post can be found here: https://medium.com/@Ne0nd0g/introducing-merlin-645da3c635a

Supporting Repositories:

Quick Start

  1. Download the latest version of Merlin Server from the releases section

    The Server package contains compiled versions of the CLI and Agent for all the major operating systems in the data/bin directory

  2. Extract the files with 7zip using the x function The password is: merlin

  3. Start Merlin

  4. Start the CLI

  5. Configure a listener

  6. Deploy an agent. See Agent Execution Quick Start Guide for examples

  7. Pwn, Pivot, Profit

    mkdir /opt/merlin;cd /opt/merlin
    wget https://github.com/Ne0nd0g/merlin/releases/latest/download/merlinServer-Linux-x64.7z
    7z x merlinServer-Linux-x64.7z
    sudo ./merlinServer-Linux-x64
    ./data/bin/merlinCLI-Linux-x64
    

Mythic

Merlin can be integrated and used as an agent with the Mythic a collaborative, multi-platform, red teaming framework.

Visit the Merlin on Mythic repository in the MythicAgents organization to get started.

Misc.

Slack

Join the #merlin channel in the BloodHoundGang Slack to ask questions, troubleshoot, or provide feedback.

JetBrains

Thanks to JetBrains for kindly sponsoring Merlin by providing a Goland IDE Open Source license

JetBrains Logo GoLand Logo