ExeCheck - Multi-Platform Executable Security Checker
A comprehensive security checker for Linux (ELF), Windows (PE), and macOS (Mach-O) executables, written in Rust. ExeCheck can be used both as a command-line tool and as a Rust library for integration into other projects.
Quick Start
As a Library
[]
= "0.2.0"
use ;
use PathBuf;
let result = analyze_file?;
println!;
As a CLI Tool
# Install from source
# Analyze a single file
# Scan directory with JSON output
Features
Supported Platforms
- Linux ELF: Complete security analysis
- Windows PE: Comprehensive Windows-specific security checks
- macOS Mach-O: Basic security analysis (some features simplified)
Security Checks
Linux ELF
- Stack Canary: Detects stack smashing protection (
__stack_chk_fail) - NX/DEP: Non-executable stack protection
- PIE: Position Independent Executable
- RELRO: Relocation Read-Only (Partial/Full)
- RPATH/RUNPATH: Runtime library path analysis
- Symbol Stripping: Checks if symbols are stripped
- FORTIFY: Source fortification analysis (fortified/fortifiable functions)
- CET: Control-flow Enforcement Technology (IBT/SHSTK)
Windows PE
- Dynamic Base: ASLR support (
/DYNAMICBASE) - High Entropy VA: 64-bit ASLR (
/HIGHENTROPYVA) - Force Integrity: Code integrity (
/INTEGRITYCHECK) - Isolation: Process isolation (
/ALLOWISOLATION) - NX/DEP: Data Execution Prevention (
/NXCOMPAT) - SEH: Structured Exception Handling
- CFG: Control Flow Guard
- RFG: Return Flow Guard
- SafeSEH: Safe Structured Exception Handling
- GS: Stack Cookie (
/GS) - Authenticode: Code signing verification
- .NET: Managed code detection
macOS Mach-O
- PIE: Position Independent Executable
- Stack Canary: Stack protection detection
- NX: Non-executable memory protection
- ARC: Automatic Reference Counting
- Encryption: Binary encryption analysis
- Code Signature: Code signing verification
- Fat Binaries: Complete support for universal binaries with per-architecture analysis
Output Formats
- Human-readable (default): Colored, formatted output with security status indicators
- JSON: Machine-readable JSON format
- YAML: YAML format for configuration files
- XML: Structured XML output
- CSV: Comma-separated values for spreadsheet analysis
Scanning Options
- Single file analysis: Analyze individual executables
- Directory scanning: Scan directories with optional recursion
- Issues-only mode: Show only files with security issues
- Strict mode: Exit with non-zero code if security issues found
Installation
Library Usage
Add to your Cargo.toml:
[]
= "0.2.0"
Command Line Tool
Install from Crates.io
Build from Source
The compiled binary will be available at target/release/execheck.
Prerequisites
- Rust toolchain (1.70+ recommended)
- Cargo package manager
Usage
Library Usage
See the Library Usage Guide for comprehensive documentation and examples.
use ;
use PathBuf;
// Analyze a single file
let result = analyze_file?;
println!;
// Scan a directory
let options = ScanOptions ;
let report = scan_directory?;
println!;
Command Line Usage
Basic Usage
# Analyze a single binary
# Analyze multiple paths
# Analyze with JSON output
# Recursive directory scan
# Multiple directories recursive scan
# Show only files with security issues
# Save output to file
# Strict mode (exit code 1 if issues found)
Advanced Filtering Options
# Filter only Windows executables (.exe files)
# Filter only Windows DLLs (.dll files)
# Filter both .exe and .dll files
# Custom file extensions
# Stay within single filesystem (Unix only)
# Combine filters with other options
Command Line Options
USAGE:
execheck [OPTIONS] <PATHS>...
ARGUMENTS:
<PATHS>... Path(s) to binary or directory to analyze
OPTIONS:
-r, --recursive Recursive directory scanning
-o, --output <OUTPUT> Output format [default: human]
[possible values: human, json, yaml, xml, csv]
-f, --output-file <OUTPUT_FILE> Output file (stdout if not specified)
--strict Exit non-zero if any security feature is missing
--issues-only Show only files with security issues
--filter <FILTER> File type filter [default: all]
[possible values: all, exe, dll, exe-dll, custom]
--extensions <EXTENSIONS> Custom file extensions (comma-separated)
-x, --one-filesystem Stay within single filesystem (Unix only)
-h, --help Print help
-V, --version Print version
Example Output
Human-Readable Format
Security Check Report
====================
Summary:
Total files: 1
Secure files: 1
Insecure files: 0
Unsupported files: 0
File: /bin/ls
Type: ELF
Status: ✓ Secure
Security Checks:
RELRO : ✓ Full RELRO
Stack Canary : ✓ Canary Found
NX : ✓ NX enabled
PIE : ✓ PIE Enabled
RPATH : ✓ No RPATH
RUNPATH : ✓ No RUNPATH
Symbols : ✓ No Symbols
FORTIFY : Yes
Fortified : 10
Fortifiable : 3
CET : Full CET (IBT+SHSTK)
Fat Binary Format (macOS Universal Binary)
File: /Applications/App.app/Contents/MacOS/App
Type: Mach-O Fat (2 archs)
Status: ⚠ Mixed
Security Checks:
X86_64 Architecture:
PIE : ✓ PIE Enabled
Stack Canary : ✓ Canary Found
NX : ✓ NX enabled
ARM64 Architecture:
PIE : ✓ PIE Enabled
Stack Canary : ✗ No Canary Found
NX : ✓ NX enabled
JSON Format
Examples
Library Examples
The examples/ directory contains comprehensive examples:
# Basic file analysis
# Directory scanning
# JSON output for automation
# Custom filtering and analysis
Integration Examples
CI/CD Integration
#!/bin/bash
# Check all binaries in build output
if [; then
fi
Security Monitoring
# Weekly security scan
Architecture
ExeCheck is built with a modular architecture supporting both library and CLI usage:
src/lib.rs: Public library API and core functionalitysrc/main.rs: CLI interface and argument parsingsrc/checks.rs: Platform-specific security analysissrc/output.rs: Multiple output format supportexamples/: Library usage examplesdocs/: Comprehensive documentation
Platform Detection
Automatically detects executable format based on magic bytes:
- ELF:
0x7F454C46(\x7fELF) - PE:
0x4D5A(MZ) - Mach-O: Various magic numbers for different architectures
Limitations
Current Limitations
- Mach-O symbol analysis: Simplified implementation (symbol string table lookup not fully implemented)
- PE advanced features: Some Windows-specific checks are placeholder implementations
- Performance: Large directory scans may be slow on systems with many files
Future Enhancements
- Complete Mach-O symbol table analysis
- Advanced PE load configuration parsing
- Parallel processing for directory scans
- Additional security feature detection
- Plugin architecture for custom checks
Documentation
- Library Usage Guide - Comprehensive guide for using ExeCheck as a library
- Examples - Working examples for common use cases
- API Documentation - Full API reference
Contributing
Contributions are welcome! Areas of particular interest:
- Enhanced Mach-O analysis
- Additional Windows PE checks
- Performance improvements
- Test coverage expansion
- Documentation improvements
- Library API enhancements