From 26664ac8e9d9c3f0399a394b763955b8c57bdb95 Mon Sep 17 00:00:00 2001 From: psrok1 Date: Wed, 24 Jul 2024 14:00:32 +0200 Subject: [PATCH] Add 'fetch' command to drakplayground --- drakrun/drakrun/playground.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/drakrun/drakrun/playground.py b/drakrun/drakrun/playground.py index 385f7c98..bd465dea 100644 --- a/drakrun/drakrun/playground.py +++ b/drakrun/drakrun/playground.py @@ -121,7 +121,8 @@ def help(self): usage = dedent( """\ Available commands: - - copy(file_path) # copy file onto vm desktop + - copy(file_path, ) # copy file to guest (by default to vm desktop) + - fetch(remote_path, ) # fetch file from guest (by default into current directory) - mount(iso_path) # mount iso, useful for installing software, e.g. office - drakvuf(plugins) # start drakvuf with provided set of plugins - run(cmd) # run command inside vm @@ -130,9 +131,15 @@ def help(self): ) print(usage) - def copy(self, local): + def copy(self, local, remote=None): local = Path(local) - self.injector.write_file(local, self.desktop / local.name) + remote = WinPath(remote) if remote is not None else self.desktop / local.name + self.injector.write_file(local, remote) + + def fetch(self, remote, local=None): + remote = WinPath(remote) + local = Path(local) if local is not None else Path(".") / remote.name + self.injector.read_file(remote, local) def mount(self, local_iso_path, drive=FIRST_CDROM_DRIVE): local_iso_path = Path(local_iso_path) @@ -179,6 +186,7 @@ def main(): helpers = { "help": shell.help, "copy": shell.copy, + "fetch": shell.fetch, "mount": shell.mount, "drakvuf": shell.drakvuf, "vm": shell.vm,