Esempio n. 1
0
def update_malware_db():
    """Check for update in malware DB"""
    try:
        proxies, verify = upstream_proxy('http')
    except:
        PrintException("[ERROR] Setting upstream proxy")
    try:
        url = "http://www.malwaredomainlist.com/mdlcsv.php"
        response = requests.get(url, timeout=3, proxies=proxies, verify=verify)
        data = response.content
        tmp_dwd = tempfile.NamedTemporaryFile()
        tmp_dwd.write(data)
        mal_db = os.path.join(MALWARE_DB_DIR, 'malwaredomainlist')
        tmp_dwd.seek(0)
        # Check1: SHA256 Change
        if sha256(tmp_dwd.name) != sha256(mal_db):
            # DB needs update
            # Check2: DB Syntax Changed
            line = tmp_dwd.readline().decode("utf-8", "ignore")
            lst = line.split('",')
            if len(lst) == 10:
                # DB Format is not changed. Let's update DB
                print("\n[INFO] Updating Malware Database....")
                shutil.copyfile(tmp_dwd.name, mal_db)
            else:
                print("\n[WARNING] Malware Database format from malwaredomainlist.com changed. Database is not updated. Please report to: https://github.com/MobSF/Mobile-Security-Framework-MobSF/issues")
        else:
            print("\n[INFO] Malware Database is up-to-date.")
        tmp_dwd.close()
    except:
        PrintException("[ERROR] Malware DB Update")
def UpdateDB():
    try:
        url = "https://www.malwaredomainlist.com/mdlcsv.php"
        response = urllib2.urlopen(url)
        data = response.read()
        TMP_DWD = tempfile.NamedTemporaryFile()
        TMP_DWD.write(data)
        DB = os.path.join(MALWARE_DB_DIR, 'malwaredomainlist')
        # Check1: SHA256 Change
        if sha256(TMP_DWD.name) != sha256(DB):
            # DB needs update
            # Check2: DB Syntax Changed
            rd = io.open(TMP_DWD.name, mode='r',
                         encoding="utf8", errors="ignore")
            line = rd.readline()
            rd.close()
            lst = line.split('",')
            if len(lst) == 10:
                # DB Format is not changed. Let's update DB
                print "\n[INFO] Updating Malware Database...."
                shutil.copyfile(TMP_DWD.name, DB)
            else:
                print "\n[WARNING] Malware Database format from malwaredomainlist.com changed. Database is not updated. Please report to: https://github.com/ajinabraham/Mobile-Security-Framework-MobSF/issues"
        else:
            print "\n[INFO] Malware Database is up-to-date."
        TMP_DWD.close()
    except:
        PrintException("[ERROR] Malware DB Update")
Esempio n. 3
0
def UpdateDB():
    try:
        url = "https://www.malwaredomainlist.com/mdlcsv.php"
        response = urllib2.urlopen(url)
        data = response.read()
        TMP_DWD = tempfile.NamedTemporaryFile()
        TMP_DWD.write(data)
        DB = os.path.join(MALWARE_DB_DIR, 'malwaredomainlist')
        # Check1: SHA256 Change
        if sha256(TMP_DWD.name) != sha256(DB):
            # DB needs update
            # Check2: DB Syntax Changed
            rd = io.open(TMP_DWD.name, mode='r',
                         encoding="utf8", errors="ignore")
            line = rd.readline()
            rd.close()
            lst = line.split('",')
            if len(lst) == 10:
                # DB Format is not changed. Let's update DB
                print "\n[INFO] Updating Malware Database...."
                shutil.copyfile(TMP_DWD.name, DB)
            else:
                print "\n[WARNING] Malware Database format from malwaredomainlist.com changed. Database is not updated. Please report to: https://github.com/MobSF/Mobile-Security-Framework-MobSF/issues"
        else:
            print "\n[INFO] Malware Database is up-to-date."
        TMP_DWD.close()
    except:
        PrintException("[ERROR] Malware DB Update")
def update_malware_db():
    """Check for update in malware DB."""
    try:
        proxies, verify = upstream_proxy('http')
    except Exception:
        logger.exception('[ERROR] Setting upstream proxy')
    try:
        url = settings.MALWARE_DB_URL
        response = requests.get(url, timeout=3, proxies=proxies, verify=verify)
        data = response.content
        tmp_dwd = tempfile.NamedTemporaryFile()
        tmp_dwd.write(data)
        mal_db = os.path.join(MALWARE_DB_DIR, 'malwaredomainlist')
        tmp_dwd.seek(0)
        # Check1: SHA256 Change
        if sha256(tmp_dwd.name) != sha256(mal_db):
            # DB needs update
            # Check2: DB Syntax Changed
            line = tmp_dwd.readline().decode('utf-8', 'ignore')
            lst = line.split('",')
            if len(lst) == 10:
                # DB Format is not changed. Let's update DB
                logger.info('Updating Malware Database....')
                shutil.copyfile(tmp_dwd.name, mal_db)
            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')
        else:
            logger.info('Malware Database is up-to-date.')
        tmp_dwd.close()
    except Exception:
        logger.exception('[ERROR] Malware DB Update')
def update_malware_db():
    """Check for update in malware DB"""
    try:
        proxies, verify = upstream_proxy('http')
    except:
        PrintException("[ERROR] Setting upstream proxy")
    try:
        url = "http://www.malwaredomainlist.com/mdlcsv.php"
        response = requests.get(url, timeout=3, proxies=proxies, verify=verify)
        data = response.content
        tmp_dwd = tempfile.NamedTemporaryFile()
        tmp_dwd.write(data)
        mal_db = os.path.join(MALWARE_DB_DIR, 'malwaredomainlist')
        tmp_dwd.seek(0)
        # Check1: SHA256 Change
        if sha256(tmp_dwd.name) != sha256(mal_db):
            # DB needs update
            # Check2: DB Syntax Changed
            line = tmp_dwd.readline().decode("utf-8", "ignore")
            lst = line.split('",')
            if len(lst) == 10:
                # DB Format is not changed. Let's update DB
                logger.info("Updating Malware Database....")
                shutil.copyfile(tmp_dwd.name, mal_db)
            else:
                logger.info("Malware Database format from malwaredomainlist.com changed. Database is not updated. "
                            "Please report to: https://github.com/MobSF/Mobile-Security-Framework-MobSF/issues")
        else:
            logger.info("Malware Database is up-to-date.")
        tmp_dwd.close()
    except:
        PrintException("[ERROR] Malware DB Update")
def update_malware_db():
    """Check for update in malware DB"""
    try:
        url = "https://www.malwaredomainlist.com/mdlcsv.php"
        response = urllib2.urlopen(url)
        data = response.read()
        tmp_dwd = tempfile.NamedTemporaryFile()
        tmp_dwd.write(data)
        mal_db = os.path.join(MALWARE_DB_DIR, 'malwaredomainlist')
        # Check1: SHA256 Change
        if sha256(tmp_dwd.name) != sha256(mal_db):
            # DB needs update
            # Check2: DB Syntax Changed
            dptr = io.open(tmp_dwd.name, mode='r',
                           encoding="utf8", errors="ignore")
            line = dptr.readline()
            dptr.close()
            lst = line.split('",')
            if len(lst) == 10:
                # DB Format is not changed. Let's update DB
                print "\n[INFO] Updating Malware Database...."
                shutil.copyfile(tmp_dwd.name, mal_db)
            else:
                print "\n[WARNING] Malware Database format from malwaredomainlist.com changed. Database is not updated. Please report to: https://github.com/MobSF/Mobile-Security-Framework-MobSF/issues"
        else:
            print "\n[INFO] Malware Database is up-to-date."
        tmp_dwd.close()
    except:
        PrintException("[ERROR] Malware DB Update")
Esempio n. 7
0
 def _update_tracker_db(self):
     """Update Trackers DB."""
     try:
         proxies, verify = upstream_proxy('http')
     except Exception:
         logger.exception('[ERROR] Setting upstream proxy')
     try:
         exodus_url = settings.TRACKERS_DB_URL
         res = requests.get(exodus_url,
                            timeout=3,
                            proxies=proxies,
                            allow_redirects=True,
                            verify=verify)
         data = res.content
         tmp_dwd = tempfile.NamedTemporaryFile()
         tmp_dwd.write(data)
         tmp_dwd.seek(0)
         # Check1: SHA256 Change
         if sha256(tmp_dwd.name) != sha256(self.tracker_db):
             # DB needs update
             # Check2: DB Syntax Changed
             data = json.loads(tmp_dwd.read().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 Tracker Database....')
                 shutil.copyfile(tmp_dwd.name, self.tracker_db)
             else:
                 logger.info('Tracker 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')
         else:
             logger.info('Tracker Database is up-to-date.')
         tmp_dwd.close()
     except Exception:
         logger.exception('[ERROR] Tracker DB Update')