User Tools

Site Tools


user:mcooper6:rene

~~TOC~~

The Lab46 Tutorials

Rene the Lady Bot

There's first love, and then there's Rene

Following the steps in this tutorial will lead you to the successful creation and customization of your very own IRC roBOT, complete with personality.

This is a time consuming process that is not for the faint of heart. Read carefully.

Requirements:

  • Some flavor of Linux/Unix or a shell account
  • Eggdrop v1.6.19 or later
  • The egg-fu .tcl script

Step 1: Get a bot

This tutorial specifically describes the process of getting and setting up eggdrop. Eggdrop is not the only bot available for free, however it seems to be the most documented. Here's how to do it:

  • Get a bot from eggdrophelp.org in the form of a gzipped tarball and download it to your computer.

From my Mac OS X shell, I used scp secure copy utility to copy it to the Lab46 server from my local computer. (not the only way to get it to the Lab46 shell, but effective)

:~$ scp -v /Users/$USER/downloads/eggdrop1.6.19+ctcpfix.tar.gz  $USER@lab46.corning-cc.edu:/home/$USER/

NOTE: Replace the '$USER' in the above lines with your user name on both systems, the one sending the files and the one using the files. This will likely be different for each computer.

NOTE: the -v technically represents debugging mode, however, when you're sending big files across the network, it's useful to get some extra information.

  • Extract the files from the eggdrop tarball.
:~$ tar zxvf eggdrop1.6.19+ctcpfix.tar.gz 

Before extracting the files from the tarball, it is a good idea to create a new directory for your eggdrop. Otherwise, you'll have an awfully confusing home directory with lots of seemingly meaningless files that you may be tempted to delete. (Don't do it.)

  • Navigate to the eggdrop working directory and begin the configuration process
:~$ cd eggdrop1.6.19
  • Next, the ./configure command runs a quick “diagnostic” program that checks to see if it can predict any compilation errors. (Mighty polite in my opinion.) You shouldn't experience any problems running this command on Lab46.
:~$ ./configure
  • Next, type make config followed by make. The HOWTO's suggest that this could take several minutes, and they're not kidding.
:~$ make config

:~$ make
  • After the configs have been made, type make install DEST=~/botdir where botdir is the directory where you'd like your bot to reside. (replace 'botdir' with the directory where you unpacked your eggdrop)
:~$ make install DEST=~/botdir

NOTE: The eggdrop tutorials suggest that the ~ in the above line might not work on some shells. This is correct, however a ~ will work fine on Lab46. In the case of systems where this does not work, use the fully qualified path /home/$USER/ where $USER is your username.

  • Switch to your home home directory and run a chmod on the directory where eggdrop is installed.

This step makes the entire directory an executable, which we're going to call at the end.

:~$ cd ..

:~$  chmod 700 botdir

Again, botdir is the directory where your bot is installed

  • Remove the installation tarball. (This step is optional.)

Step 2: Configure It

This is a detailed run-down of all the lines in the .config file that can/should be changed. I've added line numbers to help reduce the time it takes to hunt and find each setting. However, please note, that if you used make iconfig instead of make config (in the above section), then your .conf file will look radically different from what is described here.

  • Set your eggdrop path.
line 1: #! /home/$USER/botdir
  • This line sets the bot's owner. Make sure this is you!
line 26: set username "$USER"
  • line 30 provides the information that is shown to the user when they type /msg help
line 30: set admin "My Name <email: $USER@your.domain.here"
  • Next, set the network on which your bot will reside.
line 34: set network "your.server.here" 
  • The hostname is one of the most important settings. If this is not set correctly, don't expect to see your bot on IRC.
line 58: uncomment
line 58: set my-hostname "your.server.here"
  • line 130 sets this name of the .log file. In this case, it's not a bad idea to set it to the name of your bot. This prepares your bot for the possibility of installing a friend. The reason for commenting out line 130 and creating line 131 is that it contains the correct syntax and location of the default log file…in case you ever want to change it back.
line 130: Comment out
line 131: logfile mco * "logs/<botnick>.log
  • Set your channel information by editing line 136/137. In this case, I recommend commenting out line 136. Again, this will provide a nice syntax guide when editing this info years into the future.
line 136: comment out
line 137:  set logfile jpk <#channel> "logs/<#channel>.log"
  • Line 178 sets up the bot's actual user file for interacting on IRC. Eggdrop will come here to get information each time the bot is started. (This might also be retrieved each time the bot joins a new channel, but this reporter didn't look it up to be sure.)
line 178: set userfile "<botnick>Bot.user"
  • Next, set the pid (process ID) file. As far as this author is concerned, it's a good idea to set this line (and line 178) to a file name that reflects its relationship to the bot. However, this is optional.
line 182: set pidfile "pid.<botnick>Bot"
  • Uncomment line 255 and choose a random port for your bot to listen in on. In this case, I chose random number between 49152 and 69535 (the more unlikely range of ports in use).
line 255: listen 59393 all
  • Change line 262 to prevent trivial boots from the channel.

The default setting of 2 is a little too strict for some people's taste.

line 262: set remote-boots 1
  • Reset line 269 to prevent people from telnet-ing the bot requesting environment and other settings.

Egghelp.org recommends setting this to 1 for greater security.

line 269: set protect-telnet 1
  • Set require-p to 1, thus restricting party line access to only those users specified by the bot's owner.
line 283: set require-p 1
  • Using the stealth-telnets setting prevents the bot from identifying itself as such (that is, a bot). Instead it will respond with its nick.
line 292: set stealth-telnets 1 
  • It's a good idea to reset the dcc-flood-thr to a slightly higher number, thus allowing more lines to be pasted into the channel. Otherwise, any input of more than 3 lines will result in a ban for flooding.
line 305: set dcc-flood-thr 5

Now, a little net friendliness to put the network admins on our side.

  • Reset hourly-updates to a value other than 00.

00 represents the minutes (on the hour) when your bot will save its user file. Since there may be more than one bot on the network, resetting our hourly-updates to another number means that our bot will save its file at a different minute in the hour.

line 350: set hourly-updates 17 
  • Next, set yourself as the owner. Otherwise, you'll have a rogue on your hands, and the admins'll probably kill it.

Don't set this value to someone you don't know or trust.

line 354: Uncomment
line 354: set owner "$USER"
  • Comment out line 411.

This is one of the gotchas that the authors of eggdrop put in there to make sure that a lazily configured bot doesn't take on a life of its own.

line 411: comment out
  • Optional: Set up a chanfile.

You can either do this here, or you can hard code the channels using the addchannel settings shown later. If you do decide to use a chanfile, set chanfile by replacing the double quotes below with “<channel>Bot.chan”. Note: The .chan file overrides channel settings in the config file.

line 453: set chanfile "botdir/<channel>.chan"
  • Required: Set at least one channel for the bot to monitor.
Lines 772 - 792: 

772: channel add <channel> {
773:	chanmode "+nt-likm"
774:	idle-kick 0
775:	stopthehack-mode 0
776:	revenge-mode 0
777:	ban-time 120
778:	exempt-time 60
779:	invite-time 60
780:	aop-delay 5:30
781:	need-op { putserv "PRIVMSG <#channel> :op me cos I'm Lame!" }
782:	need-invite { putserv "PRIVMSG <#channel> :let me in!" }
783:	need-unban { putserv "PRIVMSG <#channel> :let me in!" }
784:	need-limit { putserv "PRIVMSG <#channel> :let me in!" }
785:	flood-chan 10:60
786:	flood-deop 3:10
787:	flood-kick 3:10
788:	flood-join 5:60
789:	flood-ctcp 3:60
790:	flood-nick 5:60
791:}

792: channel set #<channel> + bitch +enforcebans + dynamicbans +userbans + dynamicexempts

Remove line 781 if you plan on deploying your bot on a channel where it cannot get ops. Otherwise it will keep asking for ops again, and again and again.

From here on out, your line numbers will likely differ from this tutorial, due to different (more or less) channel settings.

  • Set the bot's nick
line 814: set nick "<botnick>"
  • Set the bot's alternate nick

Say the bot gets to its channel, and there's already someone there wearing the same red dress. No problem, your bot changes in the coat room.

line 819: set altnick "<altbotnick>"
  • Set the bot's real name. This will appear when users perform /who on the channel where the bot resides.

If you're looking to cloak your bot, make sure you change this to something that represents what a human would write.

line 823: comment out
line 824: set realname "Hi, I'm <botnick>"
  • Line 849 - 850 set the bot's port and server.
line 848: set servers{
line 849:   your.server.here:6667
line 850:}
  • Next, set the bot's server cycle.

This is the setting that tells the bot how often to establish a connection with its server. If you're sharing a server with others, it's best to leave this setting at 60. However, in the realm of Lab46, it's OK to set this to a lower number.

line 890: set server-cycle-wait 20
  • Button up security by setting learn users to 1.

Setting learn users to 1 means that you have to add users manually before they can access your party line chat. Setting this to zero allows people to invite themselves. This could provide a path for misuse.

line 1048: set learn-users 1
  • Unbind the default /msg command

By default, anybody can issue a /msg your bot with the 'hello' or 'ident' commands. This will most definitely flag your bot as a bot, and will also provide a back door for crackers, specifically if you have learn-users set to 0. Uncommenting lines 1066 & 1067 unbinds these commands and lines 1067 & 1074 re-bind these commands to new words.

line 1066: uncomment
line 1067: uncomment
line 1067: bind msg - <message> *msg:hello
line 1074: bind msg - <othermessage> *msg:ident
  • Tell your bot where to keep notes.

You can retrieve these notes using DCC & /msg commands.

line 1266: set notefile "<botnick>Bot.notes"
  • Finally, get the last gotcha
line 1288: comment out

botchk and crontab

After the bot's .conf file is created and configured it's time to set up your botck and crontab files.

First, eggdrop comes with a handy little checker called autobotchk that will take care of some of the diagnostic overhead. Running this file as an executable will allow eggdrop to predict compilation problems before compilation.

  • Issue the following command to change the permissions for autobotchk
:~$ chmod 700 autobotchk 
  • Now run autobotchk
:~$ ./autobotchk <botnick>.conf -dir /home/botdir -noemail

At this point, you should have a very clear idea of any other issues that need to be taken care of prior to launching your bot.

Sarting eggdrop

Finally, it's time to start this damn thing.

  • Issue the following command the FIRST time you start your bot.
:~$ ./eggdrop -m <botnick>.conf

The -m in the command above tells eggdrop to create a user file for your bot. Once you've launched your bot, you can omit the -m.

Make sure you're in the channel before you launch your eggdrop bot, otherwise the bot will be the channel op, and may not share the bounty. Incidentally, if you do find that you need to kill the bot, simply type pw x at the shell. This will give you a list of running processes, each with a unique number and description. Find the number described as 'eggdrop' and issue the following command:

##
## find the running process
##

:~$ ps x | grep eggdrop

##
## kill it!
##

:~$ kill <proc>

##
##  where '<proc>' is the process number assigned to eggdrop.
##

Set Up

Once eggdrop has joined the channel that was set in the <botnick>.conf file, issue the following command from the IRSSI prompt:

Where <botnick> is the name given to the bot and <myword> is the /msg command that is assigned in the <botnick>.conf file.

/msg <botnick> <myword>

Follow this with: where <pswd> is your chosen password.

/msg <botnick> pass <pswd>  

NOTE: don't set your password in the company of prying eyes, as your password is shown as plain text while typing, and is then spit back out to the screen. Further, messaging the bot via DCC requires your password as well, and again, it is shown on the screen while typing it.

If your password has been plastered all over your IRSSI screen session, simply issue the command /clear. This will clear your entire screen.

Set up AI

Now, if you're reading this section, chances are good that you have a working bot. (If not, review the previous steps.)

Now, we can give our bot a personality. One of the easier (and more controllable) ways to do this is using he egg-fu script available at egghelp.org

  • Downloaded egg-fu from egghelp.org

Just as above, the scp utility is a handy tool for sending .zip and .tar archives across a network.

  • Once egg-fu is uploaded to the shell, unpack the files in the eggdrop ./scripts directory

Unpacking the archive will create a new directory (likely named egg-fu_2.0.2) within your scripts directory. Navigate into that directory and open the egg-fu .tcl file (likely named egg-fu_2.0.2.tcl).

  • Set up the working channels

Interestingly, adding channels in bot's the <botnick>.conf file will cause your bot (and egg-fu) to listen and learn on those channels, however the bot will only talk on channels set in the egg-fu tcl file

line 58: set working-chans "#channel1 #channel2 #channel3"
  • Set who to ingnore

Use this setting to tell your bot who NOT to learn from. Set this to the nicks of other bots or even other annoying people whose influence you'd rather avoid.

line 61: set other-bots "bot1 bot2 annoying_usr"
  • Now, edit <botnick>.conf file and add the path to egg-fu under the scripts section.

This line tells eggdrop what scripts to use at startup.

line 1368: source scripts/egg-fu.2.0.1/egg-fu.2.0.1.tcl
  • Give it a brain

Find the wordfile line and set it to the path where you'd like to keep the brain.

line 64: wordfile "botdir/brain.txt"

That's it! All the other default settings are good to go.

Now, there are a few ways to get your bot to recognize the new script. If you haven't yet started your bot, simply start it, and that's it's ready to go. However, if you've already started your bot, you can either find the process, kill it and restart it, or simply rehash it.

To rehash your bot, enter the following commands from irssi

/dcc chat <botnick>

This will open a new window within irssi. Change to the new window (alt + the window number) and enter your password. After that, you can type .help to get a list of commands available to your bot. The command you seek is .rehash. Type this at the irssi prompt and wait. A few minutes later, your bot will be back and talkative.

Useful Tips

Detaching from a screen when there are multiples, means that you have to know the number of your session. However, naming sessions makes it easier to find and reattach to a session. When creating your screen session, do this: screen -S <name> but replace <name> with the name you want to give your screen session. Now, when you want to reattach, simply use screen -ls to list all the sessions. You should see very clearly which session is which. Now, use screen -r <screen_id> to reattach to one.

Other Useful Settings

These are a few other optional lines that might be useful:

You can set the file system permissions with line 221

line 221: set userfile-perm 0600

When using your bot in a botnet, lines 246 and 247 allow you to set which ports should be listened in on.

 
line 246: listen 3333 bots
line 247: listen 4444 users

If you have learn-users set to 0, it's a good idea to make sure that line 357 is set to $owner (default). Don't set this to your acual nick because your bot will actually ID you by your hostmask, which is set using the 'owner' setting (see above).

line 357: set notify-newusers "$owner"

You can comment out lines 379 and 380 if you wish to allow .tcl and .set commands from the DCC chat interface. (NOTE: make sure you choose owners carefully if you bind these commands.)

line 379: unbind dcc n tcl *dcc:tcl 
line 380: unbind dcc n set *dcc:set:

Setting the strict-host setting causes eggdrop to ignore the tilde (~) in usernames. This can add a bit of extra security, however, as eggdrop recognizes users by their hostmask, this setting can cause problems.

line 858: set strict-host 0

Set dcc-block does what it says, it blocks DCC chat commands. DCC chat provides a malicious intruder with a path to begin the password guessing game.

line 1145: set dcc-block 0

If you plan on installing any type of file system, these are the lines you seek.

line 1230: set files-path "/home/mydir/filesys"
line 1235: set incoming-path "/home/mydir/filesys/incoming"

Conventions Used

  • $USER refers to your actual username, don't type '$USER' literally as this is an environment variable that eggdrop doesn't recognize.
  • botdir refers to the directory where you installed your eggdrop.
  • Replace your.domain.here with your actual domain.
  • Replace your.server.here with your actual IRC server.
  • <botnick> refers to your bot's nickname. Replace this with that.
  • <#channel> refers to your newly minted (or oldly polished) channel.
  • To “Comment out” a line means to put a hash/pound sign/sharp (#) at the beginning of the line.
user/mcooper6/rene.txt · Last modified: 2013/01/19 10:13 by mcooper6