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
Basic implementation of heap commands #36
Conversation
@@ -1,46 +1,127 @@ | |||
#!/usr/bin/env python |
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.
Can you put the shebang and utf line back? It avoids Python2/3 issues in weird cases
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.
Oops. Will do.
@Revisiting structure creation; Assuming that you can do this:
You can do the following: addr = pwndbg.regs.pc # for example
gdb_type = pwndbg.typeinfo.load('struct malloc_chunk')
chunk = gdb.Value(addr).cast(gdb_type.pointer()).dereference()
for field in chunk.type.fields():
print("+%#04x %-15r %#x" % (field.bitpos / 8, field.name, int(chunk[field.name]) & pwndbg.arch.ptrmask)) I get the following (note that I'm using
You can see that this code is actually already implemented in the
The |
@@ -80,41 +87,59 @@ def bins(addr=None): | |||
fastbins = main_arena['fastbinsY'] | |||
bins = main_arena['bins'] | |||
|
|||
size_t_size = gdb.lookup_type('size_t').sizeof |
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.
pwndbg.typeinfo.size_t.sizeof
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.
Actually, they're not size_t
, they're pvoid. This should use pwndbg.typeinfo.pvoid.sizeof
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.
And in before "they're the same", see x32 ABI with 4-byte pointers and 8-byte size_t 😛
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.
Where do you see a pointer being used? The two fields we're skipping are prev_size
and size
, which are both INTERNAL_SIZE_T
which is just size_t
.
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.
Ah, I see that we're skipping over the prevsize
and size
field (size_t sized), I thought we were calculating an index into the fastbinsY
array (pointer-sized).
Updated. Because the dynamic type parsing is broken, this is still broken when you don't have symbols. I think that's fine for now, since installing debugging symbols is trivial (at least on Ubuntu). |
It turns out even with dynamic type generation, this doesn't work, since no
|
Though we could do the super ghetto stuff I used to do. Which would
|
Implemented commands for printing heap chunks and fast bins.