"""PyAudio hdd-killer: Generate sound and interfere with a spinning HDD (not SSDs) """ """Alfredo Ortega @ortegaalfredo""" """Usage: hdd-killer """ """Where is any big file. Can be a /dev/sdX raw device, it will be opened read-only.""" """Turn the volume to the max for better results""" """Requires: pyaudio. Install with 'sudo pip install pyaudio' or 'sudo apt-get install python-pyaudio'""" import pyaudio import time import sys import math import random RATE=48000 FREQ=50 # validation. If a disk hasn't been specified, exit. if len(sys.argv) < 2: print "hdd-killer: Attempt to interfere with a hard disk, using sound.\n\n" +\ "The file will be opened as read-only.\n" + \ "Warning: It might cause damage to HDD.\n" +\ "Usage: %s (can also be a raw device ex. /dev/sdX)" % sys.argv[0] sys.exit(-1) # instantiate PyAudio (1) p = pyaudio.PyAudio() x1=0 NEWFREQ=FREQ # define audio synt callback (2) def callback(in_data, frame_count, time_info, status): global x1,FREQ,NEWFREQ data='' sample=0 for x in xrange(frame_count): oldsample=sample sample=int(math.sin(x1*((2*math.pi)/(RATE/FREQ)))*127)+128 #### uncomment for square wave # if sample<128: sample=10 # if sample>128: sample=250 data = data+chr(sample) # continous frequency change if (NEWFREQ!=FREQ) and (sample==128) and (oldsample