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


Python ESAPI.executor方法代码示例

本文整理汇总了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        
开发者ID:kenshinx,项目名称:django-esapi,代码行数:35,代码来源:test_executor.py

示例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)
开发者ID:kenshinx,项目名称:django-esapi,代码行数:43,代码来源:test_executor.py


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