本文整理汇总了Python中core.data.parsers.url.URL.url_join方法的典型用法代码示例。如果您正苦于以下问题:Python URL.url_join方法的具体用法?Python URL.url_join怎么用?Python URL.url_join使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core.data.parsers.url.URL
的用法示例。
在下文中一共展示了URL.url_join方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_url_join_case03
# 需要导入模块: from core.data.parsers.url import URL [as 别名]
# 或者: from core.data.parsers.url.URL import url_join [as 别名]
def test_url_join_case03(self):
u = URL('http://w3af.com/def/jkl/')
self.assertEqual(u.url_join('/def/abc.html').url_string,
u'http://w3af.com/def/abc.html')
self.assertEqual(u.url_join('def/abc.html').url_string,
u'http://w3af.com/def/jkl/def/abc.html')
示例2: test_url_join_case01
# 需要导入模块: from core.data.parsers.url import URL [as 别名]
# 或者: from core.data.parsers.url.URL import url_join [as 别名]
def test_url_join_case01(self):
u = URL('http://w3af.com/foo.bar')
self.assertEqual(u.url_join('abc.html').url_string,
u'http://w3af.com/abc.html')
self.assertEqual(u.url_join('/abc.html').url_string,
u'http://w3af.com/abc.html')
示例3: xssed_dot_com
# 需要导入模块: from core.data.parsers.url import URL [as 别名]
# 或者: from core.data.parsers.url.URL import url_join [as 别名]
class xssed_dot_com(InfrastructurePlugin):
'''
Search in xssed.com to find xssed pages.
:author: Nicolas Crocfer ([email protected])
:author: Raul Siles: set "." in front of the root domain to limit search
'''
def __init__(self):
InfrastructurePlugin.__init__(self)
#
# Could change in time,
#
self._xssed_url = URL("http://www.xssed.com")
self._fixed = "<img src='http://data.xssed.org/images/fixed.gif'> FIXED</th>"
@runonce(exc_class=w3afRunOnce)
def discover(self, fuzzable_request):
'''
Search in xssed.com and parse the output.
:param fuzzable_request: A fuzzable_request instance that contains
(among other things) the URL to test.
'''
target_domain = fuzzable_request.get_url().get_root_domain()
try:
check_url = self._xssed_url.url_join(
"/search?key=." + target_domain)
response = self._uri_opener.GET(check_url)
except w3afException, e:
msg = 'An exception was raised while running xssed_dot_com'\
' plugin. Exception: "%s".' % e
om.out.debug(msg)
else:
示例4: test_url_join_case07
# 需要导入模块: from core.data.parsers.url import URL [as 别名]
# 或者: from core.data.parsers.url.URL import url_join [as 别名]
def test_url_join_case07(self):
u = URL('http://w3af.com/')
self.assertEqual(u.url_join('http://w3af.org:8080/abc.html').url_string,
u'http://w3af.org:8080/abc.html')
示例5: test_url_join_case05
# 需要导入模块: from core.data.parsers.url import URL [as 别名]
# 或者: from core.data.parsers.url.URL import url_join [as 别名]
def test_url_join_case05(self):
u = URL('http://w3af.com/def/')
self.assertEqual(u.url_join(u'тест').url_string,
u'http://w3af.com/def/тест')
示例6: TestFuzzableRequest
# 需要导入模块: from core.data.parsers.url import URL [as 别名]
# 或者: from core.data.parsers.url.URL import url_join [as 别名]
class TestFuzzableRequest(unittest.TestCase):
def setUp(self):
self.url = URL('http://w3af.com/a/b/c.php')
def test_variants_commutative(self):
# 'is_variant_of' is commutative
fr = FuzzableRequest(self.url, method='POST', dc={'a': ['1']})
fr_other = FuzzableRequest(self.url, method='POST', dc={'a': ['1']})
self.assertTrue(fr.is_variant_of(fr_other))
self.assertTrue(fr_other.is_variant_of(fr))
def test_variants_false_diff_meths(self):
# Different methods
fr_get = FuzzableRequest(self.url, method='GET', dc={'a': ['1']})
fr_post = FuzzableRequest(self.url, method='POST', dc={'a': ['1']})
self.assertFalse(fr_get.is_variant_of(fr_post))
def test_variants_false_diff_params_type(self):
fr = FuzzableRequest(
self.url, method='GET', dc={'a': ['1'], 'b': ['1']})
fr_other = FuzzableRequest(
self.url, method='GET', dc={'a': ['2'], 'b': ['cc']})
self.assertFalse(fr.is_variant_of(fr_other))
def test_variants_false_nonetype_in_params(self):
fr = FuzzableRequest(self.url, method='GET', dc={'a': [None]})
fr_other = FuzzableRequest(self.url, method='GET', dc={'a': ['s']})
self.assertFalse(fr.is_variant_of(fr_other))
def test_variants_true_similar_params(self):
# change the url by adding a querystring. shouldn't affect anything.
url = self.url.url_join('?a=z')
fr = FuzzableRequest(url, method='GET', dc={'a': ['1'], 'b': ['bb']})
fr_other = FuzzableRequest(
self.url, method='GET', dc={'a': ['2'], 'b': ['cc']})
self.assertTrue(fr.is_variant_of(fr_other))
def test_variants_true_similar_params_two(self):
fr = FuzzableRequest(self.url, method='GET', dc={'a': ['b']})
fr_other = FuzzableRequest(self.url, method='GET', dc={'a': ['']})
self.assertTrue(fr.is_variant_of(fr_other))
def test_dump_case01(self):
expected = '\r\n'.join(['GET http://w3af.com/a/b/c.php HTTP/1.1',
'Hello: World',
'',
''])
headers = Headers([('Hello', 'World')])
#TODO: Note that I'm passing a dc to the FuzzableRequest and it's not
# appearing in the dump. It might be a bug...
fr = FuzzableRequest(self.url, method='GET', dc={'a': ['b']},
headers=headers)
self.assertEqual(fr.dump(), expected)
def test_dump_case02(self):
expected = u'\r\n'.join([u'GET http://w3af.com/a/b/c.php HTTP/1.1',
u'Hola: Múndo',
u'',
u''])
headers = Headers([(u'Hola', u'Múndo')])
#TODO: Note that I'm passing a dc to the FuzzableRequest and it's not
# appearing in the dump. It might be a bug...
fr = FuzzableRequest(self.url, method='GET', dc={u'á': ['b']},
headers=headers)
self.assertEqual(fr.dump(), expected)
def test_dump_case03(self):
header_value = ''.join(chr(i) for i in xrange(256))
expected = u'\r\n'.join([u'GET http://w3af.com/a/b/c.php HTTP/1.1',
u'Hola: %s' % smart_unicode(header_value),
u'',
u''])
headers = Headers([(u'Hola', header_value)])
#TODO: Note that I'm passing a dc to the FuzzableRequest and it's not
# appearing in the dump. It might be a bug...
fr = FuzzableRequest(self.url, method='GET', dc={u'a': ['b']},
headers=headers)
self.assertEqual(fr.dump(), expected)
def test_dump_mangle(self):
fr = FuzzableRequest(URL("http://www.w3af.com/"),\
headers=Headers([('Host','www.w3af.com'),]))
expected = u'\r\n'.join([u'GET http://www.w3af.com/ HTTP/1.1',
u'Host: www.w3af.com',
u'',
u''])
self.assertEqual(fr.dump(), expected)
fr.set_method('POST')
fr.set_data('data=23')
expected = u'\r\n'.join([u'POST http://www.w3af.com/ HTTP/1.1',
#.........这里部分代码省略.........