1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
"""
Example showing pwnlib's readline implementation and a few completers. This
part of pwnlib will probably see some major changes soon, but we wanted to show
off some proof-of-concepts.
"""
from pwn import *
from pwnlib.term.completer import LongestPrefixCompleter
from pwnlib.term.completer import PathCompleter
c1 = LongestPrefixCompleter([
'foobar',
'foobaz',
'fooqux',
'exit',
'enough!',
])
c2 = PathCompleter(mask = '*.py')
with c1:
print('type "exit" to exit')
while True:
s = str_input(prompt = '> ').strip()
if s in ('exit', 'enough!'):
break
print('You wrote', s)
with c2:
print('choose a file')
s = str_input(prompt = text.bold_green('$ ')).strip()
print('You picked', s)
|