From e0f6c0625b0609d7d159fc654e5ebc26c7afb818 Mon Sep 17 00:00:00 2001 From: SafaSafari Date: Fri, 9 Aug 2024 19:27:46 +0330 Subject: [PATCH] fix for python >= 3.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 d038434..e300b9d 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 17fc7cd..f7e4e02 100644 --- a/pwncat/commands/__init__.py +++ b/pwncat/commands/__init__.py @@ -433,8 +433,8 @@ class CommandParser: 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 @@ class CommandParser: 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 393cb01..f9430da 100644 --- a/pwncat/manager.py +++ b/pwncat/manager.py @@ -388,7 +388,8 @@ class Listener(threading.Thread): 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 @@ class Manager: # 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 13c7e04..20f9bb1 100644 --- a/pwncat/platform/__init__.py +++ b/pwncat/platform/__init__.py @@ -520,7 +520,7 @@ class Platform(ABC): _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 """