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 language.you 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
user="username@gmail.com"
password="password"
server="gmail.com"
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=[])
connection.connect()
result = connection.auth(jid.getNode(), password, "client Name")
connection.RegisterHandler('presence',presenceHandler)
connection.sendInitPresence()
while connection.Process(1):
             pass

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

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





1 comment:

  1. presence.getType() is "unavailable" for both invisible and offline users so this does not work!
    Correct me if I am wrong.

    ReplyDelete