@@@ @@@ @@@@@@@@ @@@@@@@ @@@@@@ @@@@@@ @@@@@@@@ @@@@@@@
@@! @@@ @@! @@! @@@ @@! @@@ !@@ @@! @@! @@@
@!@ !@! @!!@@! @!@!@! @!@!@!@@ !@@!! @!!@@! @!@!@!
!@ .:! @!: @! :!@ !@! !@! !@! @!: @! :!@
@! !@!:.:!@ @! :@. :!: :!: !:.:@! !@!:.:!@ @! :@.
VeraCrypt + Eraser = VERASER
A modern, cross-platform secure file erasure engine designed for permanent data destruction with military-grade algorithms and SSD-optimized techniques.
VERASER is a professional-grade secure deletion tool that goes beyond simple file deletion. When you delete a file normally, the operating system only removes the reference to that file—the actual data remains on the disk until overwritten. VERASER ensures that deleted data is truly irrecoverable by using cryptographic techniques and industry-standard overwriting algorithms.
- Military-Grade Security: Implements DoD 5220.22-M, NIST 800-88, and Gutmann algorithms
- SSD-Optimized: Advanced encrypt-in-place technique for solid-state drives
- Cross-Platform: Single codebase for Windows, Linux, and macOS
- Dual-Mode Operation: Use as CLI tool or integrate as a library
- Cryptography: Uses platform-native CSPRNGs and AES-256-CTR encryption
- Zero Dependencies: Self-contained implementation (OpenSSL optional on POSIX)
- High Performance: Optimized I/O with configurable chunk sizes (default 8 MiB)
- Recursive Processing: Handles entire directory trees with automatic cleanup
VERASER follows a PRD-driven architecture with clear separation between HDD-oriented overwrite algorithms and SSD-optimized encryption flows. The codebase is intentionally monolithic (veraser.c + veraser.h) to facilitate:
- Static linking into larger applications (e.g., VeraCrypt integration)
- Simple deployment without complex build dependencies
- Easy auditing of the entire codebase
The implementation uses conditional compilation to provide native platform support:
| Platform | RNG Source | Encryption | File I/O | TRIM Support |
|---|---|---|---|---|
| Windows | BCryptGenRandom (CNG) | BCrypt AES-256-CTR | Win32 API | Implicit on delete |
| Linux | getrandom() + /dev/urandom | OpenSSL EVP (optional) | POSIX | FITRIM ioctl + fallocate |
| macOS | arc4random_buf | OpenSSL EVP (optional) | POSIX | Implicit on delete |
- Thread-local error storage: Each thread maintains its own error message buffer via TLS (
__thread/__declspec(thread)) - Reentrant design: All public APIs are thread-safe for concurrent file operations
- Future-ready: Options struct includes
threadsfield for planned parallel processing
- Secure zeroing: Platform-specific implementations (
SecureZeroMemoryon Windows, volatile writes on POSIX) - Key cleanup: All cryptographic material (AES keys, IVs) is securely wiped after use
- Buffer protection: Sensitive buffers are cleared before deallocation
For traditional hard disk drives, VERASER uses multi-pass overwriting to prevent data recovery:
1. Open file in read-write mode
2. For each pass (algorithm-dependent):
a. Generate pattern (zeros, random, or algorithm-specific)
b. Write pattern across entire file in 8 MiB chunks
c. Flush buffers to disk (fsync/FlushFileBuffers)
3. Close file handle
4. Delete file (unlink/DeleteFile)
5. Optional: TRIM free space (best-effort)
Pattern Generation:
- Zero: Fixed 0x00 bytes (fast, basic security)
- Random: Cryptographically secure random data from OS CSPRNG
- DoD/NIST/Gutmann: Specific sequences defined by standards
For solid-state drives, traditional overwriting is ineffective due to wear-leveling and spare blocks. VERASER uses an encrypt-in-place approach:
1. Open file in read-write mode
2. Generate random 256-bit AES key and 128-bit IV
3. Read file in 8 MiB chunks:
a. Encrypt chunk with AES-256-CTR
b. Write encrypted data back to same location
c. Increment IV counter for next chunk
4. Flush all writes to disk
5. Punch holes (Linux fallocate) to deallocate extents
6. Close file handle
7. Delete file (unlink/DeleteFile)
8. Issue TRIM command (best-effort)
9. Securely wipe AES key and IV from memory
Why This Works:
- Original plaintext is overwritten with ciphertext derived from a random key
- Without the key (which is immediately destroyed), data is cryptographically irrecoverable
- TRIM hints allow the SSD controller to truly erase the physical blocks
- Faster than multi-pass overwrites (single pass + encryption)
Windows Path:
- Uses Microsoft CNG (Cryptography Next Generation) APIs
BCryptOpenAlgorithmProvider+BCryptSetPropertyfor CTR mode- Processes data in chunks with manual IV increment
- Hardware AES-NI acceleration when available
POSIX Path (with OpenSSL):
- Uses OpenSSL EVP interface (
EVP_aes_256_ctr) - Automatic IV management within EVP context
- Hardware acceleration via OpenSSL's optimized implementations
POSIX Fallback (no OpenSSL):
- XOR-based stream cipher (NOT SECURE)
- Provided only for build portability testing
- Production deployments should use OpenSSL
| Algorithm | Passes | Use Case | Speed | Security Level |
|---|---|---|---|---|
| zero | 1 | Quick wipe, pre-provisioning | 5/5 | 2/5 |
| random | 1-N | General-purpose secure deletion | 4/5 | 4/5 |
| nist | 1 | Recommended default for modern drives | 4/5 | 4/5 |
| dod3 | 3 | DoD 5220.22-M compliance | 3/5 | 4/5 |
| dod7 | 7 | Enhanced DoD compliance | 2/5 | 5/5 |
| gutmann | 35 | Historical maximum (overkill for modern drives) | 1/5 | 5/5 |
| ssd | 1 | Recommended for SSD/NVMe | 5/5 | 5/5 |
Based on NIST Special Publication 800-88 guidelines for media sanitization. Single-pass cryptographically secure random overwrite is sufficient for modern drives (≥15GB capacity, manufactured after 2001).
Best for: General-purpose secure deletion on any drive type
U.S. Department of Defense standard for sanitizing magnetic media:
- 3-pass: 0xFF, 0x00, random + verification
- 7-pass: Extended pattern sequence for classified data
Best for: Regulatory compliance, legacy systems
Peter Gutmann's 35-pass algorithm designed for older MFM/RLL drives. Includes patterns for various encoding schemes. Overkill for modern drives but useful for maximum paranoia scenarios.
Best for: Historical compatibility, extreme security requirements
Modern approach for solid-state storage:
- Encrypt: AES-256-CTR in-place encryption with random key
- Delete: Standard file deletion
- TRIM: Hint to SSD controller to erase physical blocks
Best for: SSDs, NVMe drives, USB flash drives, SD cards
- Compiler:
- GCC 4.8+ / Clang 3.4+ (Linux/macOS)
- MSVC 2015+ / MinGW-w64 (Windows)
- OpenSSL (optional, POSIX only):
libssl-devor equivalent - Build Tools: Make / CMake (optional)
# With OpenSSL for secure AES-CTR
gcc -O2 -Wall -std=c99 -DVE_BUILD_CLI -DVE_USE_OPENSSL \
veraser.c -o veraser -lssl -lcrypto
# Without OpenSSL (uses insecure fallback)
gcc -O2 -Wall -std=c99 -DVE_BUILD_CLI \
veraser.c -o verasercl /O2 /W4 /DVE_BUILD_CLI veraser.c /Fe:veraser.exe bcrypt.libgcc -O2 -Wall -std=c99 -DVE_BUILD_CLI \
veraser.c -o veraser.exe -lbcrypt# Omit -DVE_BUILD_CLI to build only the library
gcc -O2 -Wall -std=c99 -c veraser.c -o veraser.o# Securely erase a single file (NIST algorithm - recommended default)
./veraser --path sensitive_document.pdf
# Erase entire directory recursively
./veraser --path /path/to/secret_folder --algorithm ssd
# Dry run to preview operations
./veraser --path myfile.txt --dry-run
# Multiple random passes with verification
./veraser --path data.db --algorithm random --passes 3 --verifyveraser --path <target> [options]
| Option | Values | Description |
|---|---|---|
--path |
<file|dir> |
Required. Target file or directory |
--algorithm |
zero|random|dod3|dod7|nist|gutmann|ssd |
Erasure algorithm (default: nist) |
--passes |
<N> |
Number of passes for random algorithm (default: 1) |
--verify |
Enable read-back verification (increases time) | |
--trim |
auto|on|off |
TRIM control (default: auto) |
--dry-run |
Preview operations without modifying data | |
--quiet |
Reduce output verbosity |
# Default NIST algorithm
./veraser --path invoice.pdf
# Explicitly use SSD mode for faster erasure
./veraser --path photo.jpg --algorithm ssd# Recursively erase entire directory tree
./veraser --path ~/old_projects
# With verification for critical data
./veraser --path /tmp/confidential --algorithm dod7 --verify# Multiple random passes (paranoid mode)
./veraser --path keys.pem --algorithm random --passes 7
# Legacy DoD compliance with TRIM disabled
./veraser --path archive.zip --algorithm dod3 --trim off
# Safe preview before erasure
./veraser --path important_folder --dry-run#include "veraser.h"
int secure_delete_file(const char* path) {
ve_options_t opts = {0};
opts.algorithm = VE_ALG_SSD;
opts.trim_mode = 0; // auto
ve_status_t status = ve_erase_path(path, &opts);
if (status != VE_SUCCESS) {
fprintf(stderr, "Erasure failed: %s\n",
ve_last_error_message());
return -1;
}
return 0;
}// Erase file or directory (recursive)
ve_status_t ve_erase_path(
const char* path,
const ve_options_t* options
);
// Best-effort TRIM on free space
ve_status_t ve_trim_free_space(
const char* mount_or_volume_path,
int aggressive
);
// Detect storage device type
ve_device_type_t ve_detect_device_type(
const char* path
);
// Get last error message (thread-local)
const char* ve_last_error_message(void);typedef struct {
ve_algorithm_t algorithm; // Erasure algorithm
ve_device_type_t device_type; // Device hint (auto/ssd/hdd)
int passes; // Random algorithm passes
int verify; // Enable verification
int trim_mode; // 0=auto, 1=on, 2=off
int follow_symlinks; // Traverse symlinks
int erase_ads; // Windows ADS handling
int erase_xattr; // Extended attributes
uint64_t chunk_size; // I/O buffer size
int threads; // Reserved (future)
int dry_run; // No-op mode
int quiet; // Reduce verbosity
} ve_options_t;File recovery tools (Recuva, PhotoRec, etc.)
Forensic data carving from unallocated space
Simple file system analysis (directory listings, metadata)
Basic disk imaging without specialized equipment
Physical disk dissection (electron microscopy in lab conditions)
Firmware-level attacks on compromised storage controllers
Data already backed up elsewhere (cloud, external drives, RAID mirrors)
Operating system caches (swap, hibernation files, temporary files)
Hardware wear-leveling on SSDs (residual data in spare blocks - mitigated by encryption + TRIM)
- Use SSD algorithm for modern drives: Fastest and most effective
- Verify TRIM support: Check that your filesystem/OS enables TRIM
- Run as administrator/root: Required for TRIM operations on some systems
- Disable swap/hibernation: For truly sensitive data, disable these OS features first
- Full-disk encryption: Use LUKS/BitLocker/FileVault as the first line of defense
- Verify erasure: Use
--verifyflag for critical data (adds time but confirms success) - Multiple passes for HDDs: 3-7 passes for magnetic drives if paranoid
- Single pass for SSDs: More passes don't help and cause unnecessary wear
- ADS/Extended Attributes: Not implemented in current version
- Symlink Handling: Follow mode exists but defaults to off (security)
- Network Shares: May not support TRIM; algorithms still work for overwriting
- Compressed Filesystems: Encryption-based methods may not work as expected (btrfs, ZFS compression)
- Copy-on-Write FS: BTRFS, ZFS may duplicate data during overwrites (use filesystem-specific tools)
- Device Detection: Auto-detection is placeholder (returns AUTO); manually specify SSD mode
Windows:
- Requires
bcrypt.libfor linking - Automatically clears read-only flag before erasure
- TRIM is typically handled by OS on delete
Linux:
- FITRIM requires mount point, not individual files
fallocatepunch-hole requires kernel 2.6.38+- May require root for FITRIM ioctl
macOS:
- TRIM is automatic on modern macOS (10.10+) for internal SSDs
- External drives may not support TRIM
arc4random_bufis always available (no fallback needed)
// Add to VeraCrypt's dismount flow
#include "veraser.h"
void SecureDeleteContainerFile(const char* containerPath) {
ve_options_t opts = {0};
opts.algorithm = VE_ALG_SSD;
opts.verify = 1;
opts.trim_mode = 1; // force TRIM attempt
if (ve_erase_path(containerPath, &opts) != VE_SUCCESS) {
// Log error via VeraCrypt's logging system
LogError("Secure deletion failed: %s",
ve_last_error_message());
}
}// Nautilus/Explorer context menu handler
void OnSecureDeleteAction(const char** files, int count) {
ve_options_t opts = {0};
opts.algorithm = VE_ALG_NIST;
opts.quiet = 0;
for (int i = 0; i < count; i++) {
printf("Erasing %s...\n", files[i]);
ve_erase_path(files[i], &opts);
}
}#!/bin/bash
# Secure cleanup of temporary files
TEMP_DIRS=(
"/tmp/app_cache"
"/var/log/old_logs"
"~/.cache/thumbnails"
)
for dir in "${TEMP_DIRS[@]}"; do
if [ -d "$dir" ]; then
./veraser --path "$dir" --algorithm ssd --quiet
fi
doneTested on Ubuntu 22.04, Intel i7-12700K, various storage devices:
| Drive Type | Algorithm | File Size | Time | Throughput |
|---|---|---|---|---|
| NVMe SSD (Samsung 980 PRO) | SSD | 1 GB | 0.8s | ~1250 MB/s |
| NVMe SSD | NIST (random) | 1 GB | 1.2s | ~833 MB/s |
| SATA SSD | SSD | 1 GB | 1.5s | ~667 MB/s |
| HDD 7200rpm | DoD-3 | 1 GB | 18s | ~167 MB/s |
| HDD 7200rpm | Gutmann | 1 GB | 3m 45s | ~14.8 MB/s |
Benchmarks are approximate and vary by hardware configuration.
Contributions are welcome! Areas of interest:
- Automatic device type detection (SSD vs HDD)
- NTFS Alternate Data Streams handling
- Extended attributes (xattr) cleanup
- Multi-threaded processing for large directories
- Progress callback mechanism for GUI integration
- Windows Storage Spaces / ReFS optimization
- Verification mode implementation
- Localization (i18n)
# Clone repository
git clone https://github.com/yourusername/veraser.git
cd veraser
# Build with debug symbols
gcc -g -O0 -Wall -Wextra -std=c99 -DVE_BUILD_CLI -DVE_USE_OPENSSL \
veraser.c -o veraser_debug -lssl -lcrypto
# Run tests (TODO: add test suite)
./veraser_debug --path test_data/sample.txt --dry-run- Follow K&R indentation (4 spaces)
- Maximum line length: 100 characters
- Comments:
/* */for multi-line,//for single-line - Prefix all internal functions with
ve_ - Use explicit error handling (no silent failures)
MIT License - See LICENSE file for details.
This software is provided "as is", without warranty of any kind. The authors are not responsible for data loss or any damages resulting from the use of this tool.
- VeraCrypt Project: Inspiration for robust cross-platform crypto tools
- Eraser Project: Original Windows secure deletion tool
- NIST SP 800-88: Guidelines for media sanitization
- Peter Gutmann: Secure deletion research and algorithm design
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Security: For security concerns, email can.omer.5306@outlook.com (PGP key available)
- Core erasure algorithms
- Cross-platform support
- CLI interface
- Library API
- Automatic device detection
- Progress reporting callbacks
- Multi-threaded directory processing
- Comprehensive test suite
- GUI application
- Scheduled/automatic erasure
- Integration with major file managers
- Enterprise policy management
Remember: Secure deletion is only one part of data security. Always use full-disk encryption, secure backups, and proper access controls for comprehensive protection.