A comprehensive, rule-based system hardening tool that implements CIS Benchmarks and security best practices across Windows and Linux platforms.
- Automatic OS detection: Windows, Linux, and macOS support
- Platform-specific executors: Optimized for each operating system
- Extensible architecture: Easy to add new platforms and rules
- YAML-based rule system: Human-readable configuration format
- Windows: CIS Microsoft Windows Benchmarks
- Account Policies (Password & Lockout)
- Registry-based security settings
- Service configurations
- Linux: CIS Linux Benchmarks
- Kernel module restrictions
- File system security
- System service hardening
- Automated compliance checking: Run checks against all rules
- One-click remediation: Apply security fixes automatically
- Granular control: Select specific rules or categories
- Multiple formats:
- Console output with rich formatting
- JSON for programmatic processing
- HTML with responsive design
- CSV for data analysis
- Markdown for documentation
- Detailed metrics:
- Compliance rate calculation
- Pass/fail status per rule
- Error tracking and reporting
- Before/after comparisons
- Automatic backups: Created before any changes
- Complete rollback: Restore previous configurations
- Backup management: Track and manage historical backups
- Safe remediation: Always reversible
- Intuitive commands:
check,apply,report,rollback,list-rules - Rich terminal UI: Beautiful output with colors and tables
- Flexible filtering: By platform, level, tags, or specific IDs
- Logging support: Debug and audit trail capabilities
- Scriptable: Perfect for automation and CI/CD
- Windows 10 (1809+) or Windows 11
- PowerShell 5.1 or later
- Administrator privileges
- Ubuntu 20.04+, Debian 10+, RHEL/CentOS 8+, Fedora 36+
- Bash 4.0 or later
- Root or sudo access
- Python 3.8 or higher
- pip for package management
- Virtual environment (recommended)
# Clone the repository
git clone https://github.com/Aswinr24/syshardn.git
cd syshardn
# Run the setup script
python setup.py
# Or manually:
pip install -r requirements.txt
pip install -e .# Install with development dependencies
python setup.py --dev
# Or manually:
pip install -r requirements.txt
pip install -r requirements-dev.txt
pip install -e .# Check version
syshardn --version
# View help
syshardn --help
# List available rules
syshardn list-rules# Check all rules for your platform
syshardn check
# Check specific severity level
syshardn check --level L1
# Check specific rules
syshardn check --rules WIN-001,WIN-002
# Export results as JSON
syshardn check --format json --output results.json# Apply all L1 rules (with confirmation)
syshardn apply --level moderate
# Apply specific rules without confirmation
syshardn apply --rules LNX-001,LNX-002 --yes
# Dry-run mode (show what would be done)
syshardn apply --dry-run# Generate console report
syshardn report
# Generate HTML report
syshardn report --format html --output report.html
# Generate JSON report
syshardn report --format json --output report.json
# Generate CSV report for analysis
syshardn report --format csv --output report.csv# List available backups
syshardn rollback --list
# Rollback to specific backup
syshardn rollback --backup 20250102_143000
# Rollback specific rules
syshardn rollback --rules WIN-001,WIN-002# List all rules
syshardn list-rules
# List rules for specific platform
syshardn list-rules --os-filter windows
# List rules by category
syshardn list-rules --category Filesystem
# List detailed view
syshardn list-rules --detailed# Enable debug logging
syshardn check --log-level DEBUG
# Log to file
syshardn check --log-file /var/log/syshardn.log
# Verbose output
syshardn check -v
# Apply with confirmation prompts
syshardn apply --level moderate --interactive
# Schedule periodic checks
syshardn schedule --level basic --cron "0 2 * * *"
# Export results in JSON
syshardn check --output results.json --format jsonRules are defined in YAML format with a consistent schema across platforms. See rules/SCHEMA.md for complete documentation.
metadata:
benchmark: CIS Benchmark Name
os: windows or linux
versions: [supported versions]
rule:
id: OS-NNN
category: Security Category
description: What this rule enforces
severity: low | medium | high | critical
hardening_levels:
basic: {enabled: true, value: 12}
moderate: {enabled: true, value: 18}
strict: {enabled: true, value: 24}
check:
command: |
# Command to check compliance
expected: {type: number, operator: ">=", value: "{{hardening_value}}"}
remediation:
command: |
# Command to apply hardening
verify_after: true
rollback:
enabled: true
backup_command: |
# Backup current state
restore_command: |
# Restore from backup- β CIS Benchmarks (Windows 10/11, Linux distributions)
- β NIST SP 800-53 (National Institute of Standards and Technology)
- β ISO/IEC 27001 (Information Security Management)
- Account Policies (Password & Lockout)
- Local Policies (Audit, User Rights, Security Options)
- Event Log Settings
- System Services
- Registry Settings
- Windows Firewall
- Advanced Audit Policies
- Application Security
- Data Protection
- Filesystem Configuration
- Services Management
- Network Configuration
- Logging and Auditing
- Access Control
- User Accounts and Environment
- System Maintenance
- Software Updates
- Detection: Automatically detect OS, version, and distribution
- Analysis: Load applicable rules for the target system
- Assessment: Check current compliance status
- Backup: Create backup of current configuration
- Remediation: Apply hardening rules based on selected level
- Verification: Verify each change was applied successfully
- Reporting: Generate comprehensive compliance report
- Logging: Record all actions to audit trail
Tests live under the tests/ directory. Current test files in this repository are:
tests/test_rule_loader.py# Unit tests for rule loading and validationtests/test_report_generator.py# Unit tests for report generation (JSON/CSV/HTML/MD)tests/test_integration.py# End-to-end integration tests
The project uses pytest and is configured by pytest.ini. The CI runs tests with coverage using:
python -m pytest tests/ -v --cov=src/syshardn --cov-report=term-missingQuick local commands you can run now:
# Run the full test suite
pytest
# Run a single test file
pytest tests/test_rule_loader.py -q
pytest tests/test_report_generator.py -q
pytest tests/test_integration.py -q
# Run a single test case inside a file
pytest tests/test_rule_loader.py::test_load_single_rule -qDeveloper notes:
- Install test/dev dependencies before running tests:
pip install -r requirements-dev.txtThis tool makes significant changes to system configuration. Always:
- Test in non-production environments first
- Review rules before applying
- Maintain backups
- Understand the impact of each rule
- Have a rollback plan
The authors are not responsible for any system issues or data loss resulting from the use of this tool.