Skip to content

Commit

Permalink
Merge pull request calebstewart#226 from calebstewart/issue-225-ssl-p…
Browse files Browse the repository at this point in the history
…arsing

Issue 225 ssl parsing
  • Loading branch information
calebstewart committed Dec 26, 2021
2 parents f8f9598 + b931f94 commit 7c1eb98
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 72 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
62 changes: 26 additions & 36 deletions pwncat/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

progress.update(
task, status=f"trying [cyan]{implant.source}[/cyan]"
)
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

# 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
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

if manager.target is not None:
manager.target.log(
Expand Down
61 changes: 25 additions & 36 deletions pwncat/commands/connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

from rich import box
from rich.table import Table
from rich.progress import Progress

import pwncat
from pwncat.util import console
Expand Down Expand Up @@ -255,41 +254,31 @@ def run(self, manager: "pwncat.manager.Manager", args):
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

progress.update(
task, status=f"trying [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
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

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

if used_implant is not None:
manager.target.log(f"connected via {used_implant.title(manager.target)}")
Expand Down

0 comments on commit 7c1eb98

Please sign in to comment.