Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

πŸ” RootkitDetector

An advanced Python-based rootkit detection and analysis system designed to identify kernel-level threats and suspicious system behavior on Linux and Unix-like systems.

🎯 Features

  • Rootkit Signature Detection: Pattern-based detection of known rootkit families
  • System Call Monitoring: Tracks anomalous system call patterns
  • Kernel Module Analysis: Examines loaded kernel modules for suspicious behavior
  • Process Inspection: Deep analysis of running processes and their system interactions
  • File System Integrity: Monitors for unauthorized file modifications
  • Network Connection Tracking: Detects suspicious network activities
  • Real-time Alerts: Immediate notification of detected threats
  • Detailed Reporting: Comprehensive analysis reports with remediation suggestions

πŸ“‹ Prerequisites

  • Python: 3.8 or higher
  • OS: Linux or Unix-like system with root/sudo access
  • Dependencies: See requirements.txt

πŸš€ Installation

1. Clone the Repository

git clone https://github.com/M-Inc-lab/RootkitDetector.git
cd RootkitDetector

2. Create Virtual Environment

python3 -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

3. Install Dependencies

pip install -r requirements.txt

4. Grant Necessary Permissions

# For system-level monitoring, root/sudo access is required
sudo chmod +x rootkit_detector.py

πŸ’» Usage

Basic Scan

sudo python rootkit_detector.py --scan full

Quick Scan (Fastest)

sudo python rootkit_detector.py --scan quick

Deep Analysis (Comprehensive)

sudo python rootkit_detector.py --scan deep --verbose

Monitor System in Real-time

sudo python rootkit_detector.py --monitor --interval 5

Generate Report

sudo python rootkit_detector.py --scan full --report /path/to/report.html

Check Specific Process

sudo python rootkit_detector.py --check-process <PID>

List Kernel Modules

sudo python rootkit_detector.py --modules

πŸ“‚ Project Structure

RootkitDetector/
β”œβ”€β”€ rootkit_detector.py          # Main entry point
β”œβ”€β”€ detector/
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ signature_engine.py      # Signature-based detection
β”‚   β”œβ”€β”€ syscall_monitor.py       # System call analysis
β”‚   β”œβ”€β”€ kernel_module_analyzer.py # Kernel module inspection
β”‚   β”œβ”€β”€ process_analyzer.py      # Process analysis engine
β”‚   β”œβ”€β”€ filesystem_monitor.py    # File system integrity
β”‚   └── network_analyzer.py      # Network connection tracking
β”œβ”€β”€ signatures/
β”‚   β”œβ”€β”€ rootkit_signatures.db    # Known rootkit patterns
β”‚   β”œβ”€β”€ suspicious_syscalls.db   # Suspicious system call patterns
β”‚   └── malware_signatures.db    # Malware indicators
β”œβ”€β”€ utils/
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ logger.py                # Logging utilities
β”‚   β”œβ”€β”€ config.py                # Configuration management
β”‚   β”œβ”€β”€ report_generator.py      # Report generation
β”‚   └── remediation.py           # Remediation suggestions
β”œβ”€β”€ tests/
β”‚   β”œβ”€β”€ test_detector.py
β”‚   β”œβ”€β”€ test_signatures.py
β”‚   └── test_analyzers.py
β”œβ”€β”€ requirements.txt             # Python dependencies
β”œβ”€β”€ config.yaml                  # Configuration file
└── README.md

πŸ”§ Configuration

config.yaml

detection:
  enable_signatures: true
  enable_syscall_monitoring: true
  enable_kernel_analysis: true
  enable_process_analysis: true
  enable_filesystem_monitoring: true
  enable_network_tracking: true

alerts:
  alert_level: HIGH
  send_notifications: true
  log_to_file: true
  log_path: /var/log/rootkit_detector.log

monitoring:
  interval: 300  # seconds
  sample_size: 100
  retention_days: 30

πŸ›‘οΈ Detection Methods

1. Signature-Based Detection

  • Compares system artifacts against known rootkit signatures
  • Database of known rootkit families and variants
  • Regular signature updates

2. Behavioral Analysis

  • Monitors anomalous system call patterns
  • Analyzes process creation and termination
  • Detects privilege escalation attempts

3. Kernel Module Analysis

  • Scans loaded kernel modules
  • Detects hidden modules
  • Analyzes module permissions and origins

4. Process Analysis

  • Deep inspection of process memory
  • Checks for code injection
  • Validates process integrity

5. File System Monitoring

  • Monitors critical system directories
  • Detects unauthorized modifications
  • Maintains file integrity checksums

6. Network Tracking

  • Monitors suspicious network connections
  • Detects command & control (C2) communications
  • Identifies data exfiltration attempts

πŸ“Š Detection Capabilities

Threat Type Detection Rate Method
Known Rootkits ~95% Signature + Behavior
Kernel-Level Malware ~85% Syscall + Module Analysis
Privilege Escalation ~90% Process Analysis
File Tampering ~98% Filesystem Integrity
Network Anomalies ~80% Network Analysis

πŸ§ͺ Testing

Run Test Suite

sudo python -m pytest tests/ -v

Run Specific Tests

sudo python -m pytest tests/test_detector.py -v

Generate Coverage Report

sudo python -m pytest tests/ --cov=detector --cov-report=html

πŸ“ˆ Example Output

╔════════════════════════════════════════════════════════╗
β•‘         RootkitDetector - Full System Scan             β•‘
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•

[*] Scanning system for rootkit indicators...

[+] Signature Detection: Checking against 2,543 signatures...
    βœ“ No known rootkits detected

[+] Kernel Module Analysis: Scanning 156 loaded modules...
    ⚠ WARNING: Suspicious module detected: 'netfilter_extra'
    β”œβ”€ Unsigned module
    β”œβ”€ Unusual memory location
    └─ Requires investigation

[+] System Call Monitoring: Analyzing syscall patterns...
    βœ“ Normal syscall behavior detected

[+] Process Analysis: Inspecting 324 running processes...
    ⚠ WARNING: Process 'sshd' has unusual memory maps
    └─ Possible code injection detected

[+] File System Integrity: Monitoring critical directories...
    βœ“ No unauthorized modifications

[+] Network Analysis: Checking connections...
    ⚠ WARNING: Unusual outbound connection detected
    β”œβ”€ Process: chrome (PID: 4521)
    β”œβ”€ Destination: 192.168.1.105:8080
    └─ Status: Connection established

═══════════════════════════════════════════════════════════
SUMMARY:
  Threats Found: 3 (1 High, 2 Medium, 0 Low)
  Clean: βœ“ 85%
  Suspicious: ⚠ 15%
  
Detailed report saved to: /tmp/rootkit_scan_2024-06-16.html
═══════════════════════════════════════════════════════════

⚠️ Important Notes

  • Requires Root Access: Most detection features require elevated privileges
  • System Impact: Deep scans may temporarily increase CPU/disk usage
  • False Positives: Some legitimate applications may trigger alerts
  • Regular Updates: Keep signature database updated for best detection
  • Backup First: Test in controlled environment before production use

πŸ” Security Best Practices

  1. Run Regularly: Schedule scans via cron for continuous monitoring
  2. Keep Updated: Download latest signatures weekly
  3. Isolate Findings: Quarantine suspicious processes
  4. Review Logs: Analyze reports and logs regularly
  5. Verify Changes: Manually verify remediation actions

πŸ”„ Update Signatures

sudo python rootkit_detector.py --update-signatures

🚨 Emergency Response

If a rootkit is detected:

  1. Isolate System: Disconnect from network
  2. Preserve Evidence: Copy logs and reports
  3. Generate Report: --report flag for documentation
  4. Professional Help: Contact security team
  5. Remediation: Follow suggested remediation steps

πŸ› Troubleshooting

Permission Denied

# Ensure running with sudo
sudo python rootkit_detector.py --scan full

Module Import Errors

# Reinstall dependencies
pip install -r requirements.txt --force-reinstall

High False Positives

# Adjust detection sensitivity
sudo python rootkit_detector.py --scan quick --sensitivity low

πŸ“ Logging

Logs are stored in:

  • Console Output: Real-time feedback
  • Log File: /var/log/rootkit_detector.log
  • Report File: HTML reports in current directory

🀝 Contributing

We welcome contributions! Please:

  1. Fork the repository
  2. Create a feature branch
  3. Submit a pull request
  4. Include test cases

Contribution Areas

  • Additional rootkit signatures
  • Improved detection algorithms
  • New analysis modules
  • Performance optimization
  • Documentation improvements

πŸ“„ License

This project is licensed under the MIT License - see LICENSE file for details.

πŸ’¬ Support & Contact

For issues or questions:

  • πŸ“§ Open a GitHub issue
  • πŸ”— Check Documentation
  • πŸ’» Review existing issues

βš–οΈ Legal Disclaimer

This tool is designed for authorized security research and system administration only. Users are responsible for:

  • Obtaining proper authorization before scanning systems
  • Complying with applicable laws and regulations
  • Using the tool ethically and responsibly
  • Respecting privacy and data protection

πŸ™ Acknowledgments

Built with inspiration from:

  • Linux kernel security research
  • SANS Institute rootkit analysis
  • Open source security community
  • Academic rootkit detection research

Protect your systems. Detect threats. Stay secure. πŸ”

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages