-
Notifications
You must be signed in to change notification settings - Fork 257
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
Home directory prefix support #172
base: release-v0.5.0
Are you sure you want to change the base?
Home directory prefix support #172
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the feedback! It now also is implemented for the remote filesystem, with windows support, and has been added to the download command. Maybe it's a good idea to combine ParameterParsers and Completers into a ParameterType? |
I'm crazy late to this conversation, but trying to clean up here. I've been away from this project for a bit. I have a couple implementation comments. We shouldn't need to do the testing for tilde's and such manually. There are routines to do this already.
Regarding the class Command(CommandDefinition):
def expand_remote(self, path):
return self.manager.target.platform.Path(path).expanduser()
ARGS = {
"test": Parameter(Complete.REMOTE_FILE, type=("method", expand_remote))
} Basically, There's two things wrong with that:
Those two problems are pretty easy to solve. First, I can change the # Defined in `pwncat/commands/__init__.py` for all commands to use
def RemotePathType(parser, path):
return parser.manager.target.platform.Path(path).expanduser()
def LocalPathType(parser, path):
return pathlib.Path(path).expanduser()
# Example of usage
class Command(CommandDefinition):
ARGS = {
"test": Parameter(Complete.REMOTE_FILE, type=RemoteFileType)
} The upside with the above implementation is that the resulting I'm going to work with this a bit on my end to see which solution I personally like the best. I'm still not sure if I want the paths to be automatically expanded. In the case of downloading/uploading files, that's true, but it may not always be true, and may cause problems if paths are mutated in the backend of the code without the user knowing what's happening. |
Description of Changes
Ran into an issue where
upload ~/file.txt /tmp/file.txt
errored out on me. Looking into this, I found pwncat doesn't support the home directory prefix.This is just a possible fix I've come up with, I'd love to hear feedback on these changes and if you think I'm heading into the right direction.
The way I've currently done this would also be able to allow for other prefixes to be configured for pwncat at some point. I can imagine wanting to have a prefix like
@
for where I've stored my static binaries.Major Changes Implemented:
~
) supportPre-Merge Tasks
python-black
isort
flake8
on repo, and fixed any new problems w/ modified filespytest
test cases[Unreleased]
)