mirror of
https://github.com/calebstewart/pwncat.git
synced 2024-11-24 01:25:37 +01:00
Fixed config argument processing
This commit is contained in:
parent
64a5cdd06c
commit
56e73a6c37
@ -32,7 +32,7 @@ def main():
|
|||||||
"--config",
|
"--config",
|
||||||
"-c",
|
"-c",
|
||||||
type=argparse.FileType("r"),
|
type=argparse.FileType("r"),
|
||||||
default="./pwncatrc",
|
default=None,
|
||||||
help="Custom configuration file (default: ./pwncatrc)",
|
help="Custom configuration file (default: ./pwncatrc)",
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
|
@ -268,14 +268,19 @@ class Manager:
|
|||||||
|
|
||||||
# Load local configuration script
|
# Load local configuration script
|
||||||
if isinstance(config, str):
|
if isinstance(config, str):
|
||||||
try:
|
with open(config) as filp:
|
||||||
with open(config) as filp:
|
self.parser.eval(filp.read(), config)
|
||||||
self.parser.eval(filp.read(), config)
|
|
||||||
except (FileNotFoundError, PermissionError):
|
|
||||||
pass
|
|
||||||
elif config is not None:
|
elif config is not None:
|
||||||
self.parser.eval(config.read(), config.name)
|
self.parser.eval(config.read(), config.name)
|
||||||
config.close()
|
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):
|
def open_database(self):
|
||||||
"""Create the internal engine and session builder
|
"""Create the internal engine and session builder
|
||||||
|
Loading…
Reference in New Issue
Block a user