Skip to content

Commit 8f122c3

Browse files
NobodyNadaArusekk
andauthored
Fix encoding & escaping in ssh.upload_dir (Gallopsled#2165)
remote_tar is a `bytes`, so the string interpolation resulted in the command `cd ... && tar -xzf b'/tmp/...tar.gz`. It also would have failed had either path contained spaces. To fix this, make everything a bytes and use proper escaping. Co-authored-by: Arusekk <[email protected]>
1 parent 123f68f commit 8f122c3

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

pwnlib/tubes/ssh.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1633,7 +1633,7 @@ def upload_dir(self, local, remote=None):
16331633
remote: Remote directory
16341634
"""
16351635

1636-
remote = remote or self.cwd
1636+
remote = packing._encode(remote or self.cwd)
16371637

16381638
local = os.path.expanduser(local)
16391639
dirname = os.path.dirname(local)
@@ -1654,7 +1654,7 @@ def upload_dir(self, local, remote=None):
16541654
remote_tar = self.mktemp('--suffix=.tar.gz')
16551655
self.upload_file(local_tar, remote_tar)
16561656

1657-
untar = self.run('cd %s && tar -xzf %s' % (remote, remote_tar))
1657+
untar = self.run(b'cd %s && tar -xzf %s' % (sh_string(remote), sh_string(remote_tar)))
16581658
message = untar.recvrepeat(2)
16591659

16601660
if untar.wait() != 0:

0 commit comments

Comments
 (0)