Find Invisible Users In Gmail


Finding who is invisible is something that I always wanted to do.It’s always fun to ping a person who feels none can see him/her online. While studying XMPP protocol I found out that even when the person is offline the chat client knows that person is online.
The Chat Client should know who all are really online at any given time.This is because even when the person is invisible he/she should have a buddy list showing online users.

Ah!! Guess you did’nt understand a word till now.Let me try making it simpler.

Let’s assume two users A and B are online now.Both A and B are Available (ie the chat client shows them online).Both A and B has a list of online users in his chat client(eg:google talk,gmail inbox chat,pidgin). Now this online users need to be kept constantly updated. This is done by the XMPP protocol(this is the protocol used by google for it’s chat).Now even if B is invisible still it needs to keep it’s online users list updated as it needs to show B the online users.
So whenever B logs into his account it initially sends a presence notification to all the users in it’s contacts list saying that B is online as “Please show me online in our online user list”.
All online users respond back with their online status and status message.
This is where the invisible people shows up.The chat server replies back with their status. The only difference in them is that they respond with their status as “Unavailable“.
So my aim was to find out all users that respond back to me with Unavailable status and display them.
Ok enough of explanation of how it works let’s see the code

#!/bin/perl

use strict;
use Net::XMPP;

my $sttime=time;
print "Username:$ARGV[0]\n";
my $username = "$ARGV[0]";
my $password = "$ARGV[1]";

my $resource = "SNIFFER";

my $hostname = 'talk.google.com';
my $port = 5222;
my $componentname = 'gmail.com';
my $Contype = 'tcpip';
my $tls = 1;

my %online;
my $Con = new Net::XMPP::Client();
$Con->SetCallBacks(presence=>\&presence_ch);

my $status = $Con->Connect(
hostname => $hostname, port => $port,
componentname => $componentname,
connectiontype => $Contype, tls => $tls);

if (!(defined($status))) {
print "ERROR:  XMPP connection failed.\n";
print "        ($!)\n";
exit(0);
}

# Change hostname
my $sid = $Con->{SESSION}->{id};
$Con->{STREAM}->{SIDS}->{$sid}->{hostname} = $componentname;

# Authenticate
my @result = $Con->AuthSend(
username => $username, password => $password,
resource => $resource);

if ($result[0] ne "ok") {
print "ERROR: Authorization failed: $result[0] - $result[1]\n";
exit(0);
}
else
{
print "Logged in Sucessfull!\nInvisible Users:\n";
}
$Con->PresenceSend(show=>"Available");
sub presence_ch
{
my $p=0;
my $x;
my $presence = pop;
my $from = $presence->GetFrom();
$from =~ s/([a-zA-Z@.]*)\/(.*)/$1/;
if($presence->GetType() eq "unavailable")
{
if (exists $online{$from})
{
delete($online{$from});
}
else
{
$online{$from}=$presence->GetType()."!!" .$presence->GetStatus();
print $from."\n";
}
}
else
{
$online{$from}=$presence->GetType()."!!" .$presence->GetStatus();
}
}
my $currtime;
while(1)
{
$currtime=time;
if($currtime-$sttime>10)
{last;}
my $res=$Con->Process(1);
if(!(defined($res))){ last;}}

XMPP protocol needs SSL encryption.So you need to install the perl modules for it.So before trying out the code make sure u have the following modules:

  • IO ::Socket ::SSL (>=0.81)
  • XML ::Stream
  • Net ::XMPP
  • Authen ::SASL

To install the packages open the CPAN shell using the command

sudo perl -MCPAN -e 'shell'

Followed by

install <module name>

for each of the module listed above
Also you need to install the package send-xmpp and it’s dependecies

sudo apt-get install send-xmpp

Run the program by running it as

perl invi.pl <username> <password>

If you need Windows Version of the tool, check the Comment #39
Worked?? Did’nt work?? Comment me


, , , , , , ,

  1. #1 by Vivek on September 21, 2008 - 9:19 am

    kollaam..nice…good explanation…try cheythu nokaam ….

  2. #2 by Jan on November 15, 2008 - 1:56 pm

    Hey Srijith

    I tried your code with ActivePerl on Windows and keep getting this error:

    You requested that XML::Stream turn the socket into an SSL socket, but you don’t have the correct version of IO::Socket:
    :SSL v0.81. at D:/Perl/site/lib/XML/Stream/Node.pm line 547

    Can you please help resolve this?

  3. #3 by R Srijith on November 16, 2008 - 12:57 am

    you need to use send-xmpp package in linux to avoid that error.
    I am not sure how to install it in windows.But feel there should be a package for it in windows too. Let me see and will get back to you.

  4. #4 by Jan on November 16, 2008 - 7:00 pm

    Thanks!! Would appreciate if you could let me know.

  5. #5 by Su_j on December 22, 2008 - 1:35 am

    Good work done…
    Now lets see if i can get more out of it…

  6. #6 by Anonymous on March 21, 2009 - 1:31 am

    Hi Srijith…..I can’t able to open this…..while trying to open this site itz coming as HTTP 5000 Internal server error…..can’t I view the invisible people anymore…..is this site not working…..

  7. #7 by R Srijith on March 21, 2009 - 2:06 am

    if you tried the online version then it is not working right now. The server I have been using is not allowing communication via post 5222. You can use the program by running the program from your system using the code i posted in this post.

  8. #8 by sharath on May 24, 2009 - 12:03 pm

    I am using almost the same code to check the invisible users on gtalk & it is working fine for me.

    If I am behind the proxy server of type http, $Contype = 'http'; will work with the same port i.e. 5222;

    if I am directly connecting to internet without any proxy then $Contype must be 'tcpip'

    if I am behind a https proxy server then $Contype = 'http' ; with $port = 443; and the

    connect system call will change to

    #the rest of the parameters u have is same.
    $ssl=1;
    $tls=1;
    Connect(hostname => $hostname,
    port => $port,
    componentname => $componentname,
    connectiontype => $connectiontype,
    tls => $tls,
    ssl => $ssl);

  9. #9 by J.K on January 16, 2010 - 7:42 pm

    does this code only can be use in linux
    how to use this others who dont have linux?
    Could you send me explanation on my mail
    cuz i am begginer and dont understand this much
    about code and other stuff
    thanks

  10. #10 by Srijith R on January 17, 2010 - 12:24 am

    You can try using active perl to do it in windows. Try that method and tell me if u get stuck somewhere

  11. #11 by asdfasdf on February 6, 2010 - 1:10 am

    come on guys..i guess its a script to trap us..

  12. #12 by Srijith R on February 6, 2010 - 9:31 am

    If you know perl just read through the code and then you will understand what i am doing. And I am giving the code and telling you to run. Not asking you to enter user name password.

  13. #13 by unknown on February 17, 2010 - 10:59 pm

    i am getting the following error

    syntax error at invi.pl line 21, near “&”

    i installed all the modules and sendxmpp package also.

  14. #14 by Srijith R on February 17, 2010 - 11:21 pm

    Oops there was an error in code that triggered that error “&” was represented as “&” when i recently edited the code. Thanks for pointing it out to me. have fixed it

  15. #15 by ufo on February 18, 2010 - 7:49 pm

    I get the following error:

    Can’t call method “GetFrom” on an undefined value at invi.pl line 57

  16. #16 by unknown on February 18, 2010 - 8:27 pm

    ya I some how figured it out yesterday. but there are two new problems now

    I am getting error like this

    Can’t call method “GetFrom” on an undefined value at invi.pl line 57.

    and I am behind a ‘http’ proxy server in my campus which allows only these settings in pidgin

    connection port : 443
    and force old (port 5223) ssl checked

    In Net::XMPP documentation i have seen that for connectiontype = ‘http’ headers are needed to talk through a web proxy

    plzzz can u help me with this

  17. #17 by Srijith R on February 20, 2010 - 11:37 pm

    Its essential for the connection port to be 5222. I myself was not able to run it behind an squid server. I feel you need to open 5222 for this script. So I cant really help you in that.

  18. #18 by Simone on February 23, 2010 - 10:03 am

    i’m very interested in this script – is there any way of making the online version of this available again?

  19. #19 by Srijith R on February 23, 2010 - 10:06 am

    Well issues i had last time was I could’nt find a server that opens 5222 port for running this script and people suspecting that I am stealing passwords. So if you could suggest a solution for this I can create the online version

  20. #20 by ss44 on February 25, 2010 - 4:23 am

    I also get the “Can’t call method “GetFrom” on an undefined value” any suggestions?

  21. #21 by jj on February 27, 2010 - 3:37 pm

    Hi sreejith,

    Good logic. I installed all the modules and i am getting the following problem.
    ERROR: XMPP connection failed.
    (Operation now in progress)
    I am sitting behind a http server. Could you help me in debugging this.

    Thanks

  22. #22 by Srijith R on February 27, 2010 - 11:48 pm

    Its because u r behind an HTTP server. It needs to be from 5222 port when it reaches google server. Could you try without HTTP server. or try tunneling it outside

  23. #23 by Vishnu on February 28, 2010 - 8:55 pm

    I get similar error…

    Can’t call method “GetFrom” on an undefined value at /home/vishnu/Workshop/xmpp/invi.pl line 57.

    I have no proxy…

  24. #24 by Srijith R on February 28, 2010 - 9:26 pm

    I am sorry there was a small error in the script when i recently changed the script. I have corrected it now please try now and tell me

  25. #25 by Vishnu on February 28, 2010 - 11:32 pm

    Yes it’s working, perfect…. Thank you. It’s adipoli machu…

  26. #26 by Lovy Singhal on March 8, 2010 - 9:47 pm

    Hi thr! Followin is d error tht I m g8in. Will appreci8 help 4m u.

    Username:xyz
    ERROR: XMPP connection failed.
    (Invalid argument)

    TIA

  27. #27 by Srijith R on March 8, 2010 - 10:13 pm

    is ur username xyz? and did u pass password also as mentioned in the blog?

  28. #28 by Lovy Singhal on March 15, 2010 - 12:27 am

    No, it displayed my actual username in place of xyz and yes, I did pass the password too. FYI, I m behind a proxy server, if that is of any relevance.

  29. #29 by howzzzat on March 27, 2010 - 3:18 pm

    Hi Srijith,

    A nifty piece of code indeed! :)
    I wanted to point out that when I log in using the script, I’m logged in as visible (maybe for less than a second). Still is there a way to log in as invisible and get other invisible contacts :p

    Thanks

  30. #30 by Offshore Web Development on April 24, 2010 - 4:39 pm

    Hey.. great script ..
    Carry on with such great work.

  31. #31 by Vyom on April 25, 2010 - 5:21 pm

    Can you please make the online version up. I am finding difficulty doing in windows. Difficult installing send-xmpp, IO ::Socket ::SSL (>=0.81) and XML ::Stream. Used Actvie state perlmanager.

  32. #32 by Karthik on May 5, 2010 - 8:43 am

    Hey I am new to PERL on Windows. Can somebody give a step-by-step direction to detect invisible users on Google chat?

    Thanks

  33. #33 by Srijith R on May 5, 2010 - 10:24 am

    I Thought my blog post is descriptive. If you could explain what you are not understanding I could help you out in that. And I hav’nt worked in active perl. So not very good in that.

  34. #34 by Shar on May 8, 2010 - 3:09 pm

    I get a similar error to this-
    You requested that XML::Stream turn the socket into an SSL socket, but you don’t have the correct version of IO::Socket:
    :SSL v0.81. at D:/Perl/site/lib/XML/Stream/Node.pm line 547

    Great code-but to really be useful you need to be a little more low level.I managed to somehow install activePERL on Win and also install the packages..But I wasnt able to install send-xmpp(no clue) although I did download a TAR file..

    Please help out

  35. #35 by azy on May 13, 2010 - 10:50 am

    hiii..this is a nice work reli…i cn undrstnd d coding but i duno where 2 do dis coding…pls can anybody tel me pls..i love 2 see ma invisible buddies…

    tnq
    bye

  36. #36 by Rupert on May 14, 2010 - 9:35 am

    are
    * IO ::Socket ::SSL (>=0.81)
    * XML ::Stream
    * Net ::XMPP
    * Authen ::SASL
    avail in windows.. I don’t know much but I can’t seem to get it to work. you couldn’t find a server that opens the correct port for your online one, but would you be able to send me an exec that would allow me to run it from home?

  37. #37 by Thaha on May 18, 2010 - 7:30 pm

    I installed Active Perl for WAMP in XP and is working fine..
    But I couldnt find the module IO ::Socket ::SSL. and when I try to run the script I get the ” Internal Server Error”.

    Please help me..

  38. #38 by Ashish Kumar on May 21, 2010 - 12:20 pm

    Superb job, awesome script…and thanks sharath as well, ur tweak got it working for me in my college!

  39. #39 by vyompv on June 2, 2010 - 8:28 pm

    I got it worked at last in Windows. [i tried in Windows XP]
    Guys download the perl from here http://strawberryperl.com/ [38MB file] and then from the programs menu take the command prompt from strawberry perl. And then type->cpan [ i have tried with normal command prompt it works smooth]
    install these modules: [format to type inside cpan prompt->install ]
    IO::Socket::SSL
    XML::Stream
    Net::XMPP
    Authen::SASL
    All will get installed without error [as it does in linux]

    After that download send-xmpp from here http://sendxmpp.platon.sk/ [download this file sendxmpp-0.0.8.tar.gz.] .Hope you already have Winrar for extracting that file. [may be it works with zip, i didnt check it]
    Extract the send-xmpp file and via command prompt go to that folder where its extracted and then do these commands:
    1)perl Makefile.PL
    2)dmake
    3)dmake install

    Thats it. Now copy the above script [be careful while copying hope you don't make mistake] and paste in NOTEPAD [not wordpad] and save as “invi.pl” [Save as type All files and ANSI encoding. [save the file with quotes]
    and then take the command prompt to the place where you kept that file and then type->perl invi.pl
    I got the result without any error :) . Hope you also enjoy the output.

    And not to mention thanks to Srijith; he has done a great job. :)

  40. #40 by vyompv on June 2, 2010 - 8:32 pm

    I think it will work in windows 7. Well i tried with windowx XP 32 bit. If its 64bit change the appropriate download of perl from http://strawberryperl.com/.

  41. #41 by vyompv on June 3, 2010 - 8:57 pm

    Type perl invi.pl username password to run the program. I have put in my previous post with ” it didnot get printed.

  42. #42 by hs on June 4, 2010 - 3:50 pm

    Excellent excellent excellent…..Both the script as well as the 39th comment by vyompv. Both have been very descriptive and helpful and all works fine on my Win XP machine. Only 1 thing I would like to know (if possible)…the moment I run the script, I get online for a minute and then get offline…is there a way to edit the code and just check the invisible users without getting online? Even if thats not possible, no issues…..yet its really really helpful code…..Hats off…!! :)

  43. #43 by vyompv on June 5, 2010 - 9:14 pm

    Hi Sreejith well i was trying to convert the whole thing in java [rate myself a beginner]. I am very new to perl but some how managed to make out the things. After a lot of google and a lot search i made the java code to enter into the gtalk and get all the visible and away users making myself in invisible mode.
    As you told Presence->gettype “unavailable”. For me all the offline users also come under this.
    Presence class with getstatus method returns null for me for all the unavailable users.
    May be i did not understand your code properly can you please tell me the exact place where you differentiate offline and invisible user. The class and the method which you used for that.

    I got in invisible mode by taking presence type as unavailable and then sending that packet using connection.

    I checked the perl docs of NET::XMPP i couldnt figure out the difference in offline and invisible. Tried a lot for a day but couldn’t figure it out. Thanking you for the reply.

  44. #44 by Harry on June 6, 2010 - 11:08 am

    Thank you both vyompv and Srijith. Between the two of you it worked perfectly!!

    Is there anyway to invite an invisible user to a video chat?

  45. #45 by Nisanth Issac on June 6, 2010 - 9:41 pm

    First of all, hats off to you for this wonderful script. But the problem is that I couldn’t run it. I am using ubuntu 10.04 and contains perl v5.10.1. I tried to install all the four packages specified above but all of them gave the result as “Cannot install , don’t know what it is.”. Also I have a file invi.pl containing your code and don’t know how to run it.

  46. #46 by Srijith R on June 6, 2010 - 11:35 pm

    I am not sure how that error comes. Try installing it from the installation folder. Which is ~/.cpan/bundles folder.

  47. #47 by vyompv on June 8, 2010 - 9:00 am

    Nishanth
    There is a small change in the package names u type ->
    IO::Socket::SSL
    XML::Stream
    Net::XMPP
    Authen::SASL

    Copy paste these things :) . i

    LOL i hope you would have kept a space in between in the package name.
    Enjoy the output.

    Srijith you need to remove that space [people would be copying that and and trying to install. Even i made the same mistake :( .

  48. #48 by Kar on June 12, 2010 - 12:13 am

    I have been working with the instructions in #39 and have installed all the modules and extracted sendmxpp but the command prompts don’t seem to be recognizing “perl” or “dmake” commands. Anybody know why?

  49. #49 by vyompv on June 12, 2010 - 11:05 am

    :) :) :) I made the code in java :) . Took a bit of time to figure it out as i rate myself a beginner in coding. I have used the smack package to communicate to google talk [that went easy]. After that, was the trouble; for using the package correctly for finding the invisible users, though Srijith explanation was good enough for layman.
    Connecting through google talk and then communicating via invisible mode went well.
    There was a word callback in his code, to figure out that i took a bit of time; its called “Packet” in the smack package.

    Since its in Java and smack package my code works well in all the google like chat [where the private companies use their own domain name and host their mail in google [gmail]].
    The code also keeps ourselves invisible.

    May be Srijith can tweek his code to make ourselves invisible. In my code i have first logged in invisible mode and then kept a listener for packet [callback] .

    Well that was a great idea by Srijith to find invisible users.

    To run the java code is pretty difficult for layman, i cannot give the explanation the way in which Srijith did. In java we need to download package and then put the things which will not work and lot of error can occur. So i am thinking to make a jar running application [which a lay man can run easily] and put in my blog later, so for sometime i am not even publishing my code.

    Thanks Srijith it was a great idea and i learnt a lot from your code.

    Nammude keralam valaratte !!!! [in malayalam language spoken in kerala[india]]

  50. #50 by Nisanth V Issac on June 12, 2010 - 6:02 pm

    Hi Srijith, Vyompv
    thank u both for the support. But ‘prasnagal theeruniila’ hi hi.At first i got ERROR: XMPP connection failed and now ERROR: Authorization failed: . I was not logged in to the account through any other software when I executed the script. Please help me get rid of this error.

    Nammude keralam valaratte !!!!

1 2 3
(will not be published)