Skip to content
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

Fix cyclic cli for 64 bit integers #1616

Merged
merged 3 commits into from
Jul 7, 2020
Merged

Conversation

tyilo
Copy link
Contributor

@tyilo tyilo commented Jun 28, 2020

Before this change, pwn cyclic -n 8 -l 0x6161616161616178 outputs:

Traceback (most recent call last):
  File "/home/tyilo/.local/bin/pwn", line 8, in <module>
    sys.exit(main())
  File "/home/tyilo/.local/lib/python3.8/site-packages/pwnlib/commandline/main.py", line 54, in main
    commands[args.command](args)
  File "/home/tyilo/.local/lib/python3.8/site-packages/pwnlib/commandline/cyclic.py", line 73, in main
    pat = flat(pat)
  File "/home/tyilo/.local/lib/python3.8/site-packages/pwnlib/context/__init__.py", line 1460, in setter
    return function(*a, **kw)
  File "/home/tyilo/.local/lib/python3.8/site-packages/pwnlib/util/packing.py", line 732, in flat
    out = _flat(args, preprocessor, make_packer(), filler)
  File "/home/tyilo/.local/lib/python3.8/site-packages/pwnlib/util/packing.py", line 560, in _flat
    val = packer(arg)
  File "/home/tyilo/.local/lib/python3.8/site-packages/pwnlib/util/packing.py", line 426, in <lambda>
    return lambda number: pack(number, word_size, endianness, sign)
  File "/home/tyilo/.local/lib/python3.8/site-packages/pwnlib/util/packing.py", line 145, in pack
    raise ValueError("pack(): number does not fit within word_size [%i, %r, %r]" % (0, number, limit))
ValueError: pack(): number does not fit within word_size [0, 7016996765293437304, 4294967296]

@tyilo tyilo changed the base branch from dev to stable June 28, 2020 06:56
@tyilo tyilo changed the base branch from stable to dev June 28, 2020 06:57
@Arusekk
Copy link
Member

Arusekk commented Jun 28, 2020

Shouldn't this just use cyclic_find() function? It should handle stuff automatically already

@@ -70,7 +70,7 @@ def main(args):
pat = int(pat, 0)
except ValueError:
pass
pat = flat(pat)
pat = flat(pat, word_size=8 * args.length)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should set context.cyclic_size. instead of doing this here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That doesn't actually work:

AttributeError: cyclic pattern size cannot be larger than word size

but I can set context.bytes to args.length and it seems to work.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we at least do bytes= to avoid the unnecessary multiplication? Also this should be rebased since v4.2.0 was released and now this targets v4.4.0dev0

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@heapcrash
Copy link
Collaborator

Mind rebasing this on dev? We just did a release today.

@tyilo tyilo force-pushed the fix_cyclic_64bit branch from a21b143 to 736f8d2 Compare July 5, 2020 22:30
@tyilo
Copy link
Contributor Author

tyilo commented Jul 5, 2020

Rebased.

@zachriggle
Copy link
Member

@heapcrash or @Arusekk can you merge this?

@Arusekk Arusekk merged commit 7e0e644 into Gallopsled:dev Jul 7, 2020
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.

4 participants