Skip to content

Commit f1d5afe

Browse files
committed
Merge branch 'beta' into dev
2 parents 05783e9 + d90cfd8 commit f1d5afe

File tree

2 files changed

+32
-6
lines changed

2 files changed

+32
-6
lines changed

CHANGELOG.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,13 @@ The table below shows which release corresponds to each branch, and what date th
8787
[2186]: https://github.com/Gallopsled/pwntools/pull/2186
8888
[2129]: https://github.com/Gallopsled/pwntools/pull/2129
8989

90-
## 4.10.0 (`stable`)
90+
## 4.10.1 (`stable`)
91+
92+
- [#2214][2214] Fix bug at ssh.py:`download` and `download_file` with relative paths
93+
94+
[2214]: https://github.com/Gallopsled/pwntools/pull/2214
95+
96+
## 4.10.0
9197

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

pwnlib/tubes/ssh.py

+25-5
Original file line numberDiff line numberDiff line change
@@ -1502,17 +1502,25 @@ def download_file(self, remote, local = None):
15021502
calling the function twice has little overhead.
15031503
15041504
Arguments:
1505-
remote(str): The remote filename to download
1505+
remote(str/bytes): The remote filename to download
15061506
local(str): The local filename to save it to. Default is to infer it from the remote filename.
1507+
1508+
Examples:
1509+
>>> with open('/tmp/foobar','w+') as f:
1510+
... _ = f.write('Hello, world')
1511+
>>> s = ssh(host='example.pwnme',
1512+
... cache=False)
1513+
>>> _ = s.set_working_directory(wd='/tmp')
1514+
>>> _ = s.download_file('foobar', 'barfoo')
1515+
>>> with open('barfoo','r') as f:
1516+
... print(f.read())
1517+
Hello, world
15071518
"""
15081519

15091520

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

1513-
if os.path.basename(remote) == remote:
1514-
remote = os.path.join(self.cwd, remote)
1515-
15161524
with self.progress('Downloading %r to %r' % (remote, local)) as p:
15171525
local_tmp = self._download_to_cache(remote, p)
15181526

@@ -1694,6 +1702,18 @@ def download(self, file_or_directory, local=None):
16941702
file_or_directory(str): Path to the file or directory to download.
16951703
local(str): Local path to store the data.
16961704
By default, uses the current directory.
1705+
1706+
1707+
Examples:
1708+
>>> with open('/tmp/foobar','w+') as f:
1709+
... _ = f.write('Hello, world')
1710+
>>> s = ssh(host='example.pwnme',
1711+
... cache=False)
1712+
>>> _ = s.set_working_directory('/tmp')
1713+
>>> _ = s.download('foobar', 'barfoo')
1714+
>>> with open('barfoo','r') as f:
1715+
... print(f.read())
1716+
Hello, world
16971717
"""
16981718
file_or_directory = packing._encode(file_or_directory)
16991719
with self.system(b'test -d ' + sh_string(file_or_directory)) as io:
@@ -1769,7 +1789,7 @@ def interactive(self, shell=None):
17691789

17701790
if self.cwd != '.':
17711791
cmd = 'cd ' + sh_string(self.cwd)
1772-
s.sendline(cmd)
1792+
s.sendline(packing._need_bytes(cmd, 2, 0x80))
17731793

17741794
s.interactive()
17751795
s.close()

0 commit comments

Comments
 (0)