Skip to content

Latest commit

Β 

History

History
69 lines (55 loc) Β· 4.73 KB

File metadata and controls

69 lines (55 loc) Β· 4.73 KB

Drive Shredder πŸ›‘οΈπŸ’Ύ

Drive Shredder is a robust, security-focused desktop application built with Qt 6 and C++. It is designed to permanently erase data from external storage devices (USB drives, SD cards, external HDDs) using industry-standard sanitization algorithms, rendering the data unrecoverable.

🌟 Key Features

  • πŸš€ Auto-Elevation: Automatically detects if the application is running without root privileges and relaunches itself with pkexec to ensure it has the necessary permissions to write directly to block devices.
  • πŸ” Real-Time Drive Detection: Automatically detects connected drives and updates the list in real-time. Smart filtering hides system partitions (like /, /boot, /home) to prevent accidental damage to your operating system.
  • 🧹 Multiple Shredding Algorithms:
    • Zero (1 Pass): Fast, fills the drive with zeros.
    • DoD 5220.22-M (3 Passes): US Department of Defense standard (Zeros, Ones, Random).
    • Gutmann (35 Passes): Maximum security, overwrites data 35 times with specific patterns.
    • Secure Erase (ATA/NVMe): Uses the drive's built-in firmware commands to erase all data. Ideal for SSDs and NVMe drives as it resets all blocks.
    • Cryptographic Erasure: Instantly destroys the media encryption key, rendering data unreadable. Fastest method for self-encrypting drives (SEDs).
  • ⏱️ Precision Tracking:
    • Real-time Progress Bar.
    • Elapsed Time counter.
    • Estimated Time Remaining (ETA) calculation based on current write speed.
  • πŸ› οΈ Integrated Formatting: Seamlessly formats the drive after shredding (supports ext4, ntfs, fat32, exfat) so it's ready to use again immediately.

πŸ”„ Application Flow

  1. Startup: App checks for root permissions. If missing, it requests password via PolicyKit (pkexec) to restart as root.
  2. Detection: Scans for removable media, filtering out system drives.
  3. Selection: User selects a target drive and a shredding method.
  4. Preparation:
    • Safety Check: Confirms user intent with a warning dialog.
    • Unmount: Automatically unmounts the drive to ensure exclusive access and prevent OS interference.
  5. Shredding:
    • Runs in a background thread to keep the UI responsive.
    • Writes patterns directly to the raw device file (e.g., /dev/sdb) OR issues Secure Erase commands.
    • Updates UI with progress and time estimates.
  6. Completion & Recovery:
    • Notifies user upon success.
    • Offers to Format the now-empty (raw) drive.
    • If formatted, the drive is remounted and ready for use.

πŸ”§ The "Nitty Gritty": Technical Challenges Handled

This project solves several complex system-level challenges:

1. Root Privilege Management πŸ”

Writing to raw block devices requires root access. Instead of asking the user to run sudo ./app, the application handles this natively:

  • It checks getuid() at startup.
  • If not root, it spawns a new instance of itself using pkexec, passing necessary environment variables (DISPLAY, XAUTHORITY) to preserve the GUI session.

2. Safe Drive Handling & Unmounting πŸ›‘

  • The Problem: You cannot write to or format a mounted drive safely. The OS will fight you.
  • The Solution: We implemented an automated unmountDrive() helper. Before any destructive operation, the app issues a umount command.
  • UI Challenge: Unmounting a drive usually makes it disappear from QStorageInfo. We handle this by pausing UI updates during the operation and caching the device path (m_currentDrivePath), ensuring the app doesn't "lose" the drive it's working on.

3. Threading & Concurrency 🧡

  • Shredding a large drive takes time. Running this on the main thread would freeze the GUI.
  • We use QtConcurrent::run to offload the heavy I/O operations (shredding and formatting) to a background thread.
  • Signals and Slots (progressUpdated, timerUpdated) are used to safely communicate back to the main UI thread.

4. Raw Block Device I/O πŸ’Ύ

  • The app doesn't write to files; it writes to the physical device (e.g., /dev/sdb).
  • It handles low-level details like buffer sizes (4KB chunks) and flushing to ensure data is physically written to the disk platter/flash cells.
  • For Secure Erase, it interfaces with system tools (nvme-cli, hdparm) to trigger the drive's internal erasure routines.

πŸ“¦ Requirements

  • OS: Linux (requires pkexec, lsblk, umount, mkfs.*, nvme-cli, hdparm)
  • Framework: Qt 6.x
  • Build System: CMake or qmake

⚠️ Disclaimer

This software permanently destroys data. Once shredded, data cannot be recovered by any means. Use with caution.