Deprecated: Creation of dynamic property Timber\Site::$pingback is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Site.php on line 180

Deprecated: Creation of dynamic property Timber\User::$name is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/User.php on line 118

Deprecated: Creation of dynamic property Timber\Post::$has_disclaimer is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_edit_lock is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_edit_last is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$onesignal_meta_box_present is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$onesignal_send_notification is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$onesignal_modify_title_and_content is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$onesignal_notification_custom_heading is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$onesignal_notification_custom_content is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$tipologia is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_tipologia is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$attributi is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_attributi is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$in_evidenza_newsletter is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_in_evidenza_newsletter is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$inviato_in_newsletter is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_inviato_in_newsletter is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_yoast_wpseo_primary_category is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_yoast_wpseo_primary_blz_affiliation_attributes is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_yoast_wpseo_primary_content_type is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_yoast_wpseo_primary_attributes is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_yoast_wpseo_primary_speciali is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_yoast_wpseo_content_score is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_yoast_wpseo_focuskeywords is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_yoast_wpseo_keywordsynonyms is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_yoast_wpseo_estimated-reading-time-minutes is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_yoast_wpseo_wordproof_timestamp is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_yoast_wpseo_focuskw is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_yoast_wpseo_metadesc is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_yoast_wpseo_linkdex is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_thumbnail_id is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$response_body is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$status is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_yoast_indexnow_last_ping is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_oembed_8df0457993a63fcb557a930354673dcb is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_oembed_time_8df0457993a63fcb557a930354673dcb is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$post_date_gmt is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$comment_status is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$ping_status is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$post_password is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$post_name is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$to_ping is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$pinged is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$post_modified is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$post_modified_gmt is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$post_content_filtered is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$guid is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$menu_order is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$post_mime_type is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$comment_count is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$filter is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71
Perché il FRITZ!Box potrebbe essere il miglior alleato contro le chiamate indesiderate: la sfida dell'estate | IlSoftware.it

Perché il FRITZ!Box potrebbe essere il miglior alleato contro le chiamate indesiderate: la sfida dell'estate

Come monitorare le chiamate in arrivo con FRITZ!Box, il protocollo TR-064 e un semplice script Python. Il router AVM avrebbe il potenziale di diventare un efficacissimo strumento contro le chiamate indesiderate. C'è però un "neo" non da poco: lo spieghiamo nel nostro articolo.
Perché il FRITZ!Box potrebbe essere il miglior alleato contro le chiamate indesiderate: la sfida dell'estate

Uno dei fiori all’occhio dei router FRITZ!Box è senza dubbio la loro completa e solida gestione delle chiamate telefoniche: VoIP, ISDN/PSTN che siano, i dispositivi di AVM offrono caratteristiche avanzate per la gestione della telefonia. I FRITZ!Box offrono funzionalità di centralino virtuale, permettendo la configurazione di diversi profili utente con servizi come segreteria telefonica, trasferimenti di chiamata, deviazioni e gestione delle chiamate in entrata e in uscita. L’integrazione con la rubrica facilita la gestione dei contatti mentre il monitoraggio delle chiamate è un ottimo alleato contro le chiamate indesiderate.

I dettagli sulle chiamate in entrata (numero identificativo del chiamate o CID, Caller ID, compreso) consentono di impostare regole per il blocco o il filtraggio delle chiamate spam. Peccato, però, che allo stato attuale i router FRITZ!Box basino le loro funzionalità di blocco delle numerazioni indesiderate su elenchi composti dall’utente o acquisibili da parte di soggetti terzi (di solito a pagamento). Queste rubriche contenenti numeri telefonici da bloccare sono solitamente distribuite in formato CardDAV e possono essere importate nell’interfaccia del FRITZ!Box specificando un apposito URL.

La nostra idea di un FRITZ!Box capace di bloccare tutte le chiamate indesiderate

Dicevamo in apertura che i router FRITZ!Box sono particolarmente abili nella gestione della sezione telefonica e offrono funzionalità spesso assenti in altri prodotti. Il supporto del protocollo TR-064 da parte dei dispositivi AVM è una caratteristica eccezionale perché apre le porte alla gestione tramite script e procedure automatizzate. La documentazione AVM contiene riferimenti a centinaia di chiamate SOAP (Simple Object Access Protocol), un protocollo di comunicazione basato su XML utilizzato per scambiare informazioni strutturate.

Sfruttando questa piattaforma, la nostra idea era quella di sviluppare uno script Python per monitorare in background le chiamate in arrivo e verificare in tempo reale quali sono telefonate indesiderate, da rigettare immediatamente.

Come monitorare le chiamate in arrivo sul FRITZ!Box

FritzMonitor è un modulo Python che consente di monitorare gli eventi generatisi su un router FRITZ!Box. Utilizzando un sistema Linux collegato con la stessa rete locale ove il router FRITZ!Box risulta installato, è possibile monitorare le chiamate in arrivo. Il bello è che il codice Python che abbiamo sviluppato potrebbe funzionare anche su una compatta scheda Raspberry Pi (e può essere eventualmente eseguito in una macchina WSL, in ambiente Windows).

Supponendo di aver già installato Python, per usare FritzMonitor è sufficiente impartire il comando seguente:

pip install fritzconnection

A questo punto, è sufficiente creare un nuovo file chiamato cid.py :

nano cid.py

Lo script Python che rileva le chiamate indesiderate

Il codice seguente attiva una connessione con il router FRITZ!Box installato in rete locale (nel nostro caso ha IP 192.168.0.1) quindi si mette in ascolto per le chiamate in arrivo sul dispositivo, visualizzandone in tempo reale il CID corrispondente. Nello specifico, il modulo riceve una notifica ogni volta che si verifica un evento sul router, ad esempio una chiamata in entrata o in uscita.

import queue
import requests
from bs4 import BeautifulSoup
from fritzconnection import FritzMonitor

def check_spam(cid):
    urls = [
        f"URL_PRIMO_SERVIZIO_ANTISPAM_TELEFONICO/{cid}",
        f"URL_SECONDO_SERVIZIO_ANTISPAM_TELEFONICO/{cid}"
    ]
    keywords = ["truffa", "telemarketing", "negativa"]

    for url in urls:
        try:
            # Effettua una richiesta GET al URL specificato
            response = requests.get(url)
            if response.status_code == 200:
                # Limita la lettura dell'HTML alle prime 200 righe
                html_content = response.content.decode(response.encoding)
                first_200_lines = "\n".join(html_content.splitlines()[:200])
                
                # Analizza il contenuto HTML limitato
                soup = BeautifulSoup(first_200_lines, 'html.parser')
                text = soup.get_text().lower()
                if any(keyword in text for keyword in keywords):
                    return True  # Trovato SPAM
        except requests.exceptions.RequestException as e:
            print(f"Errore durante la richiesta a {url}: {e}")

    return False  # Nessun segnale di SPAM trovato

def process_events(monitor, event_queue):
    while True:
        try:
            event = event_queue.get(timeout=10)
        except queue.Empty:
            # Nessun evento da processare
            pass
        else:
            # Elabora l'evento di chiamata
            event_parts = event.split(";")
            if event_parts[1] == "RING":
                # Chiamata in arrivo
                calling_number = event_parts[3]
                print(f"Chiamata in arrivo da: {calling_number}")
                
                # Controlla se il numero è segnalato come SPAM
                if check_spam(calling_number):
                    print(f"{calling_number} è segnalato come SPAM!")
                else:
                    print(f"{calling_number} non è segnalato come SPAM.")
                    
def main():
    try:
        # Indirizzo IP del router FRITZ!Box
        router_address = "192.168.0.1"

        # Crea un'istanza di FritzMonitor
        with FritzMonitor(address=router_address) as monitor:
            event_queue = monitor.start()
            process_events(monitor, event_queue)
    except (OSError, KeyboardInterrupt) as err:
        print(f"Errore: {err}")

if __name__ == "__main__":
    main()

La funzione process_events() è responsabile dell’elaborazione degli eventi di chiamata in arrivo sul router FRITZ!Box. Il ciclo infinito while True permette di restare in ascolto e gestire tutti gli eventi in arrivo. Controllando se il secondo campo che contraddistingue l’evento è RING, è possibile sapere il momento esatto in cui il FRITZ!Box riceve una chiamata.

La successiva funzione check_spam controlla se il numero di telefono del chiamante è segnalato come SPAM sui siti Web specifici (inviando un’apposita query HTTPS).

Come attivare la funzionalità di monitoraggio delle chiamate

Il codice Python proposto poco sopra non fornisce alcun riscontro se prima non si provvede ad attivare il servizio CallMonitor sul FRITZ!Box.

Per procedere in tal senso, è necessario afferrare un telefono collegato con il router FRITZ!Box quindi comporre il seguente codice speciale: #96*5*

Nel caso in cui, in seguito, si volesse disattivare il servizio, basta comporre il codice telefonico seguente: #96*4*

Funziona tutto, tranne per il fatto che non è possibile rifiutare la chiamata spam

Digitando python3 cid.py, è possibile porre in ascolto lo script ed esaminare l’identità del chiamante, per ogni singola telefonata gestita dal FRITZ!Box. Come si vede, il meccanismo che abbiamo approntato riesce a rilevare alla perfezione quali telefonate sono poste in essere da spammer e scammer:

Chiamate indesiderate FRITZ!Box

Blocco chiamate spam FRITZ!Box

Qual è l’unico problema che, purtroppo, permane? Incredibile ma vero, allo stato attuale AVM sembra non fornire una chiamata SOAP specifica che permetta di rifiutare una chiamata in tempo reale. Abbiamo spulciato la documentazione, effettuato mille prove e provato alcuni workaround. Allo stato attuale, come confermato a questo indirizzo, non sembra esserci modo per disconnettere una chiamata in arrivo, quando si trova nello stato “RING”.

Una soluzione potrebbe essere quella di forzare una deviazione su un interno inesistente in modo tale impedire la prosecuzione degli squilli sulla numerazione gestita con il FRITZ!Box. Al momento, tuttavia, non sembra possibile farlo. Insomma, se avete idee potrebbe essere la sfida dell’estate, come scriviamo nel titolo.

L’immagine in apertura è tratta da AVM.

Ti consigliamo anche

Link copiato negli appunti