#!/usr/bin/perl # supercid.pl - by ro0t2 # Version 3 (Modified to use Greypages XML) # http://www.oldskoolphreak.com # Based on hacked version of supercallerid.pl by natas # shouts also to Strom carlsons and dual, all of whom inspired this is the first # place. # http://www.oldskoolphreak.com # This script uses Greypages and ACMA (Australian Communications and Media Authority's) # Number Register, also filter has been included to only accept numbers in regular # STD format eg. 0732210987...this is mainly to limit unnecessary requests # to greypages. # This is the third recode of this, the code is still very sloppy, i really don't # know perl at all, although am now starting to learn :P its just written from # perldoc, google and other scripts including supercallid.pl by natas # Shouts to natas, dual, strom carlson, jasonk and everybody at www.ausphreak.com # sorry for lack of commenting in the code its all pretty straight forward though # very simple little script os thought it unnecessary # Instructions for Unix based machines (sorry windows guys I got NO idea) # Shell Usage: supercid.pl # chmod +x supercid.pl # In extentsions.conf add this to imcomming call location # exten => {PHONENUMBER},1,System(/home/./supercid.pl ${CALLERIDNUM} > /outputdirectory/super_callerid_output.txt) # exten => {PHONENUMBER},2,Dial(SIP/PHONE1) # etc. anyways the lookup takes about 2 rings on my box...so just means that your phone # wont start ringing for a few extra seconds # You will need to get the following for this to work # perl -MCPAN -e "install WWW::Mechanize" and/or # perl -MCPAN -e "install XML::LibXML" # perl -MCPAN -e "install MIME::Base64"; use strict; use WWW::Mechanize; use MIME::Base64; use XML::LibXML; if($ARGV[0] =~ /0[23478]\d\d\d\d\d\d\d\d/){ # filters for Australian number format...mainly to stop it running on VoIP calls and to allow further coding # that would allow different scripts for different number formats my $input = $ARGV[0]; my $username = "greypages"; my $password = "9954"; my $mech = WWW::Mechanize->new(autocheck => 1); my @args = ( Authorization => "Basic " . MIME::Base64::encode( $username . ':' . $password ) ); $mech->get("http://bluedevel.com/greypages/search-xml.php?cmd=searchall&phoneno=$input", @args); my $content = $mech->content(); my $parser = XML::LibXML->new(); my $tree = $parser->parse_string($content); my $root = $tree->getDocumentElement; my $bussiness_var = $root->getElementsByTagName('COMPANY_NAME'); my $initals = $root->getElementsByTagName('INITIALS'); my $name = $root->getElementsByTagName('SURNAME'); my $fax = $root->getElementsByTagName('FAX_AC_PHONE'); my $address = $root->getElementsByTagName('ADDRESS'); my $suburb = $root->getElementsByTagName('SUBURB'); my $postcode = $root->getElementsByTagName('POSTCODE'); my $state = $root->getElementsByTagName('STATE'); my $longitude = $root->getElementsByTagName('LONGITUDE'); my $latitude = $root->getElementsByTagName('LATITUDE'); $mech->get("http://web.acma.gov.au/numb/openAccess/inquiry/viewAllocationSearch.do"); $mech->form(1); $mech->field("fromNumber", $input); $mech->field("outputId", 2); $mech->field("action", 'Search'); $mech->click(); my $content = $mech->content(); my $holder; my $numarea; my $servarea; my $alocatedate; my $service; if ($content =~ /.* "(.*)","(.*)","(.*)","(.*)","(.*)","(.*)","(.*)","(.*)","(.*)","(.*)","(.*)","(.*)".*/){ $service = $1; $holder = $9; $alocatedate = $8; $numarea = $11; $servarea = $12; } my $final_name; # just combines the initials with surname if person or sets to the company name if ($bussiness_var =~ /[a-z]/){ $final_name = $bussiness_var; } else { $final_name = $initals." ".$name; } print "\n Caller ID: \t\t"."$input\n\n"; print " Name: \t\t"."$final_name\n"; print " Address: \t\t"."$address\n\t\t\t$suburb\n\t\t\t$postcode\n\t\t\t$state\n\n"; print " Longitude: \t\t"."$longitude\n"; print " Latitude: \t\t"."$latitude\n"; print " Fax No: \t\t"."$fax\n"; print " Service Type: \t"."$service\n"; print " Allocatee: \t\t"."$holder\n"; print " Allocation Date: \t"."$alocatedate\n"; print " Service Area: \t"."$servarea\n"; print " Numbering Area: \t"."$numarea\n"; print "\n"; }