from pexpect import replwrap
from fortrace.utility.console_applications.console_application import (
GenericConsoleApplication,
)
from fortrace.utility.console_applications.metasploit_console import MetasploitConsole
from fortrace.utility.console_applications.text_editor.text_editor_factory import (
get_console_text_editor,
text_editors,
)
[docs]
def get_console_application(
name: str, pty: replwrap.REPLWrapper
) -> GenericConsoleApplication:
"""Factory for construction of console applications.
Args:
name: name of the application (must be matched in this function
pty: handle to pty (used if there is a new prompt in the console application)
Returns:
opened console application
"""
if name in text_editors:
return get_console_text_editor(name, pty)
elif name in ["msfdb", "msfconsole"]:
return MetasploitConsole(pty)
else:
raise ValueError(f"The program {name} is not known")