def _parse_mssql(self, sj: dict, task: IscoutTask, level: int, portinfo: PortInfo): """ 解析mssql的banner和一些其他的信息 暂时未使用 :param sj: :param task: :param level: :param portinfo: :return: """ res = False if not sj.__contains__("data") or not sj["data"].__contains__("mssql"): return try: sjmssql = sj['data']['mssql'] succ = sjmssql["status"] if succ != "success": return protocol = sjmssql["protocol"] if protocol != "mssql": return if portinfo.service != protocol: portinfo.service = protocol self._get_port_timestamp(sjmssql, portinfo) # 开始构建mssql的banner msdata = Mssql() mres = sjmssql.get('result') if mres is None: return # 就只构建有的吧,模仿的shodan的https://www.shodan.io/host/119.18.55.104 instancename = mres.get('instance_name', '') msdata.instance_name = instancename msdata.version = mres.get('version') portinfo.banner = msdata.build_banner() msdata.banner = portinfo.banner res = True # 开始解析tls sjtls = mres.pop('tls', None) portinfo.extrainfo = json.dumps(mres) if sjtls is not None: sjhandshake = sjtls.get("handshake_log") if sjhandshake is None or len(sjhandshake) < 1: return self._parser_tls._parse_cert(sjhandshake, portinfo) portinfo.set_mssql(msdata) except: self._logger.error( f"Parse mssql protocal error, err:{traceback.format_exc()}") return res
def _parse_redis(self, sj: dict, task: IscoutTask, level: int, portinfo: PortInfo): """ 解析redis的banner和一些其他的信息 总之就是port里的信息 :param sj: :param task: :param level: :param portinfo: :return: """ res = False if not sj.__contains__("data") or not sj["data"].__contains__("redis"): return try: sjredis = sj['data']['redis'] succ = sjredis["status"] if succ != "success": return protocol = sjredis["protocol"] if protocol != "redis": return if portinfo.service != protocol: portinfo.service = protocol self._get_port_timestamp(sjredis, portinfo) # 开始构建redis的banner result = sjredis.get('result', {}) rdata = Redis() rdata.info_response = result.pop('info_response', None) rdata.ping_response = result.pop('ping_response', None) portinfo.banner = rdata.build_banner() rdata.banner = portinfo.banner portinfo.version = result.pop('version') portinfo.os = result.pop('os') portinfo.extrainfo = json.dumps(result) res = True portinfo.set_redis(rdata) except: self._logger.error( f"Parse redis protocal error, err:{traceback.format_exc()}") return res