From 56e73a6c37bd60043be0e5c8b1ef8112254db7f8 Mon Sep 17 00:00:00 2001 From: Caleb Stewart Date: Mon, 15 Feb 2021 14:20:06 -0500 Subject: [PATCH] Fixed config argument processing --- pwncat/__main__.py | 2 +- pwncat/manager.py | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/pwncat/__main__.py b/pwncat/__main__.py index be9e66e..a1a8b13 100644 --- a/pwncat/__main__.py +++ b/pwncat/__main__.py @@ -32,7 +32,7 @@ def main(): "--config", "-c", type=argparse.FileType("r"), - default="./pwncatrc", + default=None, help="Custom configuration file (default: ./pwncatrc)", ) parser.add_argument( diff --git a/pwncat/manager.py b/pwncat/manager.py index 04eecb8..c1f779a 100644 --- a/pwncat/manager.py +++ b/pwncat/manager.py @@ -268,14 +268,19 @@ class Manager: # Load local configuration script if isinstance(config, str): - try: - with open(config) as filp: - self.parser.eval(filp.read(), config) - except (FileNotFoundError, PermissionError): - pass + with open(config) as filp: + self.parser.eval(filp.read(), config) elif config is not None: self.parser.eval(config.read(), config.name) config.close() + else: + try: + # If no config is specified, attempt to load `./pwncatrc` + # but don't fail if it doesn't exist. + with open("./pwncatrc") as filp: + self.parser.eval(filp.read(), "./pwncatrc") + except (FileNotFoundError, PermissionError): + pass def open_database(self): """Create the internal engine and session builder