mirror of
https://github.com/Gallopsled/pwntools.git
synced 2026-10-12 02:02:27 +00:00
* Fix tube.clean_and_log not logging buffered data Only new data received after the `clean_and_log` call is printed while data already received and buffered earlier is not. Print the buffered data first before waiting for more so we don't miss anything. * Only show buffered data if DEBUG is off * Update CHANGELOG.md --------- Co-authored-by: Arusekk <[email protected]>
35 lines
1009 B
Python
35 lines
1009 B
Python
"""
|
|
Use case for `pwnlib.tubes.tube.clean_and_log`.
|
|
|
|
Sometimes you will have a solution to a challenge but you don't know what it
|
|
will look like when you get the flag. Sometimes that will leave you with a
|
|
top-level exception, no flag, and angry team members.
|
|
|
|
Solution:
|
|
1. Always run wireshark or tcpdump. Always.
|
|
2. Register <your socket>.clean or <your socket>.clean_and_log to run at exit.
|
|
"""
|
|
|
|
from pwn import *
|
|
from multiprocessing import Process
|
|
|
|
def submit_data():
|
|
with context.quiet:
|
|
with listen(1337) as io:
|
|
io.wait_for_connection()
|
|
io.sendline(b'prefix sometext')
|
|
io.sendline(b'prefix someothertext')
|
|
io.sendline(b'here comes the flag')
|
|
io.sendline(b'LostInTheInterTubes')
|
|
|
|
if __name__ == '__main__':
|
|
p = Process(target=submit_data)
|
|
p.start()
|
|
|
|
r = remote('localhost', 1337)
|
|
atexit.register(r.clean_and_log)
|
|
|
|
while True:
|
|
line = r.recvline()
|
|
print(re.findall(br'^prefix (\S+)$', line)[0])
|