#!/usr/bin/perl -w use Net::AIMTOC; use Term::ReadKey; $version = 0.01; #The version number $screenname = ""; #Contains the screenname for logging in $password = ""; #Password for logging in $out = "STDOUT"; #Set default output to the screen @targets; #Array containing screennames to watch # process($) # Takes next argument as parameter. # Checks to see if it's a flag, otherwise # considers it a screenname and adds to list. sub process_args($) { my $iterate = 0; #Local variable for adding to @targets if ($_[0] eq "-v" || $_[0] eq "--version") { print "Thanks for supporting AimSpy. You are currently using version $version of AimSpy.\n"; } elsif ($_[0] eq "-h" || $_[0] eq "--help") { } #help info elsif ($_[0] eq "-o") { #check for output file spec. $save = shift @ARGV; open($out = SAVE, ">>$save") or open($out = SAVE, ">$save") or die "Can't save to file $save: $!\n"; } elsif ($_[0] eq "-i") { #check for input file spec. $read = shift @ARGV; open(INPUT, "$read") or die "Could not open file: $!\n"; $iterate = 0; while() { $targets[$iterate] = $_; $iterate++; } } else { #everything else is a screenname $targets[$iterate] = $_[0]; $iterate++; } } # login() # Logs in to AIM. Prompts sn and pw. # Establishes connection to AOL. # Doesn't really do too much else.... sub login() { if (!@ARGV) { #We need someone to spy on. die "No targets specified!"; } if ($screenname eq "") { print "Enter your screenname: "; chomp($screenname = ); print "\nEnter your password: "; ReadMode 2; chomp($password = ); ReadMode 0; } try { $aim = Net::AIMTOC->new; $aim->connect; $aim->sign_on($screenname, $password); } catch Net::AIMTOC::Error with { my $err = shift; print $err->stringify, "\n"; }; foreach my $iterate (@targets) { $aim->add_online_buddies("aimspy", $iterate); } } sub monitor() { while (1) { my $msg = $aim->recv_from_aol(); if ($msg->getType eq 'UPDATE_BUDDY' && $msg->getBuddy eq @targets) { print $out $msg->getBuddy, " turned ", $msg-getOnlineStatus, " at this time.\n"; } elsif ($msg->getType eq 'IM_IN') { print $out "Message ", $msg->getMsg, " received from ", $msg->getSender, " at this time.\n"; } elsif ($msg->getType eq 'ERROR') { print $out "Error ", $msg->getMsg, " received at this time.\n"; } } } while (@ARGV) { #process arguments process_args(shift @ARGV); } login; monitor;