-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Make cyclic_find work with large int values #1981
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
Make cyclic_find work with large int values #1981
Conversation
The CI failure doesn't look related to this PR |
Thanks for the PR, but this situation is already handled and the code is behaving correctly. Set
I do agree we need a better error message, but the behavior is correct, and the default cyclic size is ALWAYS four bytes. It looks in your case, you do indeed have a 4-byte cyclic pattern, but are decoding it incorrectly. To save confusion in the future, just pass the bytes directly to cyclic_find and it will do the right thing.
|
Thanks @zachriggle While it might be a minor issue, the current working-as-intended behaviour can be a nuisance in some cases. #1965 shows some of these, but perhaps they're not presented as enough of a real-world problem.
What I'm speaking of is the case where I've used, say, I've then got a crash with a register being, say, 0x6b6161666b616165. I'd like to pass this to It currently doesn't work:
Curiously we do have support for overly long bytes subsequences:
To get around this API inconsistency and to successfully use
None of which are terribly clean. I'd rather pwntools trim the overly large int for me, and warn loudly when it does so, just as it's currently doing for overly long bytes subsequences. To make things simpler, this PR allows users to do:
Sure it gives an ugly warning, and perhaps it's something that people "shouldn't" be doing, but it does bring the handling of large ints into alignment with how we're handling overly long bytes. If catering to this use case isn't something that pwntools is interested in doing, then that's ok. It sure would shave off a rough edge for me though. But on the other hand, does this PR break something I'm not aware of? |
Then I completely misunderstood the intent of this PR, and my diatribe can be safely ignored. Everything sounds good to me, though I'd prefer |
Ah yep, totally agree. Updated.
|
* Make cyclic_find work with large int values * Add entry for cyclic_find() large int fix * Tweak cyclic_find() large int warning
This resolves #1965 by making
cyclic_find()
work with integers larger than what could fit in n bytes.It does so by truncating the integer value, similarly to how
cyclic_find()
has been truncating long bytes-type values. It honourscontext.endianness
in its truncation.I also tidied up the warning in the case of overly long bytes-type values. It was printing
4
instead of pulling fromn
.Demo
Old behavior:
Even setting
endian.context
doesn't resolve it:New behavior:
While I filed #1965 as a bug, I'm not sure this warrants backporting to stable. It is behaviour that has been completely blowing up on users so far, so they'd be used to routing around it.