May 24, 2010

Find invisible users in your Gtalk buddy list

Most instant messaging protocols like yahoo messenger, msn, gtalk, etc,. support invisible users. Anyone can remain online without being noticed by anyone in their buddy list. In this post I'm going to explain how to find the invisible users in your GTalk list. For this i used:
  •    operating system: ubuntu 9.04 
  •    programming language:python language.Install this by running 
            sudo apt-get install python
  •    xmpp module for python can install this by running the following command:   
                         sudo apt-get install python-xmpp
          The interesting thing about GTalk implementation is that it implements user 'invisibility' on the client side, not on  the server side. we can find such invisible-yet-online users by listening to their presence notifications. When ever a user or client joins a sever/network, it sends presence notification for the users. when the user authenticates to the server and becomes invisible, the client sends an 'unavailable' presence to all buddies in the roster. Thus, presence notifications with a presence type of 'unavailable' means that the user is in invisible mode. All Gtalk clients ignore this type of presence; hence, those users are not shown in the buddy list.

using the below python program we can grab the list of invisible users.It uses XMPP module for python. You can install this module in Ubuntu and other debian based distribution by running the following command:
                                      sudo apt-get install python-xmpp

#!/usr/bin/python -W ignore::DeprecationWarning
import xmpp
def presenceHandler (conn, presence):
      if presence:
         if presence.getType() == "unavailable":
          print presence.getFrom().getStripped()
print "Invisible users:"
jid = xmpp.JID(user)
connection = xmpp.Client(server,debug=[])
result = connection.auth(jid.getNode(), password, "client Name")
while connection.Process(1):

Write the above code in a text editor and save it as '' (without quotes)
open the terminal and go to the directory containing the file and type:
         chmod a+x   to get root powers to execute the code.

now type:
This will print the list of invisible users on the command line itself.