[HowTo] Block unwanted calls - create blacklist
-
@br1 Well, next OTA is not a thing to worry about for a while ^^ I think I'll use that script for now. But yeah, GUI implementation is a must. You're the best !
-
@moem This is a hack, let it stay hacky (you can't really solve the OTA problem, but @kugiigi has a "hack manager" that would at least make it a bit safer)
A proper solution is to do what Sailfish did (literally, using their implementation) - there might even be a GUI for it somewhere waiting for focal
Security stuff
The
visudo
change means that anyone can rundbus-monitor
without entering a password - this is super unsafe as it would allow anyone with access to the device shell (ssh, adb, the terminal app or any unconfined app) to listen in on all dbus traffic (and afaik the keyboard sends keystrokes using dbus) -
@klh said in [HowTo] Block unwanted calls - create blacklist:
@moem This is a hack, let it stay hacky
Fair enough! No call blocking for me, then... for now.
-
this is super unsafe as it would allow anyone with access to the device shell (ssh, adb, the terminal app or any unconfined app) to listen in on all dbus traffic
adb and terminal app require physical access to the device(if someone has your device you already have a bigger problem) ssh with private key is safe, in my opinion the risk is very low ... everyone can evaluate risks and benefits.
-
@br1 Which is why I posted what the risks are - this is not mentioned in the original post. It's still much safer than paying for an unconfined proprietary app
Also, since you already have to mess with the rootfs and run it as root, you might as well move the upstart job to /etc/init and not mess with the sudoers file.
-
--------- update ---------
To fix security issue mentioned by @klh, I have created an init.d service.
-
Create a new contact and call it SPAM, add to it the numbers you want to block
-
First script
nano /home/phablet/.myscripts/calls_blocker.sh
and make it executable (chmod u+x)
#!/bin/bash # Intercepts every incoming call addressed to SPAM contact and terminates it interface=org.freedesktop.DBus.Properties member=Set dbus-monitor --system interface=$interface member=$member | awk '/SPAM/ { system("dbus-send --system --print-reply --dest=org.ofono /ril_0/voicecall01 org.ofono.VoiceCall.Hangup") 1>/dev/null }'
- Second script
nano /home/phablet/.myscripts/stop_blocker.sh
(chmod u+x)
#!/bin/bash # stop process gracefully pkill dbus-monitor exit
- mount system in rw mode
sudo mount -o remount,rw /
- create service
sudo nano /etc/init.d/blacklist
and set permissions (sudo chmod 755)
#! /bin/bash ### BEGIN INIT INFO # Provides: blacklist # Required-Start: dbus # Required-Stop: dbus # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Blocks calls # Description: Daemon that blocks unwanted calls ### END INIT INFO # Written by Br1 <br1@spacelinux.it> case "$1" in start) echo "Starting blacklist service ..." bash -c 'cd /home/phablet/.aa_myscripts/ && ./calls_blocker.sh &' ;; stop) echo "Stopping blacklist service ..." bash -c 'cd /home/phablet/.aa_myscripts/ && ./stop_blocker.sh &' sleep 2 ;; *) echo "Usage: /etc/init.d/blacklist {start|stop}" exit 1 ;; esac exit 0
- start or stop service with
sudo service blacklist start # or sudo service blacklist stop
- enable service auto start on boot up
sudo update-rc.d blacklist defaults
- if you want disable service auto start on boot up
sudo update-rc.d -f blacklist remove
- check if service/dbus-monitor is running
ps -e | grep dbus-monitor
-
-
-
-
-
-
-
@br1 Thanks it works perfectly
-
The problem is the battery consumption, it lasts 2 hours with the scripts activated on my nexus.
-
@joao-0 u sure it's the script ? Nexus has catastrophic battery life
-
@emphrath yes I am sure
-
-
--------- UPDATE ---------
New version to install/uninstall with single command, see here for further information.The old version has to be manually uninstalled before.
There are no new features but should be running much faster and draw less battery power (*)
three steps :
1 - download (just click) blacklist.1.01.tar.gz from here
2 - open file manager, go to Downloads click blacklist.1.01.tar.gz and extract archive
3 - open terminal and type :
sudo /home/phablet/Downloads/blacklist.1.01/blist-install
type 1 to install
type 2 to uninstall
type 3 to exitThat's all.
Preview of install/uninstall script (blist-install) :
#!/bin/bash BLSERV=/etc/init.d/blacklist ; # Make sure only root can run this script if [ "$(id -u)" != "0" ]; then echo " Must be run as root, you must prepend sudo !" 1>&2 ; exit 1 fi echo -e '\n - Install/uninstall BlackList :\n' ; PS3='Please enter your choice : ' options=("Install" "Uninstall" "Quit") select opt in "${options[@]}" do case $opt in "Install") echo -e '\n Installation in progress ...\n' ; # change the working directory cd /home/phablet/Downloads/blacklist.1.01/ ; # create directory mkdir -p /home/phablet/.blacklist ; # copy scripts to directory just created cp *.sh /home/phablet/.blacklist/ ; # mount root in read/write mode mount -o remount,rw / ; # copy blacklist service cp blacklist /etc/init.d/ ; # enable autostart update-rc.d blacklist defaults ; # start service service blacklist start # roll back root in read only mode mount -o remount,ro / ; echo -e '\n Done, Blacklist installed !\n' exit 0 ;; "Uninstall") # check status if [ ! -f "$BLSERV" ]; then echo -e '\n Blacklist is not installed !\n' ; else # mount root in read/write mode mount -o remount,rw / ; # stop blacklist service, disable autostart and remove file service blacklist stop ; update-rc.d -f blacklist remove ; rm /etc/init.d/blacklist ; # roll back root in read only mode mount -o remount,ro / ; # delete scripts and remove directory rm -rf /home/phablet/.blacklist/* ; rmdir /home/phablet/.blacklist ; echo -e '\n Blacklist uninstalled !\n' exit 0 fi ;; "Quit") exit 0 ;; *) echo "invalid option $REPLY" ;; esac done
- small changes to make more efficient the script (now named sr-kill.sh) useful to stop blacklist service from command line :
#!/bin/sh # stop blacklist service # get pid of the script scPID=$(pidof -x calls_blocker.sh) # kill script and child processes pkill -P $scPID exit
(*) Now the always running script (calls_blocker.sh) is executed by dash shell which is much faster and requires fewer resources than bash shell, see benchmark , here is the preview :
#!/bin/sh # Intercepts every incoming call addressed to SPAM contact and terminates it interface=org.freedesktop.DBus.Properties member=Set sudo dbus-monitor --system interface=$interface member=$member | awk '/SPAM/ { system("dbus-send --system --print-reply --dest=org.ofono /ril_0/voicecall01 org.ofono.VoiceCall.Hangup") }' >/dev/null 2>&1
-
This post is deleted! -
This post is deleted! -
Hello the program works perfectly. The autonomy is frankly superior to the old version, the application consumes 9% per hour on my nexus 5 with a new battery. Without the appication my nexus 5 consumes 3% per hour. It's a bit fair but as you say the nexus has a limited basic autonomy.
Thanks, great job. -
OTA-25 --- You can reinstall, no changes are necessary.
-
---- UPDATE OTA-2 Focal ----
---- Stable Channel ----Usual three steps :
1 - download (just tap) blacklist-ota.2 from here
2 - open file manager, go to Downloads tap blacklist-ota.2.tar.gz and tap extract archive
3 - open terminal, type :
sudo Downloads/blacklist-ota.2/blist-install
and hit enter,
type 1 + enter to install
type 2 + enter to uninstall
reboot not required.
Blacklist only consist of three files :
preview of blist-install :
#!/bin/bash BLSERV=/usr/lib/systemd/system/blacklist.service ; # Make sure only root can run this script if [ "$(id -u)" != "0" ]; then echo " Must be run as root, you must prepend sudo !" 1>&2 ; exit 1 fi echo -e '\n - Install-Uninstall BlackList :\n' ; PS3=$' Please enter your choice : ' options=(" Install - " " Uninstall - " " Quit - ") select opt in "${options[@]}" do case $opt in " Install - ") echo -e '\n Installation in progress ...\n' ; # change the working directory cd /home/phablet/Downloads/blacklist-ota.2/ ; # create directory mkdir -p /home/phablet/.blacklist ; # copy scripts to directory just created cp calls_blocker.sh /home/phablet/.blacklist/ ; # mount root in read/write mode mount -o remount,rw / ; # copy blacklist service cp blacklist.service /usr/lib/systemd/system/ ; # enable and start service systemctl enable --now blacklist > /dev/null 2>&1 ; # roll back root in read only mode mount -o remount,ro / ; echo -e '\n Done, Blacklist installed !\n' exit 0 ;; " Uninstall - ") # check status if [ ! -f "$BLSERV" ]; then echo -e '\n Blacklist is not installed !\n' ; else # mount root in read/write mode mount -o remount,rw / ; # stop and disable blacklist service systemctl disable --now blacklist > /dev/null 2>&1 ; # remove file rm /usr/lib/systemd/system/blacklist.service ; # roll back root in read only mode mount -o remount,ro / ; # delete scripts and remove directory rm -rf /home/phablet/.blacklist/* ; rmdir /home/phablet/.blacklist ; echo -e '\n Blacklist uninstalled !\n' exit 0 fi ;; " Quit - ") echo -e '\n - OS unchanged !\n' exit 0 ;; *) echo "invalid option $REPLY" ;; esac done
preview of blacklist.service :
[Unit] Description=Calls Blacklist [Service] Type=simple ExecStart=/home/phablet/.blacklist/calls_blocker.sh RemainAfterExit=yes [Install] WantedBy=multi-user.target
calls_blocker.sh script has not changed.
The script to stop service is no longer necessary, blacklist now is a systemd service and can be managed with systemctl commands, example :
systemctl stop blacklist
improved legibility :
-
I canβt test ota 3 update, install at your own risk. -
OTA 3 Stable channel --- You can reinstall, no changes are necessary.
-
Blacklist also work fine with OTA 4.
-