Skip to content

Educational PowerShell script that overwrites files with the BA AD F0 0D pattern and generates a readable text representation.

Notifications You must be signed in to change notification settings

david-marin-0xff/Overwrite-BAADF00D-ToTXT

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

**This PowerShell script overwrites a file with a repeating 4-byte pattern (0xBA 0xAD 0xF0 0x0D) for a user-specified number of passes, then creates a .txt file showing the pattern in readable hexadecimal form. **

Features:

Multi-pass overwrite using the 4-byte pattern BA AD F0 0D Prompts for full file path and number of passes

-- How the overwrite works (technical):

Pattern definition: The script defines the overwrite sequence as a byte array: [byte[]] $pattern = 0xBA, 0xAD, 0xF0, 0x0D Buffer construction:

A 4 KB buffer is filled by repeating the pattern above. This buffer is reused for each write operation to improve performance. File access:

The file is opened using .NET's System.IO.FileStream with: FileMode.Open FileAccess.ReadWrite FileShare.None

The script retrieves the file length to know how many bytes must be overwritten. Overwriting process:

The buffer is written repeatedly until the file length is reached. For the last chunk, if fewer than 4 KB remain, a partial copy of the buffer is written. Each pass ensures the file is flushed to disk to commit data.

Multiple passes: The process is repeated for the number of passes the user specifies. Between passes, the file stream is closed and reopened to reset buffers and ensure clean overwrites. Readable text output: After all passes, the script generates a .txt file alongside the original, containing the pattern repeated as human-readable hex: BA AD F0 0D BA AD F0 0D ...

Technical notes: Not a secure wipe: This script demonstrates basic overwriting and is not a guarantee of secure deletion. SSDs and file systems can retain copies. Buffer size: Uses 4 KB, aligned to common disk block sizes. Can be adjusted for performance. Flush behavior: Uses both Flush() and FlushToDisk() when available to improve data persistence. File locking: Opens with FileShare.None to prevent simultaneous access. Error handling: Handles user cancellations and I/O exceptions gracefully. Performance: Overwriting is I/O-bound; SSDs will complete faster than HDDs.

Usage: Run from PowerShell: .\Overwrite-BAADF00D-ToTXT.ps1 Follow prompts for file path and number of passes.

For educational and testing purposes only.******

About

Educational PowerShell script that overwrites files with the BA AD F0 0D pattern and generates a readable text representation.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published