From 9b9e30a8bf6edc71e862e95ca9e5d02a9e0e2b95 Mon Sep 17 00:00:00 2001 From: hugsy Date: Sun, 4 Feb 2024 14:44:29 -0800 Subject: [PATCH] update default prompt to see which mode gef runs under --- gef.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/gef.py b/gef.py index 46f467971..537617dd9 100644 --- a/gef.py +++ b/gef.py @@ -10438,9 +10438,7 @@ def __gef_prompt__(current_prompt: Callable[[Callable], str]) -> str: """GEF custom prompt function.""" if gef.config["gef.readline_compat"] is True: return GEF_PROMPT if gef.config["gef.disable_color"] is True: return GEF_PROMPT - prompt = "" - if gef.session.remote: - prompt += Color.boldify("(remote) ") + prompt = gef.session.remote.mode.prompt_string() if gef.session.remote else "" prompt += GEF_PROMPT_ON if is_alive() else GEF_PROMPT_OFF return prompt @@ -11095,6 +11093,15 @@ def __str__(self): def __repr__(self): return f"RemoteMode = {str(self)} ({int(self)})" + def prompt_string(self) -> str: + if self == GefRemoteSessionManager.RemoteMode.QEMU: + return Color.boldify("(qemu) ") + if self == GefRemoteSessionManager.RemoteMode.RR: + return Color.boldify("(rr) ") + if self == GefRemoteSessionManager.RemoteMode.GDBSERVER: + return Color.boldify("(remote) ") + raise AttributeError("Unknown value") + def __init__(self, host: str, port: int, pid: int =-1, qemu: Optional[pathlib.Path] = None) -> None: super().__init__() self.__host = host