'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.'

def get_transfer_handler(self, inbound_port=None):

    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)
    else:
        echo_transfer = EchoLinux(self._exec_method, os)
    to_test = [echo_transfer]
    try:
        if (not inbound_port):
            inbound_port = self._es.get_inbound_port()
    except BaseFrameworkException as w3:
        msg = 'The    extrusion    scan    failed,    no    reverse    connect    transfer    methods    can    be    used.    Trying    inband    echo    transfer    method.    Error:    "%s"'
        om.out.error((msg % w3))
    except Exception as e:
        om.out.error(('Unhandled    exception:    "%s"' % e))
    else:
        to_test.append(ReverseFTP(self._exec_method, os, inbound_port))
        if (os == 'windows'):
            pass
        elif (os == 'linux'):
            reverse = ClientlessReverseHTTP(self._exec_method, os, inbound_port)
            to_test.append(reverse)
        def sort_function(x, y):
            return cmp(y.get_speed(), x.get_speed())
        to_test.sort(sort_function)
    for method in to_test:
        om.out.debug(('Testing    if    "%s"    is    able    to    transfer    a    file    to    the    compromised    host.' % method))
        if method.can_transfer():
            om.out.debug(('%s    is    able    to    transfer    a    file    to    the    compromised    host.' % method))
            return method
        else:
            om.out.debug(('%s    *FAILED*    to    transfer    a    file    to    the    compromised    host.' % method))
    raise BaseFrameworkException('Failed    to    transfer    the    file    to    the    remote    host.    All    the    transfer    methods    failed.    See    the    debug    log    for    more    information    and    potential    workarounds    for    this    issue.')
