Anything DIY

Easy ban for spam phone calls using Dynamic Routes and CID lookup

Post Reply
other / anything     Views: 67Prev .. Next
Easy ban for spam phone calls using Dynamic Routes and CID lookupPosted: Thursday, June 27, 2024 [17:00:20] - 1
rootPosted by:rootMember Since:
June 16 2010
Posts: 363
It appears as phone spam companies buying area codes whole exchange for their businesses.
Blacklist in FreePBX getting really big because of that.
Simple and very much workable solution is by blocking the whole exchange for the area code(s) and it takes almost no resources.

Just add "Dynamic Routes" module to FreePBX and create a simple URL Lookup on some home computer that runs Apache or any other Web Server.

Easy ban for spam phone calls using Dynamic Routes and CID lookup

Add some Dynamic Route Entries to block the caller based on URL Lookup responses.

Simple Lookup Perl script will do the job:

View Code#!/usr/bin/env perl
## Lookup for Dynamic Routes FreePBX Module
## Based on response Dynamic Routes can put the call through
## or take additional actions
use strict;
use warnings;

my %in;    our %dsrch;    my $res='';
unless($ENV{'QUERY_STRING'}) {exit(0);}
my @inp = split(/[&;]/,$ENV{'QUERY_STRING'});

foreach my $i (@inp) {
    my($key, $val) = split(/=/,$i);
    $key =~ s/%([A-Fa-f0-9]{2})/pack("c",hex($1))/ge;
    $val =~ s/\D//g;
    $in{$key}=$val;
}

my $ut=time;
my $lclt=localtime($ut);
$lclt =~ tr/ //s;
open(VR,">>/path_to_log_file/last.pbcheck.txt");
print VR "$lclt ($ut)\nCID: $in{'number'}\nDID: $in{did}\n";
print "Content-type: text/plain\n\n";

if($in{did} eq '1XXXXXXXXXX') { ## Replace "X"-es with your DID
    unless(length($in{'number'}) == 11) {$in{'number'} = '1'.$in{'number'};}
}
print VR "Lookup number: $in{'number'}\t";
## MATCH SCAMMERS AREA CODE AND EXCHANGE - Edit next line to match your scammers area code(s)/exchange
if($in{'number'} =~ m/^1(412465|412460|412830|412506|412847|412520|210245|215234|225207|816393)/) {
     print 'badcall';
     $res='Spammers phone';
     doexit('spam');
}

## NOW, SEE IF CALLER IN YOUR PHONEBOOK
if(-f "/path_to_your_phone_book/search.phones.txt") {
    eval {require "/path_to_your_phone_book/search.phones.txt"};

    if($dsrch{$in{'number'}}{'en'}) {
        print VR "$dsrch{$in{'number'}}{'en'}\n";
        print 'goodus';    $res='record in PB: '.$dsrch{$in{'number'}}{'en'};
    } ## END PHONE FOUND
    else {
        print 'allus';    $res='not in PB US';
    } ## END NO ENTRY
} ## END PHONEBOOK PRESENT
else {
    print 'allus';    $res='no PB found';
} ## END NO PHONE BOOK FILE

doexit($res);

sub doexit {
    my $res=shift;
    print VR "result: $res\n---------\n";
    close(VR);
    exit(0);
} ## END SUB DO EXIT


When they move to a new area code/exchange just edit lookup script.There's no place like ~
other / anythingPrev .. Next
 
Post Reply
Home - Other: Anything DIY
Our Telegram Group