def ConfAnalysis(ConfFile): """ configuration file analysis. Load global variables with parameters found in configuration file. :param confFile: the configuration file """ global CONF global DBFile global TABLEname global LogFile global Proxy global UA global UAFILE global Alerts_dir global Alert_Monitor_timelapse global Notification_Destination global Safe_Browsing_API_Key try: CONF = ConfParser(ConfFile) DBFile = CONF.DBFile TABLEname = CONF.TABLEname LogFile = CONF.LogFile Proxy = CONF.Proxy UA = CONF.http_UA Alerts_dir = generate_alert_dir(CONF.Alerts_dir) Alert_Monitor_timelapse = CONF.Alert_Monitor_timelapse Notification_Destination = CONF.Notification_Destination UAFILE = CONF.UAfile Safe_Browsing_API_Key = CONF.Safe_Browsing_API_Key except Exception as err: err = sys.exc_info() logging.error(" ConfParser Error: " + str(err))
def ConfAnalysis(ConfFile): """ configuration file analysis. Load global variables with parameters found in configuration file. :param confFile: the configuration file """ global CONF global DBFile global TABLEname global LogFile global Proxy global UA global UAFILE global Alerts_dir try: CONF = ConfParser(ConfFile) DBFile = CONF.DBFile TABLEname = CONF.TABLEname LogFile = CONF.LogFile Proxy = CONF.Proxy UA = CONF.http_UA Alerts_dir = CONF.Alerts_dir UAFILE = CONF.UAfile except Exception as err: err = sys.exc_info() logging.error(" ConfParser Error: " + str(err))
def ConfAnalysis(ConfFile): """ configuration file analysis. Load global variables with parameters found in configuration file. :param confFile: the configuration file """ global CONF global DBFile global TABLEname global LogFile global SearchString global DetectionThreshold try: CONF = ConfParser(ConfFile) DBFile = CONF.DBFile TABLEname = CONF.TABLEname LogFile = CONF.LogFile SearchString = CONF.SearchString DetectionThreshold = CONF.DetectionThreshold except: err = sys.exc_info() logging.error(" ConfParser Error: " + str(err))
def _loadconfig(): conf_file = APP_BASE_DIR+"/certstream.json" if len(argv) > 1 and exists(APP_BASE_DIR+"/"+argv[1]): conf_file = APP_BASE_DIR + "/" + argv[1] if exists(conf_file): json_data = open(conf_file) engine.scanner = load(json_data) engine.scanner["status"] = "READY" else: LOG.error("Error: config file '{}' not found".format(conf_file)) return {"status": "error", "reason": "config file not found"} if "options" not in engine.scanner: LOG.error("Error: You have to specify options") return {"status": "error", "reason": "You have to specify options"} engine.scanner["options"]["Whitelist"]["present"] = "Whitelist" in engine.scanner["options"] and exists(engine.scanner["options"]["Whitelist"]["value"]) with open(engine.scanner["options"]["Whitelist"]["value"], "r", encoding="UTF-8") as whitelist_file: whitelist = whitelist_file.read() engine.scanner["options"]["Whitelist"]["list"] = whitelist.split("\n")[:-1] if "CertStreamMonitorFile" not in engine.scanner["options"]: LOG.error("Error: You have to specify CertStreamMonitorFile in options") return {"status": "error", "reason": "You have to specify CertStreamMonitorFile in options"} CertStreamMonitorFile = engine.scanner["options"]["CertStreamMonitorFile"]["value"] if not exists(CertStreamMonitorFile): LOG.error("Error: CertStreamMonitorFile not found : {}".format(CertStreamMonitorFile)) return {"status": "error", "reason": "CertStreamMonitorFile not found : {}".format(CertStreamMonitorFile)} LOG.info("[OK] CertStreamMonitorFile") try: CONF = ConfParser(CertStreamMonitorFile) engine.scanner["options"]["DBFile"] = "CertStreamMonitor/" + CONF.DBFile engine.scanner["options"]["TABLEname"] = CONF.TABLEname engine.scanner["options"]["SearchKeywords"] = CONF.SearchKeywords except Exception: LOG.error("Error: Cannot read CertStreamMonitorFile : {}".format(CertStreamMonitorFile)) return {"status": "error", "reason": "Cannot read CertStreamMonitorFile : {}".format(CertStreamMonitorFile)} if not exists(engine.scanner["options"]["DBFile"]): LOG.error("Error: sqlite file not found : {}".format(engine.scanner["options"]["DBFile"])) return {"status": "error", "reason": "sqlite file not found : {}".format(engine.scanner["options"]["DBFile"])}
def ConfAnalysis(ConfFile): """ configuration file analysis. Load global variables with parameters found in configuration file. :param confFile: the configuration file """ global CONF global DBFile global TABLEname try: CONF = ConfParser(ConfFile) DBFile = CONF.DBFile TABLEname = CONF.TABLEname except Exception as err: err = sys.exc_info() print("ConfParser Error: "+str(err))
def ConfAnalysis(ConfFile): global CONF global DBFile global TABLEname global LogFile global SearchString try: CONF = ConfParser(ConfFile) DBFile = CONF.DBFile TABLEname = CONF.TABLEname LogFile = CONF.LogFile SearchString = CONF.SearchString except: err = sys.exc_info() logging.error(" ConfParser Error: "+str(err))
def status(): """Get status on engine and all scans.""" CertStreamMonitorFile = engine.scanner["options"]["CertStreamMonitorFile"][ "value"] if not exists(CertStreamMonitorFile): LOG.error("Error: CertStreamMonitorFile not found : {}".format( CertStreamMonitorFile)) return jsonify({ "status": "error", "reason": "CertStreamMonitorFile not found : {}".format( CertStreamMonitorFile) }) try: CONF = ConfParser(CertStreamMonitorFile) engine.scanner["options"][ "DBFile"] = "CertStreamMonitor/" + CONF.DBFile engine.scanner["options"]["TABLEname"] = CONF.TABLEname engine.scanner["options"]["SearchKeywords"] = CONF.SearchKeywords except Exception: LOG.error("Error: Cannot read CertStreamMonitorFile : {}".format( CertStreamMonitorFile)) return jsonify({ "status": "error", "reason": "Cannot read CertStreamMonitorFile : {}".format( CertStreamMonitorFile) }) if not exists(engine.scanner["options"]["DBFile"]): LOG.error("Error: sqlite file not found : {}".format( engine.scanner["options"]["DBFile"])) return jsonify({ "status": "error", "reason": "sqlite file not found : {}".format( engine.scanner["options"]["DBFile"]) }) return engine.getstatus()
def ConfAnalysis(configuration_file): """ configuration file analysis. Load global variables with parameters found in configuration file. :param configuration_file: the configuration file """ global CONF global SearchKeywords global BlacklistKeywords global DetectionThreshold try: CONF = ConfParser(configuration_file) SearchKeywords = CONF.SearchKeywords BlacklistKeywords = CONF.BlacklistKeywords DetectionThreshold = CONF.DetectionThreshold except: err = sys.exc_info() logging.error(" ConfParser Error: %s", err)
def ConfAnalysis(ConfFile): """ configuration file analysis. Load global variables with parameters found in configuration file. :param ConfFile: the configuration file """ global CONF global DBFile global TABLEname global LogFile global SearchKeywords global BlacklistKeywords global DetectionThreshold global ACTServer global Proxy_Host global Proxy_Port global Proxy_Username global Proxy_Password try: CONF = ConfParser(ConfFile) DBFile = CONF.DBFile TABLEname = CONF.TABLEname LogFile = CONF.LogFile SearchKeywords = CONF.SearchKeywords BlacklistKeywords = CONF.BlacklistKeywords DetectionThreshold = CONF.DetectionThreshold ACTServer = CONF.ACTServer Proxy_Host = CONF.Proxy_Host Proxy_Port = CONF.Proxy_Port Proxy_Username = CONF.Proxy_Username Proxy_Password = CONF.Proxy_Password except: err = sys.exc_info() logging.error(" ConfParser Error: " + str(err))