Esempio n. 1
0
 def _update_tracker_db(self):
     """Update Trackers DB."""
     try:
         if not is_internet_available():
             logger.warning('No Internet Connection. '
                            'Skipping Trackers Database Update.')
             return
         resp = update_local_db('Trackers', settings.TRACKERS_DB_URL,
                                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')
Esempio n. 2
0
 def update_maltrail_db(self):
     """Check for update in maltrail DB."""
     try:
         mal_db = self.maltrail
         resp = update_local_db('Maltrail', settings.MALTRAIL_DB_URL,
                                mal_db)
         if not resp:
             return
         # DB needs update
         # Check2: DB Syntax Changed
         lines = resp.decode('utf-8', 'ignore').splitlines()
         if len(lines) > 100:
             logger.info('Updating Maltrail Database')
             with open(mal_db, 'wb') as wfp:
                 wfp.write(resp)
         else:
             logger.warning('Unable to Update Maltrail DB')
     except Exception:
         logger.exception('[ERROR] Maltrail DB Update')
def update_malware_db():
    """Check for update in malware DB."""
    try:
        mal_db = os.path.join(MALWARE_DB_DIR, 'malwaredomainlist')
        resp = update_local_db('Malware', settings.MALWARE_DB_URL, mal_db)
        if (resp):
            # DB needs update
            # Check2: DB Syntax Changed
            line = resp.decode('utf-8', 'ignore').split('\n')[0]
            lst = line.split('",')
            if len(lst) == 10:
                # DB Format is not changed. Let's update DB
                logger.info('Updating Malware Database....')
                with open(mal_db, 'wb') as wfp:
                    wfp.write(resp)
            else:
                logger.warning('Unable to Update Malware DB')
    except Exception:
        logger.exception('[ERROR] Malware DB Update')
def update_malware_db():
    """Check for update in malware DB."""
    try:
        mal_db = os.path.join(MALWARE_DB_DIR, 'malwaredomainlist')
        resp = update_local_db('Malware', settings.MALWARE_DB_URL, mal_db)
        if (resp):
            # DB needs update
            # Check2: DB Syntax Changed
            line = resp.decode('utf-8', 'ignore').split('\n')[0]
            lst = line.split('",')
            if len(lst) == 10:
                # DB Format is not changed. Let's update DB
                logger.info('Updating Malware Database....')
                with open(mal_db, 'wb') as wfp:
                    wfp.write(resp)
            else:
                logger.info('Malware Database format from '
                            'malwaredomainlist.com has changed.'
                            ' Database is not updated. '
                            'Please report to: https://github.com/'
                            'MobSF/Mobile-Security-Framework-MobSF/issues')
    except Exception:
        logger.exception('[ERROR] Malware DB Update')