Skip to content

Commit 8cf3ecd

Browse files
committedOct 29, 2023
Merge branch 'stable' into beta
2 parents e9f73bf + 0c1121d commit 8cf3ecd

File tree

5 files changed

+32
-15
lines changed

5 files changed

+32
-15
lines changed
 

‎CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,12 @@ The table below shows which release corresponds to each branch, and what date th
9191

9292
## 4.11.1 (`stable`)
9393

94+
- [#2271][2271] FIX: Generated shebang with path to python invalid if path contains spaces
95+
- [#2272][2272] Fix `tube.clean_and_log` not logging buffered data
9496
- [#2281][2281] FIX: Getting right amount of data for search fix
9597

98+
[2271]: https://github.com/Gallopsled/pwntools/pull/2271
99+
[2272]: https://github.com/Gallopsled/pwntools/pull/2272
96100
[2281]: https://github.com/Gallopsled/pwntools/pull/2281
97101

98102
## 4.11.0

‎examples/clean_and_log.py

+18-12
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,24 @@
1111
"""
1212

1313
from pwn import *
14+
from multiprocessing import Process
1415

15-
os.system('''((
16-
echo prefix sometext ;
17-
echo prefix someothertext ;
18-
echo here comes the flag ;
19-
echo LostInTheInterTubes
20-
) | nc -l 1337) &
21-
''')
16+
def submit_data():
17+
with context.quiet:
18+
with listen(1337) as io:
19+
io.wait_for_connection()
20+
io.sendline(b'prefix sometext')
21+
io.sendline(b'prefix someothertext')
22+
io.sendline(b'here comes the flag')
23+
io.sendline(b'LostInTheInterTubes')
2224

23-
r = remote('localhost', 1337)
24-
atexit.register(r.clean_and_log)
25+
if __name__ == '__main__':
26+
p = Process(target=submit_data)
27+
p.start()
2528

26-
while True:
27-
line = r.recvline()
28-
print(re.findall(r'^prefix (\S+)$', line)[0])
29+
r = remote('localhost', 1337)
30+
atexit.register(r.clean_and_log)
31+
32+
while True:
33+
line = r.recvline()
34+
print(re.findall(br'^prefix (\S+)$', line)[0])

‎pwnlib/timeout.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,11 @@ def __enter__(self):
3030
self.obj._stop = min(self.obj._stop, self.old_stop)
3131

3232
self.obj._timeout = self.timeout
33+
self.obj.timeout_change()
3334
def __exit__(self, *a):
3435
self.obj._timeout = self.old_timeout
3536
self.obj._stop = self.old_stop
37+
self.obj.timeout_change()
3638

3739
class _local_handler(object):
3840
def __init__(self, obj, timeout):
@@ -157,7 +159,7 @@ def _get_timeout_seconds(self, value):
157159
else:
158160
value = float(value)
159161

160-
if value is value < 0:
162+
if value < 0:
161163
raise AttributeError("timeout: Timeout cannot be negative")
162164

163165
if value > self.maximum:

‎pwnlib/tubes/tube.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -1034,8 +1034,13 @@ def clean_and_log(self, timeout = 0.05):
10341034
b'hooray_data'
10351035
>>> context.clear()
10361036
"""
1037+
cached_data = self.buffer.get()
1038+
if cached_data and not self.isEnabledFor(logging.DEBUG):
1039+
with context.local(log_level='debug'):
1040+
self.debug('Received %#x bytes:' % len(cached_data))
1041+
self.maybe_hexdump(cached_data, level=logging.DEBUG)
10371042
with context.local(log_level='debug'):
1038-
return self.clean(timeout)
1043+
return cached_data + self.clean(timeout)
10391044

10401045
def connect_input(self, other):
10411046
"""connect_input(other)

‎pwnlib/util/misc.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ def run_in_new_terminal(command, terminal=None, args=None, kill_at_exit=True, pr
386386
import os
387387
os.execve({argv0!r}, {argv!r}, os.environ)
388388
'''
389-
script = script.format(executable=sys.executable,
389+
script = script.format(executable='/bin/env ' * (' ' in sys.executable) + sys.executable,
390390
argv=command,
391391
argv0=which(command[0]))
392392
script = script.lstrip()

0 commit comments

Comments
 (0)