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


Python payload_handler.exec_payload函数代码示例

本文整理汇总了Python中w3af.plugins.attack.payloads.payload_handler.exec_payload函数的典型用法代码示例。如果您正苦于以下问题:Python exec_payload函数的具体用法?Python exec_payload怎么用?Python exec_payload使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: exec_payload

    def exec_payload(self, payload_name, args=()):
        """
        Execute ANOTHER payload, by providing the other payload name.

        :param payload_name: The name of the payload I want to run.
        :return: The payload result.
        """
        try:
            return payload_handler.exec_payload(self.shell, payload_name,
                                                args, use_api=True)
        except:
            #
            #    Run the payload name with any shell that has the capabilities
            #    we need, not the one we're already using (that failed because
            #    it doesn't have the capabilities).
            #
            try:
                return payload_handler.exec_payload(None, payload_name, args,
                                                    use_api=True)
            except:
                msg = 'The payload you are trying to run ("%s") can not be' \
                      ' run because it is trying to call another payload'\
                      ' ("%s") which is failing because there are no shells'\
                      ' that support the required system calls.'
                om.out.console(msg)

                # TODO: Should I raise an exception here?
                return msg % (self, payload_name)
开发者ID:EnDe,项目名称:w3af,代码行数:28,代码来源:base_payload.py

示例2: test_portscan

    def test_portscan(self):
        result = exec_payload(self.shell, 'portscan',
                              args=('localhost', '22'),
                              use_api=True)
        self.assertEquals(self.RESULT_22, result)

        result = exec_payload(self.shell, 'portscan',
                              args=('localhost', '23'),
                              use_api=True)
        self.assertEquals(self.RESULT_23, result)
开发者ID:0x554simon,项目名称:w3af,代码行数:10,代码来源:test_portscan.py

示例3: _payload

    def _payload(self, parameters):
        """
        Handle the payload command:
            - payload desc list_processes -> return payload description
            - payload list_processes      -> run payload

        :param payload_name: The name of the payload I want to run.
        :param parameters: The parameters as sent by the user.
        """
        #
        #    Handle payload desc xyz
        #
        if len(parameters) == 2:
            if parameters[0] == 'desc':
                payload_name = parameters[1]

                if payload_name not in payload_handler.get_payload_list():
                    return 'Unknown payload name: "%s"' % payload_name

                return payload_handler.get_payload_desc(payload_name)

        #
        #    Handle payload xyz
        #
        payload_name = parameters[0]
        parameters = parameters[1:]

        if payload_name not in payload_handler.get_payload_list():
            return 'Unknown payload name: "%s"' % payload_name

        if payload_name in payload_handler.runnable_payloads(self):
            om.out.debug(
                'Payload %s can be run. Starting execution.' % payload_name)

            # Note: The payloads are actually writing to om.out.console
            # so there is no need to get the result. If someone wants to
            # get the results in a programatic way they should execute the
            # payload with use_api=True.
            try:
                payload_handler.exec_payload(self, payload_name, parameters)
                result = None
            except TypeError:
                # We get here when the user calls the payload with an incorrect
                # number of parameters:
                payload = payload_handler.get_payload_instance(
                    payload_name, self)
                result = payload.get_desc()
            except ValueError, ve:
                # We get here when one of the parameters provided by the user is
                # not of the correct type, or something like that.
                result = str(ve)
开发者ID:3rdDegree,项目名称:w3af,代码行数:51,代码来源:shell.py

示例4: test_exec_payload_read

    def test_exec_payload_read(self):
        shell = FakeReadShell()
        result = exec_payload(shell, 'os_fingerprint', use_api=True)
        self.assertEquals({'os': 'Linux'}, result)

        result = exec_payload(shell, 'cpu_info', use_api=True)
        # On my box the result is:
        #
        # {'cpu_info': 'AMD Phenom(tm) II X4 945 Processor', 'cpu_cores': '4'}
        #
        # But because others will also run this, I don't want to make it so
        # strict
        self.assertTrue('cpu_info' in result)
        self.assertTrue('cpu_cores' in result)
        self.assertGreater(int(result['cpu_cores']), 0)
        self.assertLess(int(result['cpu_cores']), 12)
开发者ID:0x554simon,项目名称:w3af,代码行数:16,代码来源:test_payload_handler.py

示例5: test_uptime

    def test_uptime(self):
        result = exec_payload(self.shell, 'uptime', use_api=True)

        for key in self.EXPECTED_RESULT:
            for time_unit in self.EXPECTED_RESULT[key]:
                self.assertTrue(
                    self.EXPECTED_RESULT[key][time_unit].isdigit())
开发者ID:0x554simon,项目名称:w3af,代码行数:7,代码来源:test_uptime.py

示例6: test_apache_mod_security

 def test_apache_mod_security(self):
     result = exec_payload(self.shell, 'apache_mod_security', use_api=True)
     
     self.assertEquals(self.EXPECTED_RESULT['version'], result['version'])
     self.assertIn('/etc/apache2/mods-available/mod-security.conf', result['file'])
     
     file_content = result['file']['/etc/apache2/mods-available/mod-security.conf']
     self.assertIn('<IfModule security2_module>', file_content)
开发者ID:0x554simon,项目名称:w3af,代码行数:8,代码来源:test_apache_mod_security.py

示例7: test_udp

    def test_udp(self):
        result = exec_payload(self.shell, 'udp', use_api=True)

        local_addresses = []
        for key, conn_data in result.iteritems():
            local_addresses.append(conn_data['local_address'])

        self.assertTrue(set(local_addresses).issuperset(self.EXPECTED_RESULT))
开发者ID:3rdDegree,项目名称:w3af,代码行数:8,代码来源:test_udp.py

示例8: test_current_user

    def test_current_user(self):
        result = exec_payload(self.shell, "current_user", use_api=True)

        user = result["current"]["user"]
        self.assertEquals(self.EXPECTED_RESULT["current"]["user"], user)

        home = result["current"]["home"]
        self.assertTrue(home.startswith(self.EXPECTED_RESULT["current"]["home"]), home)
开发者ID:masterapocalyptic,项目名称:Tortazo-spanishtranslate,代码行数:8,代码来源:test_current_user.py

示例9: test_tcp

    def test_tcp(self):
        result = exec_payload(self.shell, 'tcp', use_api=True)

        local_addresses = []
        for key, conn_data in result.iteritems():
            local_addresses.append(conn_data['local_address'])

        for expected_local_address in self.EXPECTED_RESULT:
            self.assertIn(expected_local_address, local_addresses)
开发者ID:breakthesec,项目名称:w3af,代码行数:9,代码来源:test_tcp.py

示例10: test_list_processes

    def test_list_processes(self):
        result = exec_payload(
            self.shell, 'list_processes', args=(2000,), use_api=True)

        cmds = []
        for _, pid_data in result.iteritems():
            cmds.append(pid_data['cmd'])

        for expected in self.EXPECTED_RESULT:
            self.assertIn(expected, cmds)
开发者ID:0x554simon,项目名称:w3af,代码行数:10,代码来源:test_list_processes.py

示例11: test_get_source_code

    def test_get_source_code(self):
        temp_dir = tempfile.mkdtemp()
        result = exec_payload(self.shell, 'get_source_code', args=(temp_dir,),
                              use_api=True)

        self.assertEqual(len(self.EXPECTED_RESULT.keys()), 1)

        expected_url = self.EXPECTED_RESULT.keys()[0]
        downloaded_url = result.items()[0][0].url_string
        self.assertEquals(expected_url, downloaded_url)

        downloaded_file_path = result.items()[0][1][1]
        downloaded_file_content = file(downloaded_file_path).read()
        self.assertTrue(self.CONTENT in downloaded_file_content)

        shutil.rmtree(temp_dir)
开发者ID:0x554simon,项目名称:w3af,代码行数:16,代码来源:test_get_source_code.py

示例12: test_route

    def test_route(self):
        result = exec_payload(self.shell, 'route', use_api=True)
        routes = result['route']

        for route_info in routes:
            dest = route_info['Destination']
            gw = route_info['Gateway']
            iface = route_info['Iface']
            mask = route_info['Mask']

            self.assertEqual(dest.count('.'), 3)
            self.assertEqual(gw.count('.'), 3)
            self.assertEqual(mask.count('.'), 3)
            
            self.assertTrue(iface.startswith('eth') or
                            iface.startswith('wlan') or
                            iface.startswith('ppp') or
                            iface.startswith('vbox') or
                            iface.startswith('lxcbr') or
                            iface.startswith('lo'), iface)
开发者ID:3rdDegree,项目名称:w3af,代码行数:20,代码来源:test_route.py

示例13: test_route

    def test_route(self):
        result = exec_payload(self.shell, "route", use_api=True)
        routes = result["route"]

        for route_info in routes:
            dest = route_info["Destination"]
            gw = route_info["Gateway"]
            iface = route_info["Iface"]
            mask = route_info["Mask"]

            self.assertEqual(dest.count("."), 3)
            self.assertEqual(gw.count("."), 3)
            self.assertEqual(mask.count("."), 3)

            self.assertTrue(
                iface.startswith("eth")
                or iface.startswith("wlan")
                or iface.startswith("ppp")
                or iface.startswith("vbox")
                or iface.startswith("lxcbr")
                or iface.startswith("docker")
                or iface.startswith("lo"),
                iface,
            )
开发者ID:ZionOps,项目名称:w3af,代码行数:24,代码来源:test_route.py

示例14: test_php_sca

 def test_php_sca(self):
     result = exec_payload(self.shell, 'php_sca', use_api=True)
     self.assertEquals(self.EXPECTED_RESULT, result.keys()[0])
开发者ID:0x554simon,项目名称:w3af,代码行数:3,代码来源:test_php_sca.py

示例15: test_ssh_version

 def test_ssh_version(self):
     result = exec_payload(self.shell, 'ssh_version', use_api=True)
     self.assertEquals(self.EXPECTED_RESULT, result)
开发者ID:0x554simon,项目名称:w3af,代码行数:3,代码来源:test_ssh_version.py


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