Skip to content

Instantly share code, notes, and snippets.

@UnforeseenOcean
Created July 27, 2024 04:59
Show Gist options
  • Save UnforeseenOcean/654f0406a78198f26394448fedba61d9 to your computer and use it in GitHub Desktop.
Save UnforeseenOcean/654f0406a78198f26394448fedba61d9 to your computer and use it in GitHub Desktop.
Free space filler file generator with misdirection for data recovery prevention
# Makes "believable" fake files to confuse common recovery software
# Copy the files to target device to overwrite free space after generating
# For best results wipe free space with zero fill before copying
# ---
# Requires you to prepare all headers to be used as "header.ext" such as "header.jpg" and put it inside a subfolder "headers"
# Make a subfolder to put the generated files into called "output"
# Then adjust the parameters to fit your needs
# This script written by Jamie, modified slightly to add more randomness. Tested on MINGW64/Msys64 and Linux
LEFTOVER_SIZE=5102993
SMALLEST_CHUNK=1039
BIGGEST_CHUNK=4958
while (( $LEFTOVER_SIZE > 0 ))
do
SIZE=$(($RANDOM%($BIGGEST_CHUNK-$SMALLEST_CHUNK+1)+$SMALLEST_CHUNK))
NAME_LEN=$(($RANDOM%(32-4+1)+4))
if (( $SIZE >= $LEFTOVER_SIZE ))
then
SIZE=$(( LEFTOVER_SIZE ))
fi
TEMP_NAME=($(cat /dev/urandom | tr -cd '0-9a-zA-Z' | head -c $NAME_LEN))
LEFTOVER_SIZE=$(( LEFTOVER_SIZE-SIZE ))
echo "creating file $TEMP_NAME.bin"
dd if=/dev/random of=output/temp.bin bs=${SIZE}k count=1
HEADER=$(ls headers/ | shuf -n 1)
echo "using header: $HEADER"
cat ./headers/$HEADER output/temp.bin > output/$TEMP_NAME.${HEADER#*.}
rm output/temp.bin
done
echo "All done, exiting"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment