-
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
Refactor pwnlib.encoders.encode() to be more nice to bytes objects #1923
base: stable
Are you sure you want to change the base?
Refactor pwnlib.encoders.encode() to be more nice to bytes objects #1923
Conversation
* Add byteset() to misc which does "the right thing" and returns a set of bytes * Make bytes_avoid be a bytes() object instead of a set * Update documentation to note that functions take bytes() and not str()
…ed to documentation
Also adds examples/encoder.py to make sure the encoders can work in simple situations, avoiding basic characters, and being forced to encode even if the avoid= are missing in the original bytes.
Personally I would prefer the set to be a set of numbers, but looks good. |
The issue with this is the difference between Py2 and Py3. I think there's value in keeping the behavior of the two as close as possible, for making the code as simple as possible. Py2
Py3
|
Yes, I only meant the new common behavior to be based on what py3 already does normally, and only adding a layer of py2 compatibility. This will make it easier to drop py2 support eventually (since we want to drop it in some Pwntools 5000, right?).
…--
Wysłane z mojego urządzenia Sailfish
|
I hereby vote the next release is Pwntools v5.000 😛 |
I vote even when we drop Py2 support entirely, having a `byteset` or
similar construct is useful, as would be an e.g. bytesiter. Working with
bytes() ALL THE TIME is much easier than working with int() on occasion.
…On Fri, Jun 25, 2021 at 8:15 AM Arusekk ***@***.***> wrote:
Yes, I only meant the new common behavior to be based on what py3 already
does normally, and only adding a layer of py2 compatibility. This will make
it easier to drop py2 support eventually (since we want to drop it in some
Pwntools 5000, right?).
--
Wysłane z mojego urządzenia Sailfish
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1923 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/APYTIFJHWJKG5L3OWLNBW3TTUR6PZANCNFSM47JVFSZA>
.
|
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! Allowing to run the encoders again at least is great.
I agree with having a |
.. automodule:: pwnlib.encoders.encoder | ||
:members: | ||
|
||
.. automodule:: pwnlib.encoders.i386.ascii_shellcode |
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.
The ASCII encoder isn't added to the encoder mapping in the Encoder class. We should keep the docs for that one, since it has to be used explicitly.
It has extra settings worth documenting and decodes the shellcode onto the stack, so a jmp esp
is required afterwards.
bytes
objectsEncoder
class to its own module so that it doesn't show up in docsExample Script (examples/encoder.py)
This requires running from
make -C extra/docker develop
in order for the current username to be "pwntools".Python3
Python2