1
0
mirror of https://github.com/calebstewart/pwncat.git synced 2024-11-27 19:04:15 +01:00

Added lpwd and lcd commands for local cwd changes

Also updated the documentation to reflect the new commands. Ran tests
and formatting requirements. Fixes #218.
This commit is contained in:
Caleb Stewart 2021-11-28 15:52:07 -05:00
parent 7f8531f7ed
commit 9db70d10ed
7 changed files with 73 additions and 0 deletions

View File

@ -32,6 +32,7 @@ and simply didn't have the time to go back and retroactively create one.
- Added `OSError` for `bind` protocol to show appropriate error messages - Added `OSError` for `bind` protocol to show appropriate error messages
- Contributing guidelines for GitHub maintainers - Contributing guidelines for GitHub maintainers
- Installation instructions for BlackArch - Installation instructions for BlackArch
- Added `lpwd` and `lcd` commands to interact with the local working directory ([#218](https://github.com/calebstewart/pwncat/issues/218))
### Changed ### Changed
- Removed handling of `shell` argument to `Popen` to prevent `euid` problems ([#179](https://github.com/calebstewart/pwncat/issues/179)) - Removed handling of `shell` argument to `Popen` to prevent `euid` problems ([#179](https://github.com/calebstewart/pwncat/issues/179))
- Changed some 'red' warning message color to 'yellow' - Changed some 'red' warning message color to 'yellow'

View File

@ -10,4 +10,6 @@ zodburi==2.4.0
jinja2 jinja2
paramiko==2.7.2 paramiko==2.7.2
sphinx-toolbox==2.11.2 sphinx-toolbox==2.11.2
apeye<1.0.0
enum-tools==0.6.4 enum-tools==0.6.4
sphinx_rtd_theme==1.0.0

View File

@ -12,7 +12,9 @@ Command index
connect.rst connect.rst
download.rst download.rst
escalate.rst escalate.rst
lcd.rst
load.rst load.rst
lpwd.rst
run.rst run.rst
info.rst info.rst
search.rst search.rst

View File

@ -0,0 +1,14 @@
lcd
===
The ``lcwd`` command allows you to change the *local* working directory of the running
pwncat instance. This effects any command which interacts with the local filesystem (
e.g. ``upload`` and ``download``).
.. code-block:: bash
# Example from @DanaEpp :P
lcd ~/engagements/client_some_gawd_aweful_guid/host_abc/loot
# Now, the following downloads will end up in the above directory
download /path/to/some/loot
download /paht/to/some/other/loot

View File

@ -0,0 +1,10 @@
lpwd
====
The ``lpwd`` directory will print the current *local* working directory. This is the directory
which commands like ``upload`` and ``download`` will interpret as ``.``.
.. code-block:: bash
# Print the local working directory
lpwd

27
pwncat/commands/lcd.py Normal file
View File

@ -0,0 +1,27 @@
#!/usr/bin/env python3
import os
import pathlib
import pwncat
from pwncat.commands import Complete, Parameter, CommandDefinition
class Command(CommandDefinition):
"""Change the local current working directory"""
PROG = "lcd"
ARGS = {
"path": Parameter(Complete.LOCAL_FILE),
}
def run(self, manager: "pwncat.manager.Manager", args):
# Expand `~`
path = pathlib.Path(args.path).expanduser()
# Ensure the directory exists
if not path.is_dir():
self.parser.error(f"{path}: not a directory")
# Change to that directory
os.chdir(str(path))

17
pwncat/commands/lpwd.py Normal file
View File

@ -0,0 +1,17 @@
#!/usr/bin/env python3
from pathlib import Path
import pwncat
from pwncat.util import console
from pwncat.commands import CommandDefinition
class Command(CommandDefinition):
"""Print the local current working directory"""
PROG = "lpwd"
ARGS = {}
def run(self, manager: "pwncat.manager.Manager", args):
console.print(Path.cwd())