Page 1 of 1 [ 1 post ] 

Aaron_Mason
Veteran
Veteran

User avatar

Joined: 3 Jul 2005
Age: 38
Gender: Male
Posts: 511
Location: Bathurst, Australia

24 Aug 2008, 5:29 am

Hey all,

This is hardly new news - the Bourne Again SHell (BASH) has been able to do this for years. I, however, have made a small IRC bot using only bash's socket redirection (i.e. >/dev/tcp/host/port). The script is below.

Note that this won't work on Debian based Linux distributions as they have such redirection disabled at compile time. For the rest of us, here's the magic in the form of a small harassment bot.

Code:
#!/bin/bash

if [ ! "$1" ]; then
        echo "Syntax: $0 #channel"
        exit 1
fi

sock=/dev/tcp/irc.freenode.net/6667

exec 5<>$sock

echo NICK ^^BORG >&5
echo USER borg 8 \* :We are borg. >&5

while read line <&5; do
        echo $line

        if [ "$(egrep '^:.* 376' <<<"$line")" ]; then
                # end of MOTD

                echo "At the end of the MOTD, waiting 15..."
                sleep 15
                echo "JOIN $1" >&5
                echo "PRIVMSG $1 :We are borg.  Resistance is futile." >&5
                echo "QUIT :Resistance is futile." >&5
        fi
done


DISCLAIMER: I'm not responsible for anything that breaks if you use this script. Also, if you get g-lined from a network for using this, not my fault. You are responsible for everything that happens if you choose to use this. We know where you eat.


_________________
We are one, we are strong... the more you hold us down, the more we press on - Creed, "What If"

AS is definitive. Reality is frequently inaccurate.

I'm the same as I was when I was six years old - Modest Mouse