Gallopsled / pwntools

CTF framework and exploit development library
http://pwntools.com
Other
12.05k stars 1.71k forks source link

The packing functions should have more modes #338

Closed TethysSvensson closed 8 years ago

TethysSvensson commented 9 years ago

We should continue to have the mode "unsigned" and "signed" as we currently have, which will reject anything outside [-2^(n-1), 2^(n-1)-1] and [0, 2^n-1] respectively. They are currently represented as True and False.

We should also have a mode that accepts the combined range [-2^(n-1), 2^n-1] and another that just does not care and will and it into the bytes not matter how big/small a number.

This is important as we need it for e.g. push and move shellcodes to work in a sane manner (more specifically we need the combined range version).

zachriggle commented 9 years ago

Should we expose (and use) p32u in lieu of standard usage of p32, and then have p32 be the 'dont care' version? These are already in the module as _p32u and _p32s, they are just not exposed.

TethysSvensson commented 9 years ago

I think I would be okay with that. The current behavior is not particularly nice.

I still think we should have four versions. For p8, those would be:

I think I would prefer that the default version is number 3, but I would like to have all three as a possibility. In particular I would probably use the accept everything version sometimes when dealing with stuff that should wrap around, but normally I like the sanity checking that the number is in fact small enough.

zachriggle commented 9 years ago

So the behavior effectively becomes:

If sign is None and number is negative, set sign to "True"

?

Zach Riggle

On Jan 10, 2015, at 3:32 AM, Mathias Svensson notifications@github.com wrote:

I think I would be okay with that. The current behavior is not particularly nice.

I still think we should have four versions. For p8, those would be:

Only accept 0, 255 Only accept -128, 127 Only accept -128, 255 Accept everything I think I would prefer that the default version is number 3, but I would like to have all three as a possibility. In particular I would probably use the accept everything version sometimes when dealing with stuff that should wrap around, but normally I like the sanity checking that the number is in fact small enough.

— Reply to this email directly or view it on GitHub.