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
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>
I have also made a online version of this script you can use to find invisible users the link is http://sriunplugged.blogspot.com/2008/11/online-version-of-perl-invisible-finder.html
Worked?? Did'nt work?? Comment me