Beispiel #1
0
    def get_transfer_handler(self, inbound_port=None):
        '''
        Perform an extrusion scan and return a handler that will know how to upload
        files to the remote end. If the caller sends an inbound_port, don't perform
        an extrusion scan, just trust him and use that port.

        :param inbound_port: The port that we should use for reverse connections
        :return: An object with a "transfer" method, which can be called by the user
        in order to upload files.
        '''
        os = os_detection_exec(self._exec_method)
        if os == 'windows':
            echo_transfer = EchoWindows(self._exec_method, os)
        elif os == 'linux':
            echo_transfer = EchoLinux(self._exec_method, os)

        to_test = []
        to_test.append(echo_transfer)
        try:
            if not inbound_port:
                inbound_port = self._es.get_inbound_port()
        except w3afException, w3:
            msg = 'The extrusion scan failed, no reverse connect transfer methods'
            msg += ' can be used. Trying inband echo transfer method. Error: "%s"'
            om.out.error(msg % w3)
Beispiel #2
0
    def test_upload_file(self):
        exec_method = commands.getoutput
        os = 'linux'
        echo_linux = EchoLinux(exec_method, os)

        self.assertTrue(echo_linux.can_transfer())

        file_len = 8195
        file_content = 'A' * file_len
        echo_linux.estimate_transfer_time(file_len)

        temp_file_inst = tempfile.NamedTemporaryFile()
        temp_fname = temp_file_inst.name
        upload_success = echo_linux.transfer(file_content, temp_fname)

        self.assertTrue(upload_success)
Beispiel #3
0
    def __init__(self,
                 exec_method,
                 forceReRun=False,
                 tcpPortList=[25, 80, 53, 1433, 8080],
                 udpPortList=[53, 69, 139, 1025]):
        '''
        :param exec_method: The exec_method used to execute commands on the
                               remote host
        :param forceReRun: If forceReRun is True, the extrusion scanner
                               won't fetch the results from the KB
        '''
        self._exec_method = exec_method
        self._forceReRun = forceReRun
        self._tcp_port_list = tcpPortList
        self._udp_port_list = udpPortList

        os = os_detection_exec(exec_method)
        if os == 'windows':
            self._transferHandler = EchoWindows(exec_method, os)
        elif os == 'linux':
            self._transferHandler = EchoLinux(exec_method, os)