From 5113f79678214a9abd83a12622ac24d3997a675e Mon Sep 17 00:00:00 2001 From: SafaSafari Date: Fri, 9 Aug 2024 05:44:21 +0330 Subject: [PATCH] fix for python >= 12 --- CHANGELOG.md | 1 + pwncat/commands/__init__.py | 7 ++++--- pwncat/manager.py | 5 +++-- pwncat/platform/__init__.py | 2 +- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d0384348..e300b9d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and simply didn't have the time to go back and retroactively create one. ## [Unreleased] ### Fixed +- Fixed running on python >= 12 - Fixed `shlex.join` use with non-str type objects (e.g. `RemotePath`) - Fixed `set` command use with incorrect keys (e.g. `set invalid value`) diff --git a/pwncat/commands/__init__.py b/pwncat/commands/__init__.py index 17fc7cdc..f7e4e02c 100644 --- a/pwncat/commands/__init__.py +++ b/pwncat/commands/__init__.py @@ -433,8 +433,8 @@ def __init__(self, manager: "pwncat.manager.Manager"): if module_name == "base": continue self.commands.append( - loader.find_module(module_name) - .load_module(module_name) + loader.find_spec(module_name) + .loader.load_module(module_name) .Command(manager) ) @@ -788,7 +788,8 @@ def restore_term(self, new_line=True): class CommandLexer(RegexLexer): """Implements a Regular Expression based pygments lexer for dynamically highlighting - the pwncat prompt during typing. The tokens are generated from command definitions.""" + the pwncat prompt during typing. The tokens are generated from command definitions. + """ tokens = {} diff --git a/pwncat/manager.py b/pwncat/manager.py index 393cb012..f9430da8 100644 --- a/pwncat/manager.py +++ b/pwncat/manager.py @@ -388,7 +388,8 @@ def _open_socket(self) -> socket.socket: def _ssl_wrap(self, server: socket.socket) -> ssl.SSLSocket: """Wrap the given server socket in an SSL context and return the new socket. - If the ``ssl`` option is not set, this method simply returns the original socket.""" + If the ``ssl`` option is not set, this method simply returns the original socket. + """ if not self.ssl: return server @@ -934,7 +935,7 @@ def load_modules(self, *paths): # Why is this check *not* part of pkgutil??????? D:< if module_name not in sys.modules: - module = loader.find_module(module_name).load_module(module_name) + module = loader.find_spec(module_name).loader.load_module(module_name) else: module = sys.modules[module_name] diff --git a/pwncat/platform/__init__.py b/pwncat/platform/__init__.py index 13c7e042..20f9bb1c 100644 --- a/pwncat/platform/__init__.py +++ b/pwncat/platform/__init__.py @@ -520,7 +520,7 @@ class RemotePath(base_path, Path): _stat = None def __init__(self, *args): - base_path.__init__(*args) + super().__init__(*args) self.Path = RemotePath """ A concrete Path object for this platform conforming to pathlib.Path """