mirror of
https://github.com/calebstewart/pwncat.git
synced 2024-11-27 19:04:15 +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
|
from typing import Any, Dict, List
|
||||||
|
|
||||||
import pwncat
|
|
||||||
import rich.markup
|
import rich.markup
|
||||||
|
|
||||||
|
import pwncat
|
||||||
from pwncat import util
|
from pwncat import util
|
||||||
from pwncat.db import Fact
|
from pwncat.db import Fact
|
||||||
from pwncat.modules import ModuleFailed
|
from pwncat.modules import ModuleFailed
|
||||||
from pwncat.modules.enumerate import EnumerateModule, Schedule
|
|
||||||
from pwncat.platform import PlatformError
|
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):
|
class ClipboardData(Fact):
|
||||||
def __init__(self, source, contents:str):
|
def __init__(self, source, contents: str):
|
||||||
super().__init__(source=source, types=["system.clipboard"])
|
super().__init__(source=source, types=["system.clipboard"])
|
||||||
|
|
||||||
self.contents: bool = contents
|
self.contents: bool = contents
|
||||||
|
|
||||||
|
|
||||||
def title(self, session):
|
def title(self, session):
|
||||||
return f"Current clipboard contents:"
|
return f"Current clipboard contents:"
|
||||||
|
|
||||||
def description(self, session):
|
def description(self, session):
|
||||||
return f"[yellow]{rich.markup.escape(self.contents)}[/yellow]"
|
return f"[yellow]{rich.markup.escape(self.contents)}[/yellow]"
|
||||||
|
|
||||||
@ -33,25 +34,18 @@ class Module(EnumerateModule):
|
|||||||
|
|
||||||
def enumerate(self, session):
|
def enumerate(self, session):
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
result = session.platform.powershell(
|
result = session.platform.powershell(f"Get-Clipboard")
|
||||||
f"Get-Clipboard"
|
|
||||||
)
|
|
||||||
|
|
||||||
if not result:
|
if not result:
|
||||||
raise ModuleFailed(
|
return
|
||||||
f"failed to retrieve clipboard contents"
|
|
||||||
)
|
|
||||||
|
|
||||||
if isinstance(result[0],list):
|
if isinstance(result[0], list) and result:
|
||||||
contents = "\n".join(result[0])
|
contents = "\n".join(result[0])
|
||||||
else:
|
else:
|
||||||
contents = result[0]
|
contents = result[0]
|
||||||
|
|
||||||
except PowershellError as exc:
|
except PowershellError as exc:
|
||||||
raise ModuleFailed(
|
raise ModuleFailed(f"failed to retrieve clipboard contents") from exc
|
||||||
f"failed to retrieve clipboard contents"
|
|
||||||
) from exc
|
|
||||||
|
|
||||||
yield ClipboardData(self.name, contents)
|
yield ClipboardData(self.name, contents)
|
||||||
|
@ -25,6 +25,7 @@ import signal
|
|||||||
import pathlib
|
import pathlib
|
||||||
import tarfile
|
import tarfile
|
||||||
import termios
|
import termios
|
||||||
|
import binascii
|
||||||
import readline
|
import readline
|
||||||
import textwrap
|
import textwrap
|
||||||
import subprocess
|
import subprocess
|
||||||
@ -475,7 +476,12 @@ class Windows(Platform):
|
|||||||
if wait:
|
if wait:
|
||||||
|
|
||||||
# Receive the response
|
# Receive the response
|
||||||
result = self.parse_response(self.channel.recvline())
|
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
|
# Raise an appropriate error if needed
|
||||||
if result["error"] != 0:
|
if result["error"] != 0:
|
||||||
|
Loading…
Reference in New Issue
Block a user