1
0
mirror of https://github.com/calebstewart/pwncat.git synced 2024-11-24 01:25:37 +01:00

fixed processing output from run_method

This commit is contained in:
Caleb Stewart 2021-06-09 23:03:49 -04:00
parent 04587bffb1
commit 58668d35d7
2 changed files with 17 additions and 17 deletions

View File

@ -2,14 +2,15 @@
from typing import Any, Dict, List
import pwncat
import rich.markup
import pwncat
from pwncat import util
from pwncat.db import Fact
from pwncat.modules import ModuleFailed
from pwncat.modules.enumerate import EnumerateModule, Schedule
from pwncat.platform import PlatformError
from pwncat.platform.windows import PowershellError, Windows
from pwncat.platform.windows import Windows, PowershellError
from pwncat.modules.enumerate import Schedule, EnumerateModule
class ClipboardData(Fact):
@ -18,9 +19,9 @@ class ClipboardData(Fact):
self.contents: bool = contents
def title(self, session):
return f"Current clipboard contents:"
def description(self, session):
return f"[yellow]{rich.markup.escape(self.contents)}[/yellow]"
@ -33,25 +34,18 @@ class Module(EnumerateModule):
def enumerate(self, session):
try:
result = session.platform.powershell(
f"Get-Clipboard"
)
result = session.platform.powershell(f"Get-Clipboard")
if not result:
raise ModuleFailed(
f"failed to retrieve clipboard contents"
)
return
if isinstance(result[0],list):
if isinstance(result[0], list) and result:
contents = "\n".join(result[0])
else:
contents = result[0]
except PowershellError as exc:
raise ModuleFailed(
f"failed to retrieve clipboard contents"
) from exc
raise ModuleFailed(f"failed to retrieve clipboard contents") from exc
yield ClipboardData(self.name, contents)

View File

@ -25,6 +25,7 @@ import signal
import pathlib
import tarfile
import termios
import binascii
import readline
import textwrap
import subprocess
@ -475,7 +476,12 @@ class Windows(Platform):
if wait:
# Receive the response
while True:
try:
result = self.parse_response(self.channel.recvline())
break
except (gzip.BadGzipFile, binascii.Error) as exc:
continue
# Raise an appropriate error if needed
if result["error"] != 0: