Interact to remote console by sending text with a loop with Python/pwntools

1.1k views Asked by At

I'm playing with an remote console that asks me to return every word it gives.

For example :

>>> car # Remote console gives a word
car # I answer
Ok next word ! # Remote console after checking
>>> house # Remote console gives a second word and is waiting for me

I could manually answer each word the console says. But I'd like to make a script to automate it.
I'm thinking about a loop that would do this job, that is to say :

  1. get the word from the remote console
  2. send that word back to the remote console

I tried it with the pwntools Python library by using the recvline() and sendline() commands. I wrote :

import pwn
import re
c = pwn.remote ("URL", port)
question = str(c.recvline())
c.sendline(question)
c.interactive()

By doing this, the console returns :

Ok next word !
>>> house

That's a start but obviously as there's no loop, the script can't send "house" back. To adapt it, I used while and for loops on the recvline command but without results after many tries. And I must admit I'm getting stuck.
Is there a trick to do it and put each try inside the >>> input of the service ?

Any help would be very appreciated.
Thanks.

0

There are 0 answers