本文整理汇总了Python中core.data.parsers.url.URL.from_parts方法的典型用法代码示例。如果您正苦于以下问题:Python URL.from_parts方法的具体用法?Python URL.from_parts怎么用?Python URL.from_parts使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core.data.parsers.url.URL
的用法示例。
在下文中一共展示了URL.from_parts方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_from_parts
# 需要导入模块: from core.data.parsers.url import URL [as 别名]
# 或者: from core.data.parsers.url.URL import from_parts [as 别名]
def test_from_parts(self):
u = URL.from_parts('http', 'w3af.com', '/foo/bar.txt', None, 'a=b',
'frag')
self.assertEqual(u.path, '/foo/bar.txt')
self.assertEqual(u.scheme, 'http')
self.assertEqual(u.get_file_name(), 'bar.txt')
self.assertEqual(u.get_extension(), 'txt')
示例2: _create_file
# 需要导入模块: from core.data.parsers.url import URL [as 别名]
# 或者: from core.data.parsers.url.URL import from_parts [as 别名]
def _create_file(self):
'''
Create random name file php with random php content. To be used in the
remote file inclusion test.
:return: The file content to be served via the webserver.
Please note that the generated code works both in PHP and JSP without
any issues, since PHP will run everything between "<?" and "?>" and
JSP will run code between "<%" and "%>".
TODO: make this code compatible with: asp/aspx, jsp, js (nodejs), pl,
py, rb, etc. Some code snippets that might help to achieve this
task:
asp_code = 'response.write("%s");\n response.write("%s");' % (
rand1, rand2)
asp_code = '<% \n '+asp_code+'\n %>'
'''
with self._plugin_lock:
# First, generate the php file to be included.
rfi_result_part_1 = rand1 = rand_alnum(9)
rfi_result_part_2 = rand2 = rand_alnum(9)
rfi_result = rand1 + rand2
filename = rand_alnum(8)
php_jsp_code = '<? echo "%s"; echo "%s"; ?>'
php_jsp_code += '<%% out.print("%s"); out.print("%s"); %%>'
php_jsp_code = php_jsp_code % (rand1, rand2, rand1, rand2)
# Define the required parameters
netloc = self._listen_address + ':' + str(self._listen_port)
path = '/' + filename
rfi_url = URL.from_parts('http', netloc, path, None, None, None)
rfi_data = RFIData(
rfi_url, rfi_result_part_1, rfi_result_part_2, rfi_result)
return php_jsp_code, rfi_data