From fcc1a5660ec60066b4fbb31eb7582cdfd55a4b20 Mon Sep 17 00:00:00 2001 From: Olivier Bilodeau Date: Thu, 18 Jan 2024 21:17:15 -0500 Subject: [PATCH] added --version (or -V) to all CLI tools --- pyrdp/bin/clonecert.py | 12 ++++++++++-- pyrdp/bin/convert.py | 10 +++++++++- pyrdp/bin/player.py | 10 +++++++++- pyrdp/mitm/cli.py | 10 +++++++++- 4 files changed, 37 insertions(+), 5 deletions(-) diff --git a/pyrdp/bin/clonecert.py b/pyrdp/bin/clonecert.py index ee4d6e679..f37b60f49 100755 --- a/pyrdp/bin/clonecert.py +++ b/pyrdp/bin/clonecert.py @@ -2,7 +2,7 @@ # # This file is part of the PyRDP project. -# Copyright (C) 2018-2023 GoSecure Inc. +# Copyright (C) 2018-2024 GoSecure Inc. # Licensed under the GPLv3 or later. # # Need to install this reactor before importing any other code @@ -18,6 +18,7 @@ import argparse import logging import sys +from importlib.metadata import version import OpenSSL from twisted.application.reactors import Reactor @@ -111,6 +112,13 @@ def prepareLoggers(logLevel: int): def main(): parser = argparse.ArgumentParser() + parser.add_argument( + "-V", + "--version", + help="Show the PyRDP version and exit", + action="version", + version=f"PyRDP version v{version('pyrdp-mitm')}" + ) parser.add_argument("host", help="RDP host to clone") parser.add_argument("out_file", help="Output certificate file name") parser.add_argument("-p", "--port", help="RDP port of the host (default 3389)", default=3389, type=int) @@ -194,4 +202,4 @@ def main(): if __name__ == "__main__": - main() \ No newline at end of file + main() diff --git a/pyrdp/bin/convert.py b/pyrdp/bin/convert.py index bbe2685bc..1516d0d74 100755 --- a/pyrdp/bin/convert.py +++ b/pyrdp/bin/convert.py @@ -2,12 +2,13 @@ # # This file is part of the PyRDP project. -# Copyright (C) 2020-2023 GoSecure Inc. +# Copyright (C) 2020-2024 GoSecure Inc. # Licensed under the GPLv3 or later. # import argparse import logging import sys +from importlib.metadata import version from pathlib import Path from pyrdp.convert.PCAPConverter import PCAPConverter @@ -20,6 +21,13 @@ def main(): parser = argparse.ArgumentParser() parser.add_argument("input", help="Path to a .pcap or .pyrdp file. " "Converting from a .pcap will always extract file transfer artifacts in addition to the actual replay.") + parser.add_argument( + "-V", + "--version", + help="Show the PyRDP version and exit", + action="version", + version=f"PyRDP version v{version('pyrdp-mitm')}" + ) parser.add_argument( "-l", "--list-only", diff --git a/pyrdp/bin/player.py b/pyrdp/bin/player.py index 23e5f1e06..d5edea91f 100755 --- a/pyrdp/bin/player.py +++ b/pyrdp/bin/player.py @@ -2,7 +2,7 @@ # # This file is part of the PyRDP project. -# Copyright (C) 2018-2022 GoSecure Inc. +# Copyright (C) 2018-2024 GoSecure Inc. # Licensed under the GPLv3 or later. # # Need to install this reactor before importing any other code @@ -16,6 +16,7 @@ asyncioreactor.install(asyncio.new_event_loop()) from pathlib import Path +from importlib.metadata import version import argparse import logging import logging.handlers @@ -63,6 +64,13 @@ def main(): parser.add_argument("-F", "--log-filter", help="Only show logs from this logger name (accepts '*' wildcards)", default=None) parser.add_argument("--headless", help="Parse a replay without rendering the user interface.", action="store_true") + parser.add_argument( + "-V", + "--version", + help="Show the PyRDP version and exit", + action="version", + version=f"PyRDP version v{version('pyrdp-mitm')}" + ) args = parser.parse_args() cfg = settings.load(f'{settings.CONFIG_DIR}/player.ini', DEFAULTS) diff --git a/pyrdp/mitm/cli.py b/pyrdp/mitm/cli.py index 146404938..a0898cef6 100644 --- a/pyrdp/mitm/cli.py +++ b/pyrdp/mitm/cli.py @@ -1,6 +1,6 @@ # # This file is part of the PyRDP project. -# Copyright (C) 2020-2022 GoSecure Inc. +# Copyright (C) 2020-2024 GoSecure Inc. # Licensed under the GPLv3 or later. # @@ -14,6 +14,7 @@ import os import sys from base64 import b64encode +from importlib.metadata import version from pathlib import Path from typing import Tuple @@ -131,6 +132,13 @@ def buildArgParser(): parser.add_argument("--nla-redirection-host", help="Redirection target ip if NLA is enforced", default=None) parser.add_argument("--nla-redirection-port", help="Redirection target port if NLA is enforced", type=int, default=None) parser.add_argument("--ssp-challenge", help="Set challenge for SSP authentictation (e.g. 1122334455667788). Incompatible with --auth ssp.", type=str, default=None) + parser.add_argument( + "-V", + "--version", + help="Show the PyRDP version and exit", + action="version", + version=f"PyRDP version v{version('pyrdp-mitm')}" + ) return parser