def _update_tracker_db(self):
     """Update Trackers DB."""
     try:
         if not is_internet_available():
             logger.warning('No Internet Connection. '
                            'Skipping Trackers Database Update.')
             return
         exodus_db = '{}/api/trackers'.format(settings.EXODUS_URL)
         resp = update_local_db('Trackers', exodus_db, self.tracker_db)
         # Check1: SHA256 Change
         if resp:
             # DB needs update
             # Check2: DB Syntax Changed
             data = json.loads(resp.decode('utf-8', 'ignore'))
             is_db_format_good = False
             if 'trackers' in data:
                 if '1' in data['trackers']:
                     if 'code_signature' in data['trackers']['1']:
                         is_db_format_good = True
             if is_db_format_good:
                 # DB Format is not changed. Let's update DB
                 logger.info('Updating Trackers Database....')
                 with open(self.tracker_db, 'wb') as wfp:
                     wfp.write(resp)
             else:
                 logger.info('Trackers Database format from '
                             'reports.exodus-privacy.eu.org has changed.'
                             ' Database is not updated. '
                             'Please report to: https://github.com/MobSF/'
                             'Mobile-Security-Framework-MobSF/issues')
     except Exception:
         logger.exception('[ERROR] Trackers DB Update')
def update_frida_server(arch, version):
    """Download Assets of a given version."""
    download_dir = Path(settings.DWD_DIR)
    fserver = f'frida-server-{version}-android-{arch}'
    frida_bin = download_dir / fserver
    if frida_bin.is_file():
        return True
    if not is_internet_available():
        return False
    try:
        proxies, verify = upstream_proxy('https')
    except Exception:
        logger.exception('[ERROR] Setting upstream proxy')
    try:
        response = requests.get(f'{settings.FRIDA_SERVER}{version}',
                                timeout=3,
                                proxies=proxies,
                                verify=verify)
        for item in response.json()['assets']:
            if item['name'] == f'{fserver}.xz':
                url = item['browser_download_url']
                return download_frida_server(url, version, fserver)
        return False
    except Exception:
        logger.exception('[ERROR] Fetching Frida Server Release')
    return False
 def update(self):
     if is_internet_available():
         self.update_malware_db()
         self.update_maltrail_db()
     else:
         logger.warning('Internet not available. '
                        'Skipping Malware Database Update.')