def list(kind=None): if kind == "lhost": # 获取pem秘钥文件,用于https监听配置 files = FileMsf.list_msf_files() pem_files = [] for file in files: name = file.get("name") if name.lower().endswith(".pem"): pem_files.append(name) conf = Xcache.get_lhost_config() if conf is None: conf = {'lhost': None, "pem_files": pem_files} else: conf["pem_files"] = pem_files elif kind == "telegram": conf = Xcache.get_telegram_conf() if conf is None: conf = { "token": "", "chat_id": [], "proxy": "", "alive": False } elif kind == "dingding": conf = Xcache.get_dingding_conf() if conf is None: conf = {"access_token": "", "keyword": "", "alive": False} elif kind == "serverchan": conf = Xcache.get_serverchan_conf() if conf is None: conf = {"sendkey": "", "alive": False} elif kind == "FOFA": conf = Xcache.get_fofa_conf() if conf is None: conf = {"email": "", "key": "", "alive": False} elif kind == "sessionmonitor": conf = Xcache.get_sessionmonitor_conf() else: context = data_return(301, Setting_MSG.get(301), {}) return context context = data_return(200, CODE_MSG.get(200), conf) return context
def send_dingding_message(msg=None, conf=None): if conf is None: conf = Xcache.get_dingding_conf() if conf is None: return False if conf.get("alive"): pass else: return False access_token = conf.get("access_token") keyword = conf.get("keyword") try: ding = DingDing(access_token) result = ding.send_text(msg, keyword=keyword) if result.get("errcode") == 0: return True else: return False except Exception as E: logger.warning(E) return False