I have this simple code:
from pwn import *
e = ELF(r'/home/user/Documents/pwnexercise')
print("Found hex:\n" + hex(e.symbols.main))
read_only_data = e.section('.rodata').split(b'\x00')
print(read_only_data)
for i in read_only_data:
print(i.decode())
Which gives me this output:
[*] '/home/user/Documents/pwnexercise'
Arch: amd64-64-little
RELRO: Partial RELRO
Stack: Canary found
NX: NX enabled
PIE: No PIE (0x400000)
Found hex:
0x4013fb
[b'\x01', b'\x02', b'', b'', b'', b'', b'Not correct secret sign, please try again, goodbye', b'', b'', b'', b'', b'', b'Rumors say that a hacker can complete 1024 math problems (addition or multiplication) in 60s.', b'%d ', b'%c ', b'%d = ?', b'%d', b'congrats!You completed the task!', b'Wrong, try next time', b'Please enter the secret sign', b'infA', b'']
Not correct secret sign, please try again, goodbye
Rumors say that a hacker can complete 1024 math problems (addition or multiplication) in 60s.
%d
%c
%d = ?
%d
congrats!You completed the task!
Wrong, try next time
Please enter the secret sign
infA
As you can see, the list,
[b'\x01', b'\x02', b'', b'', b'', b'', b'Not correct secret sign, please try again, goodbye', b'', b'', b'', b'', b'', b'Rumors say that a hacker can complete 1024 math problems (addition or multiplication) in 60s.', b'%d ', b'%c ', b'%d = ?', b'%d', b'congrats!You completed the task!', b'Wrong, try next time', b'Please enter the secret sign', b'infA', b'']
has alot of elemtents like b''
or b'\x01
etc.
I have tried to use remove("b'\")
or remove("b''")
, and other variants to remove the elements that doesn't contain actual strings, but I keep getting an error saying ValueError: list.remove(x): x not in list
. So my question is, how do I transform the list into something like this:
[b'Not correct secret sign, please try again, goodbye', b'Rumors say that a hacker can complete 1024 math problems (addition or multiplication) in 60s.', b'%d ', b'%c ', b'%d = ?', b'%d', b'congrats!You completed the task!', b'Wrong, try next time', b'Please enter the secret sign', b'infA']
i.e. how do I remove the empty bytestrings from this list?