📍 Languages: English | Español
TruchaSign is an advanced tool for security research and authorized testing that clones Authenticode signature blocks from signed PE (Portable Executable) files and injects them into target binaries. It rewrites the IMAGE_DIRECTORY_ENTRY_SECURITY directory and recalculates the CheckSum in the Optional Header.
⚠️ Important: The resulting PE appears signed at the presentation level (Windows Explorer, tools that only read the directory). However, the cryptographic signature chain is NOT valid —truchasignl verify /paandWinVerifyTrustwill reject the binary because the PE digest no longer matches the original CA signature.
- ⚡ Fast & Efficient — Written in Rust with optimized compilation
- 🔧 Dual PE Support — Works with PE32 and PE32+ architectures
- 📊 Safe Bounds Checking — Validates all offsets and sizes
- 🎯 Precise Checksum Calculation — Uses Microsoft's standard IMAGHELP algorithm
- 🛡️ Proper Alignment — Maintains 8-byte alignment requirements for Authenticode
- Rust 1.70+ (x86_64-pc-windows-msvc target)
- Windows 10/11
# Install Rust if needed
rustup target add x86_64-pc-windows-msvc
# Clone and build
git clone https://github.com/merovingioops/TruchaSign.git
cd TruchaSign
cargo build --releaseThe optimized binary will be available at target\release\truchasign.exe.
Alternatively, use the included PowerShell task script for easier setup:
# Initialize git repository and create initial commit
.\tasks.ps1 -Task init-repo
# Setup local development environment
.\tasks.ps1 -Task setup-local
# Build the project
.\tasks.ps1 -Task build
# Validate code formatting and quality
.\tasks.ps1 -Task validate
# Clean build artifacts
.\tasks.ps1 -Task clean
# Publish to GitHub
.\tasks.ps1 -Task publishOr simply run .\tasks.ps1 to see all available options.
# Basic syntax
.\target\release\truchasign.exe <signed_source.exe> <target.exe> <output.exe>
# Example: Clone Windows cmd.exe signature to payload
.\target\release\truchasign.exe C:\Windows\System32\cmd.exe .\payload.exe .\payload_signed.exe[+] signature source: offset=0x12000 size=8456 bytes
[+] injected va=0x4A800 size=8456 checksum=0x0004F3A1
[!] ready -> .\payload_signed.exe
- Parse DOS Header — Reads
e_lfanewat offset0x3Cand validatesMZ/PE\0\0 - Detect Architecture — Identifies PE32 (
0x10B) or PE32+ (0x20B) format - Extract Signature — Locates Security Data Directory (index 4) and extracts WIN_CERTIFICATE blob
- Prepare Target — Pads PE to 8-byte boundary (Authenticode requirement)
- Inject Signature — Appends signature blob to target PE
- Update Headers — Modifies Security Directory
VirtualAddressandSize - Recalculate Checksum — Applies Microsoft IMAGHELP algorithm (16-bit sum with carry-fold + file size)
pe_offsets— Resolves PE32/PE32+ offsets withMZ/PEvalidationextract_signature— Validates and extracts signature blob with bounds checkingcalculate_checksum— Implements Microsoft's standard checksum algorithminject_signature— Handles alignment, injection, and header patching
Verify the injection results:
# View cloned certificate (expected to show)
sigcheck.exe -i .\payload_signed.exe
# Verify cryptographic chain fails (expected behavior)
Get-AuthenticodeSignature .\payload_signed.exe
truchasignl verify /pa .\payload_signed.exe- ❌ PE/PE32+ only (no other container formats)
- ❌ Cannot reconstruct embedded certificates or catalogs
- ❌ Cryptographic validation via
truchasignlorGet-AuthenticodeSignaturewill fail (by design) - ❌ Does not handle corrupted PE structures
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This tool is designed for:
- 🔬 Authorized security research
- 🎯 Red team exercises (with explicit scope)
- 🏫 CTF (Capture The Flag) competitions
- 🧪 Isolated lab environments
Unauthorized use against systems is illegal and violates computer fraud laws. The author assumes no responsibility for misuse or damages resulting from unauthorized access.
This project is licensed under MIT OR Apache-2.0 — dual licensed for maximum compatibility and flexibility.
For a sensitive security research tool, we've chosen a dual license approach:
- MIT License: Simple, permissive, and widely trusted in the open-source community
- Apache-2.0: Includes explicit patent grants and detailed legal protections
- Both: Allow maximum flexibility while maintaining open-source principles
See the LICENSE file for full details.
- 🐛 Report Issues: GitHub Issues
- 💬 Discussions: GitHub Discussions
TruchaSign es una herramienta avanzada para investigación de seguridad y pruebas autorizadas que clona bloques de firma Authenticode desde archivos PE (Portable Executable) firmados e los inyecta en binarios objetivo. Reescribe el directorio IMAGE_DIRECTORY_ENTRY_SECURITY y recalcula el CheckSum en el Optional Header.
⚠️ Importante: El PE resultante aparenta estar firmado a nivel de presentación (Explorador de Windows, herramientas que solo leen el directorio). Sin embargo, la cadena de firma criptográfica NO es válida —truchasignl verify /payWinVerifyTrustrechazarán el binario porque el digest del PE ya no coincide con la firma original de la CA.
- ⚡ Rápido y Eficiente — Escrito en Rust con compilación optimizada
- 🔧 Soporte Dual PE — Compatible con arquitecturas PE32 y PE32+
- 📊 Validación Segura — Verifica todos los offsets y tamaños
- 🎯 Cálculo Preciso de Checksum — Utiliza el algoritmo IMAGHELP estándar de Microsoft
- 🛡️ Alineación Correcta — Mantiene requisitos de alineación de 8 bytes para Authenticode
- Rust 1.70+ (destino x86_64-pc-windows-msvc)
- Windows 10/11
# Instalar Rust si es necesario
rustup target add x86_64-pc-windows-msvc
# Clonar y compilar
git clone https://github.com/merovingioops/TruchaSign.git
cd TruchaSign
cargo build --releaseEl binario optimizado estará disponible en target\release\truchasign.exe.
Alternativamente, usa el script de tareas PowerShell incluido para una configuración más fácil:
# Inicializar repositorio git y crear commit inicial
.\tasks.ps1 -Task init-repo
# Configurar entorno de desarrollo local
.\tasks.ps1 -Task setup-local
# Compilar el proyecto
.\tasks.ps1 -Task build
# Validar formato y calidad del código
.\tasks.ps1 -Task validate
# Limpiar artefactos de compilación
.\tasks.ps1 -Task clean
# Publicar en GitHub
.\tasks.ps1 -Task publishO simplemente ejecuta .\tasks.ps1 para ver todas las opciones disponibles.
# Sintaxis básica
.\target\release\truchasign.exe <origen_firmado.exe> <objetivo.exe> <salida.exe>
# Ejemplo: Clonar firma de cmd.exe a payload
.\target\release\truchasign.exe C:\Windows\System32\cmd.exe .\payload.exe .\payload_signed.exe[+] firma origen: offset=0x12000 size=8456 bytes
[+] inyectado va=0x4A800 size=8456 checksum=0x0004F3A1
[!] listo -> .\payload_signed.exe
- Análisis DOS Header — Lee
e_lfanewen offset0x3Cy validaMZ/PE\0\0 - Detectar Arquitectura — Identifica formato PE32 (
0x10B) o PE32+ (0x20B) - Extraer Firma — Localiza Security Data Directory (índice 4) y extrae blob WIN_CERTIFICATE
- Preparar Objetivo — Rellena PE a límite de 8 bytes (requisito Authenticode)
- Inyectar Firma — Añade blob de firma al PE objetivo
- Actualizar Headers — Modifica
VirtualAddressySizedel directorio de seguridad - Recalcular Checksum — Aplica algoritmo IMAGHELP de Microsoft (suma 16-bit con carry-fold + tamaño)
pe_offsets— Resuelve offsets PE32/PE32+ con validaciónMZ/PEextract_signature— Valida y extrae blob de firma con bounds checkingcalculate_checksum— Implementa algoritmo de checksum estándar de Microsoftinject_signature— Maneja alineación, inyección y parcheo de headers
Verifica los resultados de la inyección:
# Ver certificado clonado (se espera que muestre)
sigcheck.exe -i .\payload_signed.exe
# Verificar que la cadena criptográfica falla (comportamiento esperado)
Get-AuthenticodeSignature .\payload_signed.exe
truchasignl verify /pa .\payload_signed.exe- ❌ Solo PE/PE32+ (no soporta otros formatos contenedores)
- ❌ No reconstruye certificados embebidos ni catálogos
- ❌ Validación criptográfica con
truchasignloGet-AuthenticodeSignaturefallará (por diseño) - ❌ No maneja estructuras PE corruptas
¡Las contribuciones son bienvenidas! Por favor:
- Fork el repositorio
- Crea una rama de característica (
git checkout -b feature/caracteristica-asombrosa) - Commit tus cambios (
git commit -m 'Agregar característica asombrosa') - Push a la rama (
git push origin feature/caracteristica-asombrosa) - Abre un Pull Request
Esta herramienta está diseñada para:
- 🔬 Investigación de seguridad autorizada
- 🎯 Ejercicios de red team (con scope explícito)
- 🏫 Competiciones CTF (Capture The Flag)
- 🧪 Entornos de laboratorio aislados
El uso no autorizado contra sistemas es ilegal y viola leyes de fraude informático. El autor no se responsabiliza del mal uso o daños resultantes del acceso no autorizado.
Este proyecto tiene licencia MIT OR Apache-2.0 — licencia dual para máxima compatibilidad y flexibilidad.
Para una herramienta sensible de investigación de seguridad, hemos elegido un enfoque de licencia dual:
- Licencia MIT: Simple, permisiva y ampliamente confiada en la comunidad de código abierto
- Apache-2.0: Incluye garantías explícitas de patentes y protecciones legales detalladas
- Ambas: Permiten máxima flexibilidad manteniendo principios de código abierto
Ver el archivo LICENSE para todos los detalles.
- 🐛 Reportar Problemas: GitHub Issues
- 💬 Discusiones: GitHub Discussions