# The bastardrc from:
# http://bonanomi.com/luke/bastard/
# A .bashrc for BOFHs, with all the thoughtful administrative features that the FSF forgot
# to add to BASH and that you forgot to mention to your boss.
#
# Currently Featuring:
# * remapped kill signals
# * process management
# * interactive mail forging
# Coming Soon!
# * Printer management
# * Hotkeys
###################
# BASH Functions
##################
# Remapped Kill switches
# BOFH 1998 Series "The helldesk has got a bit too big for its boots, but the BOFH has a cunning plan to knock them down to size... "
function named_kill
{
if [[ $1 == '-Godfather' ]]
then
kill -9 $2
# I admit it. I didn't do the horse-head thing.
# I'll get to it soon.
fi
if [[ $1 == '-shotgun' ]]
then
for proc in $(ps -aux | awk '/[0-9]/ { print $2}' | grep "^$2")
do
kill -9 $proc
done
fi
if [[ $1 == '-cia' ]]
then
kill -4 $2
cia="grassy knoll" # (ed. note: Hrmm... should get this into the
fi # application's core dump instead of system core)
if [[ $1 == '-driveby' ]] # Caveat: You must know the beginning of the PID
then
for proc in $(ps -aux | awk '/[0-9]/ { print $2}')
do
if [[ $proc == $2 ]]
then
kill -9 $old_proc
kill -9 $proc
fi
if [[ $old_proc == $2 ]]
then
echo kill -9 $proc
fi
old_proc=$proc
done
fi
}
###########################################################
# Man, I hate IRC... but the metaphors are awfully handy.
#########################################################
function kick
{
shell=$(tr ":" "\t" < /etc/passwd | grep "$1" | cut -f 7)
su -c "fuser -k $shell" $1
}
function kick-ban
{
shell=$(tr ":" "\t" < /etc/passwd | grep "$1" | cut -f 7);
su -c "fuser -k $shell" $1
chmod -R ugo-rwx ~$1
}
##############
# Life mirrors
# Great Cinema
##############
function matrix
{
tty_assignment=$(finger $1 | awk '/on/ { print $9}')
echo "The Matrix Has You... \n\n" > /dev/$tty_assignment
cat /dev/core > /dev/$tty_assignment
}
#####################################################################
# renice: kill -9 other people's jobs until yours is running to spec.
# note: this will try not to disturb system processes.
#####################################################################
function renice
{
i=0;
pri=$(echo 55 | tr -d "+-");
until (($i > $pri));
do
kill -9 $(ps -aux | awk '!/^["root", "daemon"]/ { print $2 }' | grep [0-9] | head -1);
let i=$i+1;
done;
}
function kazaa_hunter
{
# kazaa_hunter Domain Administrator-Name Administrator-Password
ping=$({ echo "GET /index.html" >&0; cat; } <>/dev/tcp/192.168.0.7/80 | head -3 | tail -1)
if [ -n $(echo $ping | awk '/KaZaA/ { print $0}') ]
then
echo "Filesharing BASTARD!"
smbclient //$1/c$ $3 -U $1/$2 -c 'cd "/Program Files/Kazaa/"; rename Top Search.dll Rock.kpl;';
fi
}
function edit_host_file
{
smbclient //$1/c$ $3 -U $1/$2 -c 'cd "/WINNT/system32/drivers/etc"; prompt; get hosts';
count=$(wc -l ./hosts | awk '{ print $1}')
i=0; while (($i < $count));
do
line=$(head -$i ./hosts | tail -1);
echo $line; let i=$i+1;
echo "Edit this line? y/n";
read edit;
if [[ $edit = "n" ]]
then
echo $line >> TEST_THIS_FILE;
else
echo "New Entry, ended with ^d"; cat >> new_hosts;
fi
done
echo "New entry? y/n";
read new;
while [[ $new = "y" ]]
do
echo "New Entry, ended with ^d"; cat >> new_hosts;
echo -e "\nNew entry? y/n";
read new;
done
smbclient //$1/c$ $3 -U $1/$2 -c 'cd "/WINNT/system32/drivers/etc"; prompt; put hosts';
}
#################
# BASH Aliases
#################
##################################
# forge: interactive mail forgery
##################################
alias forge='
echo Mail To:; read TO;
echo Mail From:; read FROM;
cat | su -c "mail $TO $FROM"
'
# simple aliases
#
alias kill='named_kill'
alias matrix='matrix $1'
alias rm='rm -f'
alias rmdir='rm -rf'