Skip to content

Fix cyclic_find packing when subseq=int#622

Closed
push0ebp wants to merge 1 commit intoGallopsled:masterfrom
push0ebp:master
Closed

Fix cyclic_find packing when subseq=int#622
push0ebp wants to merge 1 commit intoGallopsled:masterfrom
push0ebp:master

Conversation

@push0ebp
Copy link
Copy Markdown

when instance of cyclic_find subseq argument is int, int to str packing is not working.
because any iter before isinstance check

before

def cyclic_find(subseq, alphabet = string.ascii_lowercase, n = None):
...
if any(c not in alphabet for c in subseq):
return -1

if isinstance(subseq, (int, long)):
    width = n * 8 or 'all'
    subseq = packing.pack(subseq, width, 'little', False)

cyclic_find(0x61616162)
Traceback (most recent call last):
File "", line 1, in
File "pwnlib/util/cyclic.py", line 101, in cyclic_find
if any(c not in alphabet for c in subseq):
TypeError: 'int' object is not iterable

after

def cyclic_find(subseq, alphabet = string.ascii_lowercase, n = 0):
...

if isinstance(subseq, (int, long)):
    width = n * 8 or 'all'
    subseq = packing.pack(subseq, width, 'little', False)

if any(c not in alphabet for c in subseq):
    return -1

cyclic_find(0x61616162)
4

it worked

@push0ebp
Copy link
Copy Markdown
Author

#623

@junorouse
Copy link
Copy Markdown

hi

@TethysSvensson
Copy link
Copy Markdown
Contributor

This was fixed as part of #636.

Kyle-Kyle pushed a commit to Kyle-Kyle/pwntools that referenced this pull request Apr 25, 2021
* Use ArgparsedCommand for commands/gdbinit.py

* Use ArgparsedCommand for commands/gdbinit.py

* Use ArgparsedCommand for commands/dt.py

* Use ArgparsedCommand for commands/defcon.py. (Not sure what the other one command in there did, didn't bother making it argparsed

* Use ArgparsedCommand for commands/context.py

* Use argparsed command for commands/argv.py

* Use ArgparsedCommand for commands/heap.py

* Use ArgparsedCommand for commands/ida.py

* Use ArgparsedCommand for commands/misc.py

* Use ArgparsedCommand for commands/next.py and commands/nearpc.py

* Use ArgparsedCommand for commands/peda.py

* Use ArgparsedCommand for commands/pie.py

* Use ArgparsedCommand for commands/procinfo.py

* Use ArgparsedCommand for commands/reload.py

* Use ArgparsedCommand for commands/rop.py

* Use ArgparsedCommand for commands/segments.py

* Use ArgparsedCommand for commands/start.py

* Use ArgparsedCommand for commands/telescope.py

* Use ArgparsedCommand for commands/version.py

* Use ArgparsedCommand for commands/vmmap.py

* Use ArgparsedCommand for commands/windbg.py

* Use ArgparsedCommand for commands/xor.py

* Use ArgparsedCommand for commands/windbg.py

* Fix isort
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants