def start(self):
        L.debug("Starting packet capture on interface {}".format(
            self._interface))
        if self._popen:
            raise XVEx("Packet capture already started!")

        binary = os.path.join(os.path.dirname(os.path.realpath(__file__)),
                              "..", "bin", "xv_packet_capture.exe")

        os.path.join(self._device.temp_directory(),
                     WindowsGoPacketCapturer._random_pid_file())

        binary = windows_real_path(binary)
        output_directory = windows_real_path(self._device.temp_directory())
        cmd = [
            'cmd.exe', '/c', binary, '-i',
            str(self._interface), '-o', output_directory, '-f',
            self._capture_file, '-m', 'windump', '--preserve', '--debug'
        ]

        stdout = os.path.join(self._device.temp_directory(),
                              "{}.stdout".format(self._capture_file))
        stderr = os.path.join(self._device.temp_directory(),
                              "{}.stderr".format(self._capture_file))

        # TODO: Check for errors once opened?
        L.debug("Starting packet capture: {}".format(cmd))
        makedirs_safe(self._device.temp_directory())
        with open(stdout, "w") as out, open(stderr, "w") as err:
            self._popen = subprocess.Popen(cmd, stdout=out, stderr=err)

        self._pid = self._find_windows_pid()
示例#2
0
 def block_application(full_path, direction="out"):
     full_path = windows_real_path(full_path)
     L.info(
         "Creating firewall rule to block application {}".format(full_path))
     return WindowsAdvFirewall.create_rule("block",
                                           program=full_path,
                                           direction=direction)
 def open_app(self, app_path, root=False):  # pylint: disable=unused-argument
     # TODO: Oh dear god. This was painful!
     # Note that this can fail in a bad way. If start fails then it will pop a dialog box and
     # freeze everything. Need a better solution to this. Make sure paths are correct for now!
     head, tail = windows_path_split(app_path)
     cmd = [
         'cmd', '/C', 'start', '/D',
         "\"{}\"".format(windows_real_path(head)), tail
     ]
     L.debug("Executing cmd '{}'".format(cmd))
     self._connector_helper.check_command(cmd)
    def _start_server(self):
        root_folder = os.path.join(os.path.dirname(__file__), 'support',
                                   'ice_lookup')
        if self._host_remotely:
            # TODO: Don't hardcode port
            return self._localhost['webserver'].start_server(root_folder,
                                                             6666,
                                                             https=True)

        # If we're using cygwin then the browser won't be able to find the file unless we convert
        # to the real windows path. This is safe to call on other OSes
        return "file://{}".format(
            windows_real_path(os.path.abspath(root_folder)))