Open Kristal-g opened 5 months ago
@Kristal-g, I suppose we may use segments to preliminary detect memory regions for gadget search. Then, we may exclude non-executable memory areas based on sections information.
@JonathanSalwan, what do you think? What was the original cause of switching from sections to segments?
@Kristal-g, as current workaround ROPgadget has range option:
--range <start-end> Search between two addresses (0x...-0x...)
I don't remember why we did this move =/. However, maybe we can add options to exclude sections/segments?
I took a look at other rop gadgets tools and found that some use only the sections, and some use the segments; so there's no consensus out there.
Maybe we should add a flag such as "--elfUseSections" that would be False
by default, but when it's used it will make getExecSections
return sections instead of segments?
I suggest either a flag like that or some warning where the addresses of the sections don't fill the whole segments (meaning that perhaps part of the segment's memory isn't meant to be executable and won't stay that way).
As I stated earlier, you may use both segments and sections. Just exclude non-executable memory areas from segments according to info in sections.
Great tool!
I was surprised at first when I tried to use gadgets that it found, but they were in memory that is not executable or is already freed. The cause for this is this commit here.
I get that it might be generally more correct to search by segment and not by sections, but it could be useful to have the ability to control that feature, or maybe alert about non-executable sections inside an executable segment.
The use-case for me is searching gadgets in the linux kernel, that has a RWX segment with ".init" sections that get freed after the kernel's initialization:
I would create a pull request myself, but we should first agree if we want to fix it, and how :)