Skip to content

Commit

Permalink
Merge branch 'beta' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Arusekk committed Jul 9, 2023
2 parents 05783e9 + d90cfd8 commit f1d5afe
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 6 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,13 @@ The table below shows which release corresponds to each branch, and what date th
[2186]: https://github.com/Gallopsled/pwntools/pull/2186
[2129]: https://github.com/Gallopsled/pwntools/pull/2129

## 4.10.0 (`stable`)
## 4.10.1 (`stable`)

- [#2214][2214] Fix bug at ssh.py:`download` and `download_file` with relative paths

[2214]: https://github.com/Gallopsled/pwntools/pull/2214

## 4.10.0

In memoriam — [Zach Riggle][zach] — long time contributor and maintainer of Pwntools.

Expand Down
30 changes: 25 additions & 5 deletions pwnlib/tubes/ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -1502,17 +1502,25 @@ def download_file(self, remote, local = None):
calling the function twice has little overhead.
Arguments:
remote(str): The remote filename to download
remote(str/bytes): The remote filename to download
local(str): The local filename to save it to. Default is to infer it from the remote filename.
Examples:
>>> with open('/tmp/foobar','w+') as f:
... _ = f.write('Hello, world')
>>> s = ssh(host='example.pwnme',
... cache=False)
>>> _ = s.set_working_directory(wd='/tmp')
>>> _ = s.download_file('foobar', 'barfoo')
>>> with open('barfoo','r') as f:
... print(f.read())
Hello, world
"""


if not local:
local = os.path.basename(os.path.normpath(remote))

if os.path.basename(remote) == remote:
remote = os.path.join(self.cwd, remote)

with self.progress('Downloading %r to %r' % (remote, local)) as p:
local_tmp = self._download_to_cache(remote, p)

Expand Down Expand Up @@ -1694,6 +1702,18 @@ def download(self, file_or_directory, local=None):
file_or_directory(str): Path to the file or directory to download.
local(str): Local path to store the data.
By default, uses the current directory.
Examples:
>>> with open('/tmp/foobar','w+') as f:
... _ = f.write('Hello, world')
>>> s = ssh(host='example.pwnme',
... cache=False)
>>> _ = s.set_working_directory('/tmp')
>>> _ = s.download('foobar', 'barfoo')
>>> with open('barfoo','r') as f:
... print(f.read())
Hello, world
"""
file_or_directory = packing._encode(file_or_directory)
with self.system(b'test -d ' + sh_string(file_or_directory)) as io:
Expand Down Expand Up @@ -1769,7 +1789,7 @@ def interactive(self, shell=None):

if self.cwd != '.':
cmd = 'cd ' + sh_string(self.cwd)
s.sendline(cmd)
s.sendline(packing._need_bytes(cmd, 2, 0x80))

s.interactive()
s.close()
Expand Down

0 comments on commit f1d5afe

Please sign in to comment.