-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add functions for retrieving process mappings #2371
base: dev
Are you sure you want to change the base?
Conversation
…apping properties
Oh didn't know it had to support python2.7 |
Not sure what exactly you meant by this. |
Yes, I was imagining a parameter to .libs() to get the base address of the passed lib instead of a dict. |
Sorry for late push,
So do I leave it as is, change the functions I added, or add an overload to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! I've only some suggestions around the docs.
A doctest failed but it isnt mine? |
^ Other than that, I think thats it. (you can add the musl doctests after you do the musl-tools stuff I guess). Btw, after thinking about it a bit (and while making the tests), I feel like the various something_location() functions are redundant and should probably be removed. That use-case was something I needed in my project but libc_mappings = p.libc_mapping(single=False)
size = libc_mappings[-1].end - libc_mappings[0].start is easy enough. Also calling What do you think? |
Yes, please remove redundant API. Maybe returning some class instead of a simple mapping list which has a function to give you the total mapping size? Don't know how usable that is |
Okay so since vvar and vdso are only one mapping and stack and heap don't have contiguity guarantees it only makes sense from a user perspective to ask for the size of shared libraries (and the elf I guess?), so I replaced all the |
If you agree with the changes, the PR is done / ready for (re)review. |
Oh and as I said, it might be good to look into why https://github.com/Gallopsled/pwntools/actions/runs/8789031621/job/24117819520 failed. |
Closes #2369
process.maps
which is a wrapper aroundutil.proc.memory_maps
get_mapping
function which finds mappings given a "path" to lookstack_mapping
,heap_mapping
,vdso_mapping
,vvar_mapping
,elf_mapping
which hook intoget_mapping
, andlibc_mapping
,musl_mapping
util.proc.memory_maps
returns (so lots!)address_mapping
which allows the user to get a mapping for a supplied addressprint(p.address_mapping(is_this_stack_addr).path == '[stack]')
lib_size
which returns the size of a loaded shared library given the pathAlso Closes #2370
I didn't really touch
.libs()
or.libc
since they have a different return signature. Also.libs()
hasWhich makes little sense to me, because if
/proc/<pid>/maps
really fails and it goes to this check, if ASLR is enabled.libs()
will just quietly return wrong addresses instead of erroring out, which seems counterintuitive.Fun fact: now you can do stuff like
print(p.stack_mapping().perms.execute)
!! (prints True/False)