本文整理汇总了Python中esapi.core.ESAPI.executor方法的典型用法代码示例。如果您正苦于以下问题:Python ESAPI.executor方法的具体用法?Python ESAPI.executor怎么用?Python ESAPI.executor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类esapi.core.ESAPI
的用法示例。
在下文中一共展示了ESAPI.executor方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_execute_on_windows
# 需要导入模块: from esapi.core import ESAPI [as 别名]
# 或者: from esapi.core.ESAPI import executor [as 别名]
def test_execute_on_windows(self):
if os.name != 'nt':
print "Not executing test_execute_on_windows because os.name != 'nt'"
return
codec = WindowsCodec()
instance = ESAPI.executor()
orig_executable = "C:\\Windows\System32\cmd.exe"
parent_dir = 'C:\\'
params = ['/C', 'dir']
result = instance.execute_system_command(orig_executable, params, parent_dir, codec=codec)
print "result:", result
executable = orig_executable + ";inject.exe"
self.assertRaises(ExecutorException, instance.execute_system_command, executable, params, parent_dir, codec=codec)
executable = orig_executable + "\\..\\cmd.exe"
self.assertRaises(ExecutorException, instance.execute_system_command, executable, params, parent_dir, codec=codec)
work_dir = "C:\\ridiculous"
self.assertRaises(ExecutorException, instance.execute_system_command, orig_executable, params, parent_dir, work_dir, codec=codec)
params.append("&dir")
result = instance.execute_system_command(orig_executable, params, parent_dir, codec=codec)
print "result:", result
params = params[:-1] + ['c:\\autoexec.bat']
result = instance.execute_system_command(orig_executable, params, parent_dir, codec=codec)
print "result:", result
params = params[:-1] + ['c:\\autoexec.bat c:\\config.sys']
result = instance.execute_system_command(orig_executable, params, parent_dir, codec=codec)
print "result:", result
示例2: test_execute_on_linux
# 需要导入模块: from esapi.core import ESAPI [as 别名]
# 或者: from esapi.core.ESAPI import executor [as 别名]
def test_execute_on_linux(self):
if os.name == 'nt':
print "Not executing test_execute_on_linux because os.name == 'nt'"
return
codec = UnixCodec()
instance = ESAPI.executor()
executable = "/bin/sh"
params = ['-c', 'ls', '/']
parent_dir = '/'
result = instance.execute_system_command(executable, params, parent_dir, codec=codec)
print "result:", result
# Don't log the params
result = instance.execute_system_command(executable, params, parent_dir, log_params=False)
# Test default codec
result = instance.execute_system_command(executable, params, parent_dir)
print "result:", result
# Test bad executable
self.assertRaises( ExecutorException, instance.execute_system_command, "/usr/bin/passwd", [], parent_dir)
# Test bad working directory
self.assertRaises( ExecutorException, instance.execute_system_command, executable, params, parent_dir, "/rediculous")
executable = '/bin/sh;.inject'
self.assertRaises( ExecutorException, instance.execute_system_command, executable, params, parent_dir, codec=codec)
executable = '/../bin/sh'
self.assertRaises( ExecutorException, instance.execute_system_command, executable, params, parent_dir, codec=codec)
executable = '/bin/sh'
params.append(';ls')
result = instance.execute_system_command(executable, params, parent_dir, codec=codec)
print "result:", result
# Exceed the runtime
executable = '/bin/sleep'
params = ['30']
self.assertRaises( ExecutorException, instance.execute_system_command, executable, params, parent_dir)