当前位置: 首页>>代码示例>>Python>>正文


Python URL.get_protocol方法代码示例

本文整理汇总了Python中w3af.core.data.parsers.doc.url.URL.get_protocol方法的典型用法代码示例。如果您正苦于以下问题:Python URL.get_protocol方法的具体用法?Python URL.get_protocol怎么用?Python URL.get_protocol使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在w3af.core.data.parsers.doc.url.URL的用法示例。


在下文中一共展示了URL.get_protocol方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_default_proto

# 需要导入模块: from w3af.core.data.parsers.doc.url import URL [as 别名]
# 或者: from w3af.core.data.parsers.doc.url.URL import get_protocol [as 别名]
 def test_default_proto(self):
     """
     http is the default protocol, we can provide URLs with no proto
     """
     u = URL('w3af.com')
     self.assertEqual(u.get_domain(), 'w3af.com')
     self.assertEqual(u.get_protocol(), 'http')
开发者ID:batmanWjw,项目名称:w3af,代码行数:9,代码来源:test_url.py

示例2: test_websocket_secure_proto

# 需要导入模块: from w3af.core.data.parsers.doc.url import URL [as 别名]
# 或者: from w3af.core.data.parsers.doc.url.URL import get_protocol [as 别名]
 def test_websocket_secure_proto(self):
     """
     We can also parse and handle ws and wss protocols
     """
     u = URL('wss://w3af.com')
     self.assertEqual(u.get_domain(), 'w3af.com')
     self.assertEqual(u.get_protocol(), 'wss')
开发者ID:batmanWjw,项目名称:w3af,代码行数:9,代码来源:test_url.py

示例3: setUp

# 需要导入模块: from w3af.core.data.parsers.doc.url import URL [as 别名]
# 或者: from w3af.core.data.parsers.doc.url.URL import get_protocol [as 别名]
    def setUp(self):
        self.kb.cleanup()
        self.w3afcore = w3afCore()
        
        if self.MOCK_RESPONSES:
            httpretty.enable()
            
            try:
                url = URL(self.target_url)
            except ValueError, ve:
                msg = 'When using MOCK_RESPONSES you need to set the'\
                      ' target_url attribute to a valid URL, exception was:'\
                      ' "%s".'
                raise Exception(msg % ve)

            domain = url.get_domain()
            proto = url.get_protocol()
            port = url.get_port()

            self._register_httpretty_uri(proto, domain, port)
开发者ID:andresriancho,项目名称:w3af-kali,代码行数:22,代码来源:helper.py

示例4: test_set_protocol

# 需要导入模块: from w3af.core.data.parsers.doc.url import URL [as 别名]
# 或者: from w3af.core.data.parsers.doc.url.URL import get_protocol [as 别名]
 def test_set_protocol(self):
     u = URL("http://1.2.3.4")
     self.assertEqual(u.get_protocol(), 'http')
     
     u.set_protocol('https')
     self.assertEqual(u.get_protocol(), 'https')
开发者ID:batmanWjw,项目名称:w3af,代码行数:8,代码来源:test_url.py

示例5: alert_if_target_is_301_all

# 需要导入模块: from w3af.core.data.parsers.doc.url import URL [as 别名]
# 或者: from w3af.core.data.parsers.doc.url.URL import get_protocol [as 别名]
    def alert_if_target_is_301_all(self):
        """
        Alert the user when the configured target is set to a site which will
        301 redirect all requests to https://

        :see: https://github.com/andresriancho/w3af/issues/14976
        :return: True if the site returns 301 for all resources. Also an Info
                 instance is saved to the KB in order to alert the user.
        """
        site_does_redirect = False
        msg = ('The configured target domain redirects all HTTP requests to a'
               ' different location. The most common scenarios are:\n\n'
               ''
               '    * HTTP redirect to HTTPS\n'
               '    * domain.com redirect to www.domain.com\n\n'
               ''
               'While the scan engine can identify URLs and vulnerabilities'
               ' using the current configuration it might be wise to start'
               ' a new scan setting the target URL to the redirect target.')

        targets = cf.cf.get('targets')

        for url in targets:
            # We test if the target URLs are redirecting to a different protocol
            # or domain.
            try:
                http_response = self._w3af_core.uri_opener.GET(url, cache=False)
            except ScanMustStopByUserRequest:
                # Not a real error, the user stopped the scan
                raise
            except Exception, e:
                emsg = 'Exception found during alert_if_target_is_301_all(): "%s"'
                emsg %= e

                om.out.debug(emsg)
                raise ScanMustStopException(emsg)
            else:
                if 300 <= http_response.get_code() <= 399:

                    # Get the redirect target
                    lower_headers = http_response.get_lower_case_headers()
                    redirect_url = None

                    for header_name in ('location', 'uri'):
                        if header_name in lower_headers:
                            header_value = lower_headers[header_name]
                            header_value = header_value.strip()
                            try:
                                redirect_url = URL(header_value)
                            except ValueError:
                                # No special invalid URL handling required
                                continue

                    if not redirect_url:
                        continue

                    # Check if the protocol was changed:
                    target_proto = url.get_protocol()
                    redirect_proto = redirect_url.get_protocol()

                    if target_proto != redirect_proto:
                        site_does_redirect = True
                        break

                    # Check if the domain was changed:
                    target_domain = url.get_domain()
                    redirect_domain = redirect_url.get_domain()

                    if target_domain != redirect_domain:
                        site_does_redirect = True
                        break
开发者ID:everping,项目名称:w3af,代码行数:73,代码来源:strategy.py


注:本文中的w3af.core.data.parsers.doc.url.URL.get_protocol方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。