In this simple article, we will learn how to encrypt IRC traffic of WeeChat (IRC Client) using the crypt plug-in.
The Plugin
To encrypt IRC traffic we need to download the crypt.py plugin from this link: http://weechat.org/files/scripts/crypt.py:
cd ~/.weechat/python wget http://weechat.org/files/scripts/crypt.py
All python-based plugins should be downloaded inside ~/.weechat/python/ folder.
We can move the plugin into ~/.weechat/python/autoload, this is done to load the script automatically when weechat starts.
mv ~/.weechat/python/crypt.py ~/.weechat/python/autoload
The plugin will encrypt IRC Traffic automatically.
Building the Key
OK, now we have the plugin in place we need to configure our key, to do this, we can use OpenSSL to generate the key:
cd ~/.weechat/ echo “1234567890” > mykey.txt openssl enc -bf-cbc -salt -in mykey.txt -out cryptkey.#mychannel
OK, here is what happened:
- We created a file called mykey.txt to save our key .
- Then we encrypted the key using openssl (blowfish), we can protect our key with a password (and we should).
- #MyChannel is the name of the channel where we will be using this key.
- Optionally, you can delete mykey.txt or move it to a secure location.
The Password
I don’t like giving recommendations when it come to password generation, but, just a hint, in Linux you can run the following command to get a random string:
tr -dc A-Za-z0-9 < /dev/urandom | head -c 128
Output should be something like:
9I2bIsnJZpYqIZ00Swh2ia3g9OSIvb6zEwUkzIfYQXLY35H8uMCtOJwvZixpwW5LXo62f9OwM5FOhdXVPlpLc2Pk7q2E1vz3HGxiKRhtAtIXrkqZMyYBo4TMNJ4Y15dE
Key Name
cryptkey.myFriend crypt will use this key when chatting with the user myFriend, so if you want to chat with me (encrypted), you must save this key as cryptkey.ligeti.
cryptkey.#channelname crypt in this case will use the key to encrypt your chat while chatting in the #debian channel, so if you want to encrypt yourself while chatting in channel the key should be saved as cryptkey.#debian.
Loading the Plugin
To load the plugin you should issue the following command in weechat:
python load crypt.py
This is done in case you didn’t copy the plugin inside the autoload folder, we should see the following message:
python: loading script “home/ligeti/.weechat/python/crypt.py” python: registered script “crypt”, version 1.4.4 (encrypt/decrypt PRIVMSGs using a pre-shared key and openssl)
You can also run the /python command (or /python list) to list all the loaded plugins
Share the Key
Just post it on Facebook… of course! 😐 (that was a level 3 joke)
There are many ways to share the key with others, and there are many ways to share your key anonymously as well, but to simplify, nevertheless, do you really trust any tools? Because I don’t to be honest.
For more IRC fun, check out this tutorial on how to build artistic IRC bot: How to Build an IRC Bot in Python.