Sponsor: VoiceMeUp - Corporate & Wholesale VoIP Services

VoIP Mailing List Archives
Mailing list archives for the VoIP community
 SearchSearch 

[asterisk-users] Blacklist callers from file


 
Post new topic   Reply to topic    VoIP Mailing List Archives Forum Index -> Asterisk Users
View previous topic :: View next topic  
Author Message
atux at null.net
Guest





PostPosted: Sat Aug 27, 2016 10:59 am    Post subject: [asterisk-users] Blacklist callers from file Reply with quote

Hi. I would like to blacklist a few callers and I have been using the *CLI> database put blacklist 1234 "annoying callers". Instead of putting the same command for every user is there any way to have a file? Ideally a file in /opt that I would update the blacklisted numbers (add,remove). Is there anything like that, please?
Back to top
asterisk.org at sedwar...
Guest





PostPosted: Sat Aug 27, 2016 2:49 pm    Post subject: [asterisk-users] Blacklist callers from file Reply with quote

On Sat, 27 Aug 2016, tux john wrote:

Quote:
Hi. I would like to blacklist a few callers and I have been using the
*CLI> database put blacklist 1234 "annoying callers". Instead of putting
the same command for every user is there any way to have a file? Ideally
a file in /opt that I would update the blacklisted numbers (add,remove).
Is there anything like that, please?

If you are happy with the way blacklisting with the Asterisk database
works, how about a shell script that loads all of the entries in your
blacklist file?

Other alternatives involve modifying your dial plan. If you are
comfortable with that then you can consider alternatives like an AGI that
reads your text file and sets a channel variable.

If you need more 'immediacy' maybe storing the blacklist in a 'real'
database is more appropriate -- especially if you want the users to
maintain their own black list via a web page.

--
Thanks in advance,
-------------------------------------------------------------------------
Steve Edwards sedwards@sedwards.com Voice: +1-760-468-3867 PST
https://www.linkedin.com/in/steve-edwards-4244281

--
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --

Join the Asterisk Community at the 13th AstriCon, September 27-29, 2016
http://www.asterisk.org/community/astricon-user-conference

New to Asterisk? Start here:
https://wiki.asterisk.org/wiki/display/AST/Getting+Started

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/asterisk-users
Back to top
atux at null.net
Guest





PostPosted: Sun Aug 28, 2016 11:20 am    Post subject: [asterisk-users] Blacklist callers from file Reply with quote

Hi. Thanks a lot for the reply. Script seems good, but i am stuck on how
to make it.




On 27/8/2016 10:48 μμ, Steve Edwards wrote:
Quote:
On Sat, 27 Aug 2016, tux john wrote:

Quote:
Hi. I would like to blacklist a few callers and I have been using the
*CLI> database put blacklist 1234 "annoying callers". Instead of
putting the same command for every user is there any way to have a
file? Ideally a file in /opt that I would update the blacklisted
numbers (add,remove). Is there anything like that, please?

If you are happy with the way blacklisting with the Asterisk database
works, how about a shell script that loads all of the entries in your
blacklist file?

Other alternatives involve modifying your dial plan. If you are
comfortable with that then you can consider alternatives like an AGI
that reads your text file and sets a channel variable.

If you need more 'immediacy' maybe storing the blacklist in a 'real'
database is more appropriate -- especially if you want the users to
maintain their own black list via a web page.



--
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --

Join the Asterisk Community at the 13th AstriCon, September 27-29, 2016
http://www.asterisk.org/community/astricon-user-conference

New to Asterisk? Start here:
https://wiki.asterisk.org/wiki/display/AST/Getting+Started

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/asterisk-users
Back to top
asterisk.org at sedwar...
Guest





PostPosted: Sun Aug 28, 2016 11:53 am    Post subject: [asterisk-users] Blacklist callers from file Reply with quote

Please don't top-post.

Quote:
On 27/8/2016 10:48 μμ, Steve Edwards wrote:
Quote:

Other alternatives involve modifying your dial plan. If you are
comfortable with that then you can consider alternatives like an AGI
that reads your text file and sets a channel variable.

On Sun, 28 Aug 2016, john wrote:

Quote:
Script seems good, but i am stuck on how to make it.

Sounds like time for a bit of reading.

The AGI protocol is simple. You give Asterisk a request. You get a
response. It's all text based and you can enable AGI debug mode and watch
the 'conversation' on the console.

There are lots of examples on the net.

You can pick any language you're comfortable with. Save yourself a lot of
frustration and use an existing AGI library.

For your needs, your AGI may be as simple as:

) Read the AGI environment if your library does not do it automagically.

) Look for the ANI/caller ID in your text file (or database).

) Either set a channel variable (like AGISTATUS) or set the
context/extension/priority. I've written AGIs both ways. I think setting a
channel variable makes for more reusable code.

--
Thanks in advance,
-------------------------------------------------------------------------
Steve Edwards sedwards@sedwards.com Voice: +1-760-468-3867 PST
https://www.linkedin.com/in/steve-edwards-4244281
--
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --

Join the Asterisk Community at the 13th AstriCon, September 27-29, 2016
http://www.asterisk.org/community/astricon-user-conference

New to Asterisk? Start here:
https://wiki.asterisk.org/wiki/display/AST/Getting+Started

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/asterisk-users
Back to top
johnkiniston at gmail.com
Guest





PostPosted: Mon Aug 29, 2016 11:21 am    Post subject: [asterisk-users] Blacklist callers from file Reply with quote

Here is a quick and dirty bash script to do it that I wrote you.

#!/bin/bash
if ( asterisk -rx "database deltree blacklist")
        then
                echo "Blacklist Cleared"
        else
                err "ERROR Failed to clear Blacklist, Exiting."
                exit 1;
fi

while IFS=, read TN REASON
do
if ( asterisk -rx "database put blacklist \"${TN}\" \"${REASON}\"")
   then
           echo "Inserted $TN $REASON to Blacklist"
   else
         err "ERROR Insert Failed on $TN."
         exit 1;
fi

done < blacklist.csv
unset IFS



It reads from the file blacklist.csv in the same directory with the format of NUMBER,"DESCRIPTION/REASON"



On Sat, Aug 27, 2016 at 8:59 AM, tux john <atux@null.net (atux@null.net)> wrote:
Quote:
Hi. I would like to blacklist a few callers and I have been using the *CLI> database put blacklist 1234 "annoying callers". Instead of putting the same command for every user is there any way to have a file? Ideally a file in /opt that I would update the blacklisted numbers (add,remove). Is there anything like that, please?

--
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --

Join the Asterisk Community at the 13th AstriCon, September 27-29, 2016
      http://www.asterisk.org/community/astricon-user-conference

New to Asterisk? Start here:
      https://wiki.asterisk.org/wiki/display/AST/Getting+Started

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users



--
A human being should be able to change a diaper, plan an invasion, butcher a hog, conn a ship, design a building, write a sonnet, balance accounts, build a wall, set a bone, comfort the dying, take orders, give orders, cooperate, act alone, solve equations, analyze a new problem, pitch manure, program a computer, cook a tasty meal, fight efficiently, die gallantly. Specialization is for insects.
---Heinlein
Back to top
tim.strommen at gmail.com
Guest





PostPosted: Mon Aug 29, 2016 5:29 pm    Post subject: [asterisk-users] Blacklist callers from file Reply with quote

Sorry, Gmail took my conversation with John off-list somehow,  I'll repost what I had set here (sorry, it's going to be a bit big now), and I will be more careful in the future:

First part:


I'm using Grandstream phones, so I have XML soft-keys, what hardware do you have and how good are you with dialplans?  You'll have to do some re-work unless you have an exact match for my setup.  I'm doing my best to give you the functional code, I have to change a bunch of stuff to not leak the security things I do in my code and some of the way more involved stuff I do.  this should at least get you running I think.  Portions between "CODE:  /CODE" tags are the functional dialplan code, I tried to comment a lot here to explain what's happening, but I may have broken something in the process.  Also, be aware that I generate custom sound files, so if you try to run the code and it throws an error about sound-file does not exists, that's why.

For this, I am using the internal DB in Asterisk (https://wiki.asterisk.org/wiki/display/AST/Asterisk+Internal+Database).


The first part is easy, but also very important - filter your Caller-ID data (in computers, we NEVER trust data from a source we don't generate), CODE:


[incommingcall]
exten => 15555551234,1,Set(CalledNumber=${15555551234})               ; Primary incoming phone line, number changed to protect my phone number
same => Set(CallEventTime=${STRFTIME(${EPOCH},,%m-%d-%Y_%H.%M.%S)}
same => n,Set(CALLERID(name)=${FILTER(A-Z0-9\s,${CALLERID(name)})})
same => n,Set(CALLERID(num)=${FILTER(0-9,${CALLERID(num)})})
same => n,Verbose(Incomming call to main phone number)
same => n,Goto(IVR-Menu,IVRStart,1)



/CODE - Then you hit phone numbers that don't have caller ID with the special three-tone application that sounds like a phone company message, CODE:


[IVR-Menu]
exten => IVRStart,1,Zapateller(nocallerid)                 ; Before answering we do the sound for no-caller ID calls
same => n,Zapateller(answer,nocallerid)                    ; This is where the phone call gets answered, we hit no-caller ID calls again here
same => n,Wait(1)
same => n,Playback(call-recording-warning)              ; Legally required message: "For quality control purposes, this call may be monitored."
same => n,Wait(2)
same => n,Monitor(wav,Inbound_to_${CalledNumber}_from_${CALLERID(num)}_${CallEventTime})  ; Yes, I record every call in an out.

same => n,GotoIf($["${CalledNumber}" != "15555551234"]?BlacklistFilter)  ; Number changed to protect my toll-free costs!!!


/CODE - I had a problem with political phone calls to my 855 number this past spring, so I added this little routine to prompt the caller for a single random digit to be entered to prove they could interact, that stopped all the calls from getting through.  CODE:


; special human test for toll-free

same => n,Set(TOLLFREERAND=${RAND(0,9)})
same => n,Read(HUMANTEST,thank-you&human-test&${TOLLFREERAND}&now,1,,1,5)   ; Says "Thank you. If you're a human, please press the number: {RANDOM}, now.", like a captcha.
same => n,GotoIf($["${HUMANTEST}" = "${TOLLFREERAND}"]?BlacklistFilter) ; If the random number matches what they entered they move on in the dialplan
same => n,Playback(do-not-call-warning)                   

; I have a message that states when this number was added to the FTC do-not-call list,
; requests removal of the number from the current list, and warns that the call and information was recorded

; and will be turned over to the FTC if the calls continue.

same => n,Hangup()  ; Yes, if a human can't be bothered to press one button when calling a number I pay the minutes for, I won't be bothered to talk to them.


/CODE - now we can get into the stuff that handles the blacklists and telemarketers.  CODE:


; return to regular program

same => n(BlacklistFilter), Verbose(Checking caller ID against blacklist)
same => n,GotoIf($[DB_EXISTS(blacklist\${CALLERID(num)})]?:TelemarketerFilter) ; If the caller ID is not in the blacklist DB family, it goes to the telemarketer check
same => n,VoiceMail(Blacklist@OtherAccounts,s)
same => n,Hangup()
same => n(TelemarketerFilter), Verbose(Checking caller ID against telemarketer list)
same => n,GotoIf($[DB_EXISTS(telemarketer\${CALLERID(num)})]?:IVRInteractiveStart) ; If the caller ID is not in the blacklist DB family, it goes to the telemarketer check

same => n,VoiceMail(Telemarketer@OtherAccounts,s)
same => n,Hangup()


/CODE: Then if the caller ID is not on either list, they go into the start of the IVR.  Everything up until now takes about 8 seconds, I limit "appeal" voicemails to 30 seconds by account limit, so that if one managed to come in through my toll-free number, it wouldn't finish the first minute of billing.  CODE:


same => n(IVRInteractiveStart),Verbose(Dialplan continues here)
;
; ...redacted...
;
same => n,Hangup()




/CODE.




You'll have to tell me more about your phones to know what you are doing with called user prompts.  You can enter the numbers into the DBs manually from the console using the DB commands: https://wiki.asterisk.org/wiki/display/AST/Asterisk+Internal+Database


I hope this makes sense...




Second part:




One more thing, I didn't mention when I cut down the code, which is good food for thought - I also have a "whitelist" for friends and family.  This is the better way for a public facing phone number, people you know who will call you, you can skip most of the boring stuff if you "trust" the source phone number.

I do call screening on all incoming calls, unless they are on the whitelist.  How that works is similar, I screen once if it's a new number, and the file-name of the name they said during the screening recording is saved to the the whitelist DB as:


CODE:


same=>n,Set(DB(whitelist\${CALLERID(num)}=${FILENAMEASVALUE}))


/CODE


That way when I get connected the next time they call, I get a phone call from the home phone system, and instead of playing the screening prompt, I get: "Connecting you to {recorded name}"


For a custom find-me-follow-me function, I wrote a menu that uses the 5 options:
1 = Connect me
2 = Connect me, add to whitelist
5 = Send to my Voicemail
7 = Add to Telemarketer list
9 = Add to Blacklist


That's done in a Macro and you could do that with basically any phone.  So my basic process (with several omissions) is:


* New Incoming call
* Set up and filter variables
* Start a recording
* If it's a toll-free, do a "captcha" human-test
* Check if they are on the whitelist, if they are skip to the IVR

* Get rid of the new "easy" telemarketers
* Check if they are on the blacklist, get rid of them if they are
* Check if they are a known Telemarketer, get rid of them if they are
* Ask for the extension/user

* On user answer, If on the whitelist connect, if not screen
* If no answer, take a message.


-T




END OF REPOST...


Thread should be caught back up now (again, very sorry!!!).


I hadn't gotten to the Macro, as John hasn't responded yet anyway.



Kevin what phones are you using?  Depending on how your phones work, there are various way to get this to happen.


If your phones don't have hot keys, a quick and dirty way to "kiss-off" unwanted callers is to create an extension that an internal-called-user can transfer the caller to.  You can even use a "dumb" touch-tone phone that way.


Best,


-Tim




On Mon, Aug 29, 2016 at 2:31 PM, <kc6ovd@gmail.com (kc6ovd@gmail.com)> wrote:
Quote:

Tim, I would like to see the code for this. I also am a home user and I have been thinking of how I would do this same type of thing. Right now I have a black list db and it is manual. When the unwanted caller calls they go to a no one is here go away message and splash they are gone.  Your method and hot keys sounds very cool.
 
-Kevin
 
Sent from Mail for Windows 10
 
From: Tim S (tim.strommen@gmail.com)
Sent: Monday, August 29, 2016 12:40 PM
To: Asterisk Users Mailing List - Non-Commercial Discussion (asterisk-users@lists.digium.com)
Subject: [asterisk-users] Blacklist callers from file

 
I'm a home user (not business), but I implemented a blacklist function too after a harassing call to my wife.
 

Using the Asterisk DB functions, I have a caller ID look-up function before my IVR-tree starts, a simple if then.  Lookup caller ID in blocked-caller DB, if found then I kick them to a short dialplan the plays a message telling them they've been blocked, then lets them record an "appeal" message.  If a user put someone in the Blocked DB, by accident, I'd want to have a way for someone to report it to me via phone.

 

To add a number to the Blocked DB, the caller internal user is allowed a hot-key on the phone to block the caller in-call, or with screening they are given an option in the prompt.  When a new number is added to the Blocked DB, the call recording for the session is retained to be able to remember why it was blocked.  The Blocked DB will automatically unblock an entry after a year, to account for number changes, but the entry can be extended before it expires via an email response.

 

I did a similar thing for Telemarketers, the phone numbers also automatically unblock, but only after a month, as most of the worst offenders I've come across don't stay with a phone number longer than a few weeks to avoid enforcement by the FTC.  For that I also have a hot key on the phones for "Telemarketer Goodbye", which adds to the DB while playing a "Remove me from your list and stop bothering me" message.  This gives my users a bit of power as they don't have to be polite, or think of an evasion to the sales person, they just need to push a button and hang up the phone when they realize is a sales call.

 

I didn't want to publish code for this since it's a bit long winded, but it should give you some ideas of things you want to consider.

 

Best,

 

-Tim

 

 
On Mon, Aug 29, 2016 at 9:20 AM, John Kiniston <johnkiniston@gmail.com (johnkiniston@gmail.com)> wrote:
Quote:

Here is a quick and dirty bash script to do it that I wrote you.

#!/bin/bash
if ( asterisk -rx "database deltree blacklist")
        then
                echo "Blacklist Cleared"
        else
                err "ERROR Failed to clear Blacklist, Exiting."
                exit 1;
fi

while IFS=, read TN REASON
do
if ( asterisk -rx "database put blacklist \"${TN}\" \"${REASON}\"")
   then
           echo "Inserted $TN $REASON to Blacklist"
   else
         err "ERROR Insert Failed on $TN."
         exit 1;
fi

done < blacklist.csv
unset IFS



It reads from the file blacklist.csv in the same directory with the format of NUMBER,"DESCRIPTION/REASON"

 
On Sat, Aug 27, 2016 at 8:59 AM, tux john <atux@null.net (atux@null.net)> wrote:
Quote:

Hi. I would like to blacklist a few callers and I have been using the *CLI> database put blacklist 1234 "annoying callers". Instead of putting the same command for every user is there any way to have a file? Ideally a file in /opt that I would update the blacklisted numbers (add,remove). Is there anything like that, please?

--
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --

Join the Asterisk Community at the 13th AstriCon, September 27-29, 2016
      http://www.asterisk.org/community/astricon-user-conference

New to Asterisk? Start here:
      https://wiki.asterisk.org/wiki/display/AST/Getting+Started

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users




--
A human being should be able to change a diaper, plan an invasion, butcher a hog, conn a ship, design a building, write a sonnet, balance accounts, build a wall, set a bone, comfort the dying, take orders, give orders, cooperate, act alone, solve equations, analyze a new problem, pitch manure, program a computer, cook a tasty meal, fight efficiently, die gallantly. Specialization is for insects.
---Heinlein



--
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --

Join the Asterisk Community at the 13th AstriCon, September 27-29, 2016
      http://www.asterisk.org/community/astricon-user-conference

New to Asterisk? Start here:
      https://wiki.asterisk.org/wiki/display/AST/Getting+Started

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users





 
 



Back to top
tim.strommen at gmail.com
Guest





PostPosted: Tue Aug 30, 2016 11:09 am    Post subject: [asterisk-users] Blacklist callers from file Reply with quote

Hi Kevin,


Looks like your gmail did the same thing mine did, took the conversation off-list (unless you meant to do that).

If as you mention you're running a mix of POTS and SIP, I'd recommend sticking with the transfer call method (set the hook/trigger in the features.conf file).  That way if anyone picks up ANY phone in your house they have a consistent procedure for dealing with those calls.  It will add to the confidence of your users and will score points with wife not having to learn and remember several procedures - a label with the hint would go a long way here.


That's what I'll be doing for my aging parents, who feel helpless to the effect of the bothersome calls, and don't want a complicated solution to the issue.




-Tim
Back to top
mailinglist at linuxis...
Guest





PostPosted: Wed Aug 31, 2016 4:02 am    Post subject: [asterisk-users] Blacklist callers from file Reply with quote

On Sat, 2016-08-27 at 17:59 +0200, tux john wrote:

Quote:
Hi. I would like to blacklist a few callers

Example: callers with CallerID 0123456789, 9876543210 and 7410258963 are
sent to tt-monkeys. Callers from area code 555 are also blocked.


In "extensions.conf" file add

#include "blacklist.conf"


In "blacklist.conf"

exten => s/0123456789,1,playback(tt-monkeys)

exten => s/9876543210,1,playback(tt-monkeys)

exten => s/7410258963,1,playback(tt-monkeys)

exten => s/_555XXXXXXX,1,playback(tt-monkeys)

....
...
..
.




--
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --

Join the Asterisk Community at the 13th AstriCon, September 27-29, 2016
http://www.asterisk.org/community/astricon-user-conference

New to Asterisk? Start here:
https://wiki.asterisk.org/wiki/display/AST/Getting+Started

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/asterisk-users
Back to top
Display posts from previous:   
Post new topic   Reply to topic    VoIP Mailing List Archives Forum Index -> Asterisk Users All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group

VoiceMeUp - Corporate & Wholesale VoIP Services