From e735c40acb2a5f0d9607d5e8f4e10c2b42787206 Mon Sep 17 00:00:00 2001 From: Caleb Stewart Date: Sun, 26 Dec 2021 02:33:03 -0500 Subject: [PATCH 1/3] Fixed --ssl argument processing in main entrypoint --- pwncat/__main__.py | 60 ++++++++++++++++---------------------- pwncat/commands/connect.py | 56 +++++++++++++++-------------------- 2 files changed, 48 insertions(+), 68 deletions(-) diff --git a/pwncat/__main__.py b/pwncat/__main__.py index 6d34813..88152df 100644 --- a/pwncat/__main__.py +++ b/pwncat/__main__.py @@ -233,9 +233,9 @@ def main(): if query_args["certfile"] is not None or query_args["keyfile"] is not None: query_args["ssl"] = True - if query_args["protocol"] is not None and args.ssl: + if query_args["protocol"] not in [None, "bind", "connect"] and args.ssl: console.log( - "[red]error[/red]: --ssl is incompatible with an explicit protocol" + f"[red]error[/red]: --ssl is incompatible with an [yellow]{query_args['protocol']}[/yellow] protocol" ) return @@ -296,41 +296,31 @@ def main(): if "implant.remote" in fact.types: implants.append((target, users[fact.uid], fact)) - with Progress( - "triggering implant", - "•", - "{task.fields[status]}", - transient=True, - console=console, - ) as progress: - task = progress.add_task("", status="...") - for target, implant_user, implant in implants: - # Check correct query_args["user"] - if ( - query_args["user"] is not None - and implant_user.name != query_args["user"] - ): - continue - # Check correct platform - if ( - query_args["platform"] is not None - and target.platform != query_args["platform"] - ): - continue + for target, implant_user, implant in implants: + # Check correct query_args["user"] + if ( + query_args["user"] is not None + and implant_user.name != query_args["user"] + ): + continue + # Check correct platform + if ( + query_args["platform"] is not None + and target.platform != query_args["platform"] + ): + continue - progress.update( - task, status=f"trying [cyan]{implant.source}[/cyan]" - ) + manager.log(f"trigger implant: [cyan]{implant.source}[/cyan]") - # Attempt to trigger a new session - try: - session = implant.trigger(manager, target) - manager.target = session - used_implant = implant - break - except ModuleFailed: - db.transaction_manager.commit() - continue + # Attempt to trigger a new session + try: + session = implant.trigger(manager, target) + manager.target = session + used_implant = implant + break + except ModuleFailed: + db.transaction_manager.commit() + continue if manager.target is not None: manager.target.log( diff --git a/pwncat/commands/connect.py b/pwncat/commands/connect.py index ce40abb..50d1708 100644 --- a/pwncat/commands/connect.py +++ b/pwncat/commands/connect.py @@ -255,41 +255,31 @@ class Command(CommandDefinition): if "implant.remote" in fact.types: implants.append((target, users[fact.uid], fact)) - with Progress( - "triggering implant", - "•", - "{task.fields[status]}", - transient=True, - console=console, - ) as progress: - task = progress.add_task("", status="...") - for target, implant_user, implant in implants: - # Check correct query_args["user"] - if ( - query_args["user"] is not None - and implant_user.name != query_args["user"] - ): - continue - # Check correct platform - if ( - query_args["platform"] is not None - and target.platform != query_args["platform"] - ): - continue + for target, implant_user, implant in implants: + # Check correct query_args["user"] + if ( + query_args["user"] is not None + and implant_user.name != query_args["user"] + ): + continue + # Check correct platform + if ( + query_args["platform"] is not None + and target.platform != query_args["platform"] + ): + continue - progress.update( - task, status=f"trying [cyan]{implant.source}[/cyan]" - ) + manager.log(f"trigger implant: [cyan]{implant.source}[/cyan]") - # Attempt to trigger a new session - try: - session = implant.trigger(manager, target) - manager.target = session - used_implant = implant - break - except (ChannelError, PlatformError, ModuleFailed): - db.transaction_manager.commit() - continue + # Attempt to trigger a new session + try: + session = implant.trigger(manager, target) + manager.target = session + used_implant = implant + break + except (ChannelError, PlatformError, ModuleFailed): + db.transaction_manager.commit() + continue if used_implant is not None: manager.target.log(f"connected via {used_implant.title(manager.target)}") From 875939f4c8804b55212721d6bdd7daca49a6bb4f Mon Sep 17 00:00:00 2001 From: Caleb Stewart Date: Sun, 26 Dec 2021 02:35:16 -0500 Subject: [PATCH 2/3] Added changelog for ssl fixes --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index fd0ec98..fe849bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 The Changelog starts with v0.4.1, because we did not keep one before that, and simply didn't have the time to go back and retroactively create one. +## [Unreleased] + +### Changed +- Fixed parsing of `--ssl` argument in main entrypoint ([#225](https://github.com/calebstewart/pwncat/issues/225)) + ## [0.5.1] - 2021-12-07 Minor bug fixes. Mainly typos from changing the package name. From b931f945c1a9f111c116aaf4f8365ae174b49556 Mon Sep 17 00:00:00 2001 From: Caleb Stewart Date: Sun, 26 Dec 2021 02:36:48 -0500 Subject: [PATCH 3/3] Fixed flake8 warning --- pwncat/commands/connect.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pwncat/commands/connect.py b/pwncat/commands/connect.py index 50d1708..2c94c51 100644 --- a/pwncat/commands/connect.py +++ b/pwncat/commands/connect.py @@ -4,7 +4,6 @@ import sys from rich import box from rich.table import Table -from rich.progress import Progress import pwncat from pwncat.util import console