WinCorrupt.py is a Windows-only Python script that:
- Creates the file:
C:\Windows\System32\config\OSDATAwith 120 KB of random binary data. (This file is unused but crashes windows if there is invalid data) - Forces an immediate system reboot (
shutdown /r /t 0).
The target file resides in the Windows registry hive directory (config). Corrupting or overwriting this file can render the operating system unbootable and cause permanent data loss. The script is intentionally simple and demonstrates the use of administrative privilege escalation and low-level file operations.
- Windows operating system (the script checks
os.nameand exits on non‑Windows platforms). - Python 3 (with the standard library modules
ctypes,os, andsys). - Administrator privileges – the script automatically requests elevation via UAC if not already running as admin.
-
Save the script as
WinCorrupt.py. -
Open a command prompt or terminal.
-
Run the script:
python WinCorrupt.py
-
If not already elevated, a UAC prompt will appear. Click Yes to grant administrator rights.
-
The script writes random data to the target file and then immediately reboots the computer. -# Note: There is no confirmation prompt. Execution leads directly to system reboot.
- Administrator Check –
is_admin()usesctypes.windll.shell32.IsUserAnAdmin()to verify if the process has admin rights. - Elevation – If not admin,
elevate()relaunches the script with the runas verb using ShellExecuteW, passing the original command‑line arguments. - File Overwrite –
os.urandom(FILE_SIZE)generates 120 KB of cryptographically random bytes, which are written toTARGET_FILE. - Reboot – After writing, the script calls
os.system("shutdown /r /t 0")to force an immediate restart.
- Data loss: Overwriting OSDATA corrupts the registry hive, making Windows unable to boot. You will likely need to reinstall the operating system or restore from a backup.
- No recovery: The script does not create a backup or prompt for confirmation.
- Use at your own risk: The author assumes no liability for any damage caused by this script.
If you intend to test this script, do so only in a virtual machine or on a disposable system with no important data.