(self, _: List[str], **kwargs: Any)
| 5937 | |
| 5938 | @parse_arguments({"host": "", "port": 0}, {"--pid": -1, "--qemu-user": True, "--qemu-binary": ""}) |
| 5939 | def do_invoke(self, _: List[str], **kwargs: Any) -> None: |
| 5940 | if gef.session.remote is not None: |
| 5941 | err("You already are in remote session. Close it first before opening a new one...") |
| 5942 | return |
| 5943 | |
| 5944 | # argument check |
| 5945 | args : argparse.Namespace = kwargs["arguments"] |
| 5946 | if not args.host or not args.port: |
| 5947 | err("Missing parameters") |
| 5948 | return |
| 5949 | |
| 5950 | # qemu-user support |
| 5951 | qemu_binary: Optional[pathlib.Path] = None |
| 5952 | try: |
| 5953 | if args.qemu_user: |
| 5954 | qemu_binary = pathlib.Path(args.qemu_binary).expanduser().absolute() if args.qemu_binary else gef.session.file |
| 5955 | if not qemu_binary or not qemu_binary.exists(): |
| 5956 | raise FileNotFoundError(f"{qemu_binary} does not exist") |
| 5957 | except Exception as e: |
| 5958 | err(f"Failed to initialize qemu-user mode, reason: {str(e)}") |
| 5959 | return |
| 5960 | |
| 5961 | # try to establish the remote session, throw on error |
| 5962 | # Set `.remote_initializing` to True here - `GefRemoteSessionManager` invokes code which |
| 5963 | # calls `is_remote_debug` which checks if `remote_initializing` is True or `.remote` is None |
| 5964 | # This prevents some spurious errors being thrown during startup |
| 5965 | gef.session.remote_initializing = True |
| 5966 | gef.session.remote = GefRemoteSessionManager(args.host, args.port, args.pid, qemu_binary) |
| 5967 | gef.session.remote_initializing = False |
| 5968 | reset_all_caches() |
| 5969 | gdb.execute("context") |
| 5970 | return |
| 5971 | |
| 5972 | |
| 5973 | @register |
nothing calls this directly
no test coverage detected