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

Pwntools does not work on 32-bit Ubuntu #518

Closed
zachriggle opened this issue Mar 23, 2015 · 10 comments · Fixed by #2230
Closed

Pwntools does not work on 32-bit Ubuntu #518

zachriggle opened this issue Mar 23, 2015 · 10 comments · Fixed by #2230
Milestone

Comments

@zachriggle
Copy link
Member

There are several reasons it doesn't work on Ubuntu i686. Among them, only two really matter:

  • Prolific use of int() instead of long() which causes issues with numbers larger than 2**32-1
  • Unit tests assume 64-bit ELF binaries on the system. This also impedes OSX support.
  • Unit tests make assumptions about the random number generator. e.g. in the useragents module.

Since I don't ever intend to run Ubuntu i686, and Travis does not have an option, I suggest we loudly warn users who are using a 32-bit Python.

Does this sound OK? Something like:

if platform.processor() in ('i386', 'i486', 'i586', 'i686'):
    log.warn_once("Pwntools does not support 32-bit Python.  Use a 64-bit distro.")
@TethysSvensson
Copy link
Contributor

Sounds good to me.

@zachriggle
Copy link
Member Author

zachriggle commented Dec 1, 2016

Looks like some exception is throwing before we hit this warning

@zachriggle
Copy link
Member Author

It looks like the issue is the trailing padding / alignment of the structures.

# 64-bit
>>> for name, field in pwnlib.elf.datatypes.elf_prstatus_amd64._fields_:
..:   print getattr(pwnlib.elf.datatypes.elf_prstatus_amd64, name).offset, getattr(pwnlib.elf.datatypes.elf_prstatus_amd64, name).size, name
0 12 pr_info
12 2 pr_cursig
16 8 pr_sigpend
24 8 pr_sighold
32 4 pr_pid
36 4 pr_ppid
40 4 pr_pgrp
44 4 pr_sid
48 16 pr_utime
64 16 pr_stime
80 16 pr_cutime
96 16 pr_cstime
112 216 pr_reg
328 4 pr_fpvalid
>>> ctypes.sizeof(pwnlib.elf.datatypes.elf_prstatus_amd64)
336

# 32-bit
(Pdb) for name, field in elf_prstatus_amd64._fields_: print getattr(elf_prstatus_amd64, name).offset, getattr(elf_prstatus_amd64, name).size, name
0 12 pr_info
12 2 pr_cursig
16 8 pr_sigpend
24 8 pr_sighold
32 4 pr_pid
36 4 pr_ppid
40 4 pr_pgrp
44 4 pr_sid
48 16 pr_utime
64 16 pr_stime
80 16 pr_cutime
96 16 pr_cstime
112 216 pr_reg
328 4 pr_fpvalid
(Pdb) ctypes.sizeof(elf_prstatus_amd64)
332

@AzureRabbit
Copy link

I have installed python3-pwntools using command "pip3 install git+https://github.com/arthaud/python3-pwntools.git", but problem still exsists.

OUTPUT:
ipython  19:48:25 
Python 3.7.4 (default, Aug 21 2019, 14:02:05)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.7.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: from pwn import *

AssertionError Traceback (most recent call last)
in
----> 1 from pwn import *

~/.pyenv/versions/3.7.4/lib/python3.7/site-packages/pwn/init.py in
1 # Promote useful stuff to toplevel
----> 2 from .toplevel import *
3
4 pwnlib.args.initialize()
5 pwnlib.log.install_default_handler()

@Arusekk
Copy link
Member

Arusekk commented Aug 21, 2019

@userse31
Copy link

So the sole reason its not on i686 is "don't feel like it"?

Excellent! Remind me to never invite you to any code porting projects.

@Arusekk
Copy link
Member

Arusekk commented Dec 29, 2022

I think the issue got resolved by now, thanks to Python 3 making more sense with numbers.

Is your issue still a thing? I have been using pwntools on a 32-bit ARM system with success, and I don't remember anything going exceptionally wrong.

@heapcrash
Copy link
Collaborator

heapcrash commented Dec 30, 2022 via email

@userse31
Copy link

I gave up trying to get some stupid python 2.7 script from 2017 working. I just don't have the patience for that.

Now as a coder, I like to develop my stuff on old OLD machines so that I make sure my stuff will work on almost anything.

So when I see people go all "lol, no 32 bit, we can't be bothered" it irritates me.

@Arusekk
Copy link
Member

Arusekk commented Jan 2, 2023

PRs are welcome of course, but this would be a bit of an undertaking, as Python 2 makes a distinction between ints vs longs—this mainly leads to problems when a 32-bit attacker is working on 64-bit binaries, but might appear all of a sudden in strange places. It would be best to port your script to Python 3 if possible, because Python 2 will only get less support over time.

Also please do not mistake 'we are unable to solve this hard thing in the time we have, so let's warn that stuff may break' for 'I don't feel like it lol', many can find it disrespectful.
I get your point, but Python 2 is EOL and the fact that we still support it is already much from our side. If your problem is still valid, please open a separate issue showing all the errors you are getting and the research you have done, or better yet, send a PR, because I do not have any 32-bit system now and cannot do this myself.

@Gallopsled Gallopsled locked as too heated and limited conversation to collaborators Jan 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants