예제 #1
0
def init_request(url):
    # Number of seconds to wait before timeout connection
    if settings.VERBOSITY_LEVEL >= 1:
        debug_msg = "Setting the HTTP timeout."
        print(settings.print_debug_msg(debug_msg))
    if menu.options.timeout:
        settings.TIMEOUT = menu.options.timeout
    # Check connection(s)
    checks.check_connection(url)
    # Define HTTP User-Agent header
    user_agent_header()
    # Check the internet connection (--check-internet switch).
    if menu.options.check_internet:
        check_internet(url)
    # Check if defined POST data
    if menu.options.data:
        settings.USER_DEFINED_POST_DATA = menu.options.data
        # Check if defined character used for splitting parameter values.
        if menu.options.pdel and menu.options.pdel in settings.USER_DEFINED_POST_DATA:
            settings.PARAMETER_DELIMITER = menu.options.pdel
        try:
            request = _urllib.request.Request(url, menu.options.data.encode())
        except SocketError as e:
            if e.errno == errno.ECONNRESET:
                error_msg = "Connection reset by peer."
                print(settings.print_critical_msg(error_msg))
            elif e.errno == errno.ECONNREFUSED:
                error_msg = "Connection refused."
                print(settings.print_critical_msg(error_msg))
            raise SystemExit()
    else:
        # Check if defined character used for splitting parameter values.
        if menu.options.pdel and menu.options.pdel in url:
            settings.PARAMETER_DELIMITER = menu.options.pdel
        try:
            request = _urllib.request.Request(url)
        except SocketError as e:
            if e.errno == errno.ECONNRESET:
                error_msg = "Connection reset by peer."
                print(settings.print_critical_msg(error_msg))
            elif e.errno == errno.ECONNREFUSED:
                error_msg = "Connection refused."
                print(settings.print_critical_msg(error_msg))
            raise SystemExit()

    headers.do_check(request)
    # Check if defined any HTTP Proxy (--proxy option).
    if menu.options.proxy:
        proxy.do_check(url)
    if settings.VERBOSITY_LEVEL >= 1:
        debug_msg = "Creating " + str(
            settings.SCHEME).upper() + " requests opener object."
        print(settings.print_debug_msg(debug_msg))
    # Used a valid pair of valid credentials
    if menu.options.auth_cred and menu.options.auth_type:
        info_msg = "Using '" + menu.options.auth_cred + "' pair of " + menu.options.auth_type
        info_msg += " HTTP authentication credentials."
        print(settings.print_info_msg(info_msg))
    return request
예제 #2
0
def init_request(url):
    # Check connection(s)
    checks.check_connection(url)
    # Define HTTP User-Agent header
    user_agent_header()
    # Check the internet connection (--check-internet switch).
    if menu.options.check_internet:
        check_internet(url)
    # Check if defined POST data
    if menu.options.data:
        settings.USER_DEFINED_POST_DATA = menu.options.data
        # Check if defined character used for splitting parameter values.
        if menu.options.pdel and menu.options.pdel in settings.USER_DEFINED_POST_DATA:
            settings.PARAMETER_DELIMITER = menu.options.pdel
        try:
            request = urllib2.Request(url, menu.options.data)
        except SocketError as e:
            if e.errno == errno.ECONNRESET:
                error_msg = "Connection reset by peer."
                print(settings.print_critical_msg(error_msg))
            elif e.errno == errno.ECONNREFUSED:
                error_msg = "Connection refused."
                print(settings.print_critical_msg(error_msg))
            raise SystemExit()
    else:
        # Check if defined character used for splitting parameter values.
        if menu.options.pdel and menu.options.pdel in url:
            settings.PARAMETER_DELIMITER = menu.options.pdel
        try:
            request = urllib2.Request(url)
        except SocketError as e:
            if e.errno == errno.ECONNRESET:
                error_msg = "Connection reset by peer."
                print(settings.print_critical_msg(error_msg))
            elif e.errno == errno.ECONNREFUSED:
                error_msg = "Connection refused."
                print(settings.print_critical_msg(error_msg))
            raise SystemExit()

    headers.do_check(request)
    # Check if defined any HTTP Proxy (--proxy option).
    if menu.options.proxy:
        proxy.do_check(url)
    if settings.VERBOSITY_LEVEL >= 1:
        info_msg = "Creating HTTP requests opener object."
        print(settings.print_info_msg(info_msg))
    # Check for URL redirection
    if not menu.options.ignore_redirects:
        url = redirection.do_check(url)
    # Used a valid pair of valid credentials
    if menu.options.auth_cred and menu.options.auth_type:
        info_msg = "Using '" + menu.options.auth_cred + "' pair of " + menu.options.auth_type
        info_msg += " HTTP authentication credentials."
        print(settings.print_info_msg(info_msg))
    return request
예제 #3
0
def init_request(url):
  # Check connection(s)
  checks.check_connection(url)
  # Define HTTP User-Agent header
  user_agent_header()
  # Check the internet connection (--check-internet switch).
  if menu.options.check_internet:
    check_internet(url)
  # Check if defined POST data
  if menu.options.data:
    settings.USER_DEFINED_POST_DATA = menu.options.data
    # Check if defined character used for splitting parameter values.
    if menu.options.pdel and menu.options.pdel in settings.USER_DEFINED_POST_DATA:
      settings.PARAMETER_DELIMITER = menu.options.pdel
    try:
      request = urllib2.Request(url, menu.options.data)
    except SocketError as e:
      if e.errno == errno.ECONNRESET:
        error_msg = "Connection reset by peer."
        print settings.print_critical_msg(error_msg)
      elif e.errno == errno.WSAECONNRESET:
        error_msg = "An existing connection was forcibly closed by the remote host."
        print settings.print_critical_msg(error_msg)
      raise SystemExit()
  else:
    # Check if defined character used for splitting parameter values.
    if menu.options.pdel and menu.options.pdel in url:
      settings.PARAMETER_DELIMITER = menu.options.pdel
    try:
      request = urllib2.Request(url)
    except SocketError as e:
      if e.errno == errno.ECONNRESET:
        error_msg = "Connection reset by peer."
        print settings.print_critical_msg(error_msg)
      elif e.errno == errno.WSAECONNRESET:
        error_msg = "An existing connection was forcibly closed by the remote host."
        print settings.print_critical_msg(error_msg)
      raise SystemExit()
  headers.do_check(request)
  # Check if defined any HTTP Proxy (--proxy option).
  if menu.options.proxy:
    proxy.do_check(url)
  if settings.VERBOSITY_LEVEL >= 1:
    info_msg = "Creating HTTP requests opener object."
    print settings.print_info_msg(info_msg) 
  # Check for URL redirection
  if not menu.options.ignore_redirects:
    url = redirection.do_check(url)
  # Used a valid pair of valid credentials
  if menu.options.auth_cred and menu.options.auth_type:
    info_msg = "Using '" + menu.options.auth_cred + "' pair of " + menu.options.auth_type 
    info_msg += " HTTP authentication credentials."
    print settings.print_info_msg(info_msg)
  return request