Advertisement
Spetnik

Fill disk with data (Python)

Jan 30th, 2017
354
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.72 KB | None | 0 0
  1. # WARNING: DO NOT RUN THIS SCRIPT unless you know what you are doing
  2. # This script can permanently erase ALL data from your disk
  3.  
  4. import os
  5. import sys
  6.  
  7. megs = 4 #MB to write at a time
  8. size = 10 #Number of GB (total) to write to drive
  9.  
  10. f = os.fdopen(os.open('\\\\.\\PhysicalDrive2',  os.O_WRONLY|os.O_BINARY), 'wb+') #MAKE SURE YOU CHANGE THIS TO THE CORRECT DRIVE
  11. a = bytearray(1048576 * megs)
  12.  
  13. for x in range(0, 1048576 * megs):
  14.     if x % 4 == 0:
  15.         a[x] = 0xba
  16.     elif x % 4 == 1:
  17.         a[x] = 0xad
  18.     elif x % 4 == 2:
  19.         a[x] = 0xf0
  20.     else:
  21.         a[x] = 0x0d
  22.  
  23. for x in range(0, int((size * 1024) / megs)):
  24.     if x % megs == 0:
  25.         sys.stdout.write("\r %s MB written" % (x * megs))
  26.     f.seek(x * 1048576 * megs)
  27.     f.write(a)
  28.  
  29. f.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement