Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfix/linuxwrite64 #176

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and simply didn't have the time to go back and retroactively create one.

### Fixed
- Possible exception due to _pre-registering_ of `session` with `manager`
- Fixed base64 stream in `LinuxWriter`
### Added
- Added alternatives to `bash` to be used during _shell upgrade_ for a _better shell_
- Added a warning message when a `KeyboardInterrupt` is caught
Expand Down
1 change: 1 addition & 0 deletions pwncat/facts/ability.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ def open(
exit_cmd.encode("utf-8")
),
name=path,
stream=self.method.stream
)

# Automatically decode to the specified encoding if requested
Expand Down
8 changes: 6 additions & 2 deletions pwncat/platform/linux.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import pathlib
import tempfile
import subprocess
import base64
from io import TextIOWrapper, BufferedIOBase, UnsupportedOperation
from typing import List, Union, BinaryIO, Optional, Generator
from subprocess import TimeoutExpired, CalledProcessError
Expand Down Expand Up @@ -382,14 +383,15 @@ class LinuxWriter(BufferedIOBase):
0x7F,
]

def __init__(self, popen, on_close=None, name: str = None):
def __init__(self, popen, on_close=None, name: str = None, stream = Stream.RAW):
super().__init__()

self.popen = popen
self.last_byte = None
self.since_newline = 0
self.on_close = on_close
self.name = name
self.stream = stream

def readable(self):
return False
Expand Down Expand Up @@ -418,7 +420,9 @@ def write(self, b):
if self.popen.poll() is not None:
raise PermissionError("file write failed")

if self.popen.platform.has_pty:
if self.stream is Stream.BASE64:
self.popen.stdin.write(base64.b64encode(b))
elif self.popen.platform.has_pty:
# Control sequences need escaping
translated = []
for idx, c in enumerate(b):
Expand Down