Пример #1
0
def request_callback(future, index, datas):
    result = future.result()
    if isinstance(result, BaseException):
        logger.log('TRACE', result.args)
        name = utils.get_classname(result)
        datas[index]['reason'] = name + ' ' + str(result)
        datas[index]['request'] = 0
        datas[index]['alive'] = 0
    elif isinstance(result, tuple):
        resp, text = result
        datas[index]['reason'] = resp.reason
        datas[index]['status'] = resp.status
        if resp.status == 400 or resp.status >= 500:
            datas[index]['request'] = 0
            datas[index]['alive'] = 0
        else:
            datas[index]['request'] = 1
            datas[index]['alive'] = 1
            headers = resp.headers
            datas[index]['banner'] = utils.get_sample_banner(headers)
            datas[index]['header'] = str(dict(headers))[1:-1]
            if isinstance(text, str):
                title = get_title(text).strip()
                datas[index]['title'] = utils.remove_invalid_string(title)
                datas[index]['response'] = utils.remove_invalid_string(text)
Пример #2
0
def gen_new_info(info, resp):
    if isinstance(resp, Exception):
        info['reason'] = str(resp.args)
        info['request'] = 0
        info['alive'] = 0
        return info
    info['reason'] = resp.reason
    code = resp.status_code
    info['status'] = code
    info['request'] = 1
    if code == 400 or code >= 500:
        info['alive'] = 0
    else:
        info['alive'] = 1
    headers = resp.headers
    if settings.enable_banner_identify:
        info['banner'] = utils.get_sample_banner(headers)
    info['header'] = json.dumps(dict(headers))
    history = resp.history
    info['history'] = json.dumps(get_jump_urls(history))
    text = utils.decode_resp_text(resp)
    title = get_html_title(text).strip()
    info['title'] = utils.remove_invalid_string(title)
    info['response'] = utils.remove_invalid_string(text)
    return info
Пример #3
0
def request_callback(future, index, datas):
    resp, text = future.result()
    if isinstance(resp, BaseException):
        exception = resp
        logger.log('TRACE', exception.args)
        name = utils.get_classname(exception)
        datas[index]['reason'] = name + ' ' + str(exception)
        datas[index]['request'] = 0
        datas[index]['alive'] = 0
    else:
        datas[index]['reason'] = resp.reason
        datas[index]['status'] = resp.status
        datas[index]['request'] = 1
        if resp.status == 400 or resp.status >= 500:
            datas[index]['alive'] = 0
        else:
            datas[index]['alive'] = 1
        headers = resp.headers
        if settings.enable_banner_identify:
            datas[index]['banner'] = utils.get_sample_banner(headers)
        datas[index]['header'] = json.dumps(dict(headers))
        history = resp.history
        datas[index]['history'] = json.dumps(get_jump_urls(history))
        if isinstance(text, str):
            title = get_title(text).strip()
            datas[index]['title'] = utils.remove_invalid_string(title)
            datas[index]['response'] = utils.remove_invalid_string(text)