Exception when ELF does not contain a string table
yifanlu opened this issue · 1 comments
yifanlu commented
The following appears when trying to run on an ELF that has e_shstrndx = 0.
Traceback (most recent call last):
File "ROPgadget.py", line 17, in <module>
ropgadget.main()
File "/Users/yifanlu/Downloads/ROPgadget-master/ropgadget/__init__.py", line 21, in main
sys.exit(Core(Args().getArgs()).analyze())
File "/Users/yifanlu/Downloads/ROPgadget-master/ropgadget/core.py", line 169, in analyze
self.__binary = Binary(self.__options)
File "/Users/yifanlu/Downloads/ROPgadget-master/ropgadget/binary.py", line 37, in __init__
self.__binary = ELF(self.__rawBinary)
File "/Users/yifanlu/Downloads/ROPgadget-master/ropgadget/loaders/elf.py", line 218, in __init__
self.__setShdr()
File "/Users/yifanlu/Downloads/ROPgadget-master/ropgadget/loaders/elf.py", line 267, in __setShdr
string_table = str(self.__binary[(self.__shdr_l[self.__ElfHeader.e_shstrndx].sh_offset):])
IndexError: list index out of range
I fixed it by adding a if self.__ElfHeader.e_shstrndx:
before the string table parsing in __setShdr
JonathanSalwan commented
Fixed. :)