Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pwntools: Collapse recvuntil + send into a single sendafter #190

Merged
merged 1 commit into from
Nov 17, 2024

Conversation

peace-maker
Copy link
Collaborator

When exporting a stream as a pwntools script, make the output a bit nicer by using the send[line]after functions instead of recvuntil + send[line].

This shortens the script and makes it more readable. The data chosen to receive until is the last line including newlines to try to make it unique.

before

#!/usr/bin/env python3
from pwn import *
import sys

# Generated from stream 192227
# io = remote(sys.argv[1], 5445)
io = remote('10.32.131.2', 5445)
io.recvuntil(b' \n1 - Yes \n2 - No \n\n')
io.sendline(b'2')
io.recvuntil(b'ame: (20 chars max)\n')
io.send(b'UttermostInnocentTomtom5628')
io.recvuntil(b'ord: (20 chars max)\n')
io.send(b'g1Tlo0rQj')
io.recvuntil(b'Ticket \n 5 - Exit \n\n')
io.sendline(b'1')
io.recvuntil(b' date: <dd.mm.yyyy>\n')
io.send(b'7.12.2023')
io.recvuntil(b' do you want to go?\n')
io.send(b'Tuerkismuehle')
io.recvuntil(b' you want to start?\n')
io.send(b'Blieskastel-Lautzkirchen')
io.recvuntil(b'Whose ticket is it?\n')
io.send(b'SAAR{wQCDAAUAAADFLdYh0IX9MRv9vOE-tbV1}')
io.recvuntil(b'Ticket \n 5 - Exit \n\n')
io.sendline(b'5')
io.stream()

after

#!/usr/bin/env python3
from pwn import *
import sys

# Generated from stream 192227
# io = remote(sys.argv[1], 5445)
io = remote('10.32.131.2', 5445)
io.sendlineafter(b'2 - No \n\n', b'2')
io.sendafter(b'ease provide a username: (20 chars max)\n', b'UttermostInnocentTomtom5628')
io.sendafter(b'Provide a password: (20 chars max)\n', b'g1Tlo0rQj')
io.sendlineafter(b' 5 - Exit \n\n', b'1')
io.sendafter(b'ovide the travelling date: <dd.mm.yyyy>\n', b'7.12.2023')
io.sendafter(b'Where do you want to go?\n', b'Tuerkismuehle')
io.sendafter(b'Where do you want to start?\n', b'Blieskastel-Lautzkirchen')
io.sendafter(b'Whose ticket is it?\n', b'SAAR{wQCDAAUAAADFLdYh0IX9MRv9vOE-tbV1}')
io.sendlineafter(b' 5 - Exit \n\n', b'5')
io.stream()

When exporting a stream as a pwntools script, make the output a bit nicer by using the `send[line]after` functions instead of `recvuntil` + `send[line]`.

This shortens the script and makes it more readable. The data chosen to receive until is the last line including newlines to try to make it unique.
@peace-maker peace-maker added the enhancement New feature or request label Nov 12, 2024
@peace-maker peace-maker merged commit 60ea534 into spq:main Nov 17, 2024
5 checks passed
@peace-maker peace-maker deleted the pwntools_after branch December 3, 2024 09:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant