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:
parent
04587bffb1
commit
58668d35d7
@ -2,25 +2,26 @@
|
||||
|
||||
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):
|
||||
def __init__(self, source, contents:str):
|
||||
def __init__(self, source, contents: str):
|
||||
super().__init__(source=source, types=["system.clipboard"])
|
||||
|
||||
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)
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user