def get_rule_from_redis(): """ 从redis里面读规则 https://huangzhw.github.io/2019/02/01/python3-redis-encoding/ :return: """ for k in redis_conn_byte.scan_iter("bbscan_root_rules::*"): # print(k) # rule = print(redis_conn_byte.get(k))
def save_res_to_redis(self, url): try: if url == "/": for k in redis_conn_byte.scan_iter("bbscan_rules*"): rule_list = redis_conn_byte.get(k).decode('utf-8').split( ',') rule_list[0] = self.url + rule_list[0] ret = ','.join(rule_list) + ',' + str(self._404_status) + ',' + str(self.len_404_doc)+','+ \ self.task_name + ',' + self.task_id + ',' + self.tag_name # log.info("store bbscan root request to redis %s", ret) redis_conn_byte.lpush('BBScan_Second', ret) else: for k in redis_conn_byte.scan_iter("bbscan_rules_common::*"): rule_list = redis_conn_byte.get(k).decode('utf-8').split( ',') rule_list[0] = self.url + url.rstrip('/') + rule_list[0] ret = ','.join(rule_list) + ',' + str(self._404_status) + ',' + str(self.len_404_doc)+','+ \ self.task_name + ',' + self.task_id + ',' + self.tag_name # log.info("store bbscan common request to redis %s", ret) redis_conn_byte.lpush('BBScan_Second', ret) except: log.error("save to redis error", exc_info=True) pass
def check_white_list(content): """ 检查要网页的内容是否在白名单里面,在白名单返回,不在白名单继续 :param content: :return: """ try: for k in redis_conn_byte.scan_iter("white_list*"): if redis_conn_byte.get(k).decode('utf-8') in content: return True continue except: log.error("check white list error", exc_info=True)
def get_black_white_list(): for k in redis_conn_byte.scan_iter("white_list*"): print(redis_conn_byte.get(k))