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

Does not support Python 3.11 #2145

Closed
acidghost opened this issue Dec 5, 2022 · 0 comments
Closed

Does not support Python 3.11 #2145

acidghost opened this issue Dec 5, 2022 · 0 comments

Comments

@acidghost
Copy link

Python 3.11 is not supported

When invoking stuff from the shellcraft module I get errors:

❯ ipython
Python 3.11.0 (main, Nov 23 2022, 15:15:44) [Clang 14.0.0 (clang-1400.0.29.202)]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.7.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: from pwn import *

In [2]: exe = ELF("./fun")
[*] '/[redacted]/fun'
    Arch:     i386-32-little
    RELRO:    Partial RELRO
    Stack:    No canary found
    NX:       NX disabled
    PIE:      No PIE (0x8048000)
    RWX:      Has RWX segments

In [3]: context.binary = exe

In [4]: shellcraft.linux.sh
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[4], line 1
----> 1 shellcraft.linux.sh

File ~/.local/share/virtualenvs/picoctf-practice-DUv4OV_q/lib/python3.11/site-packages/pwnlib/shellcraft/__init__.py:80, in module.__getattr__(self, key)
     78 # This function lazy-loads the shellcodes
     79 if key in self._shellcodes:
---> 80     real = internal.make_function(key, self._shellcodes[key], self._dir)
     81     setattr(self, key, real)
     82     return real

File ~/.local/share/virtualenvs/picoctf-practice-DUv4OV_q/lib/python3.11/site-packages/pwnlib/shellcraft/internal.py:116, in make_function(funcname, filename, directory)
    113 path       = os.path.join(directory, filename)
    114 template   = lookup_template(path)
--> 116 args, varargs, keywords, defaults = inspect.getargspec(template.module.render_body)
    118 defaults = defaults or []
    120 if len(defaults) < len(args) and args[0] == 'context':

AttributeError: module 'inspect' has no attribute 'getargspec'

In [5]: shellcraft.linux.syscalls.execve
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[5], line 1
----> 1 shellcraft.linux.syscalls.execve

File ~/.local/share/virtualenvs/picoctf-practice-DUv4OV_q/lib/python3.11/site-packages/pwnlib/shellcraft/__init__.py:80, in module.__getattr__(self, key)
     78 # This function lazy-loads the shellcodes
     79 if key in self._shellcodes:
---> 80     real = internal.make_function(key, self._shellcodes[key], self._dir)
     81     setattr(self, key, real)
     82     return real

File ~/.local/share/virtualenvs/picoctf-practice-DUv4OV_q/lib/python3.11/site-packages/pwnlib/shellcraft/internal.py:116, in make_function(funcname, filename, directory)
    113 path       = os.path.join(directory, filename)
    114 template   = lookup_template(path)
--> 116 args, varargs, keywords, defaults = inspect.getargspec(template.module.render_body)
    118 defaults = defaults or []
    120 if len(defaults) < len(args) and args[0] == 'context':

AttributeError: module 'inspect' has no attribute 'getargspec'

In [6]: shellcraft.sh
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[6], line 1
----> 1 shellcraft.sh

File ~/.local/share/virtualenvs/picoctf-practice-DUv4OV_q/lib/python3.11/site-packages/pwnlib/shellcraft/__init__.py:90, in module.__getattr__(self, key)
     87     except AttributeError:
     88         pass
---> 90 raise AttributeError("'module' object has no attribute '%s'" % key)

AttributeError: 'module' object has no attribute 'sh'

This is due to (at least) Python 3.11 removing inspect.getargspec (https://docs.python.org/3.11/whatsnew/3.11.html#removed).

Environment

  • macOS 13.0.1
  • python 3.11.0
  • pwntools 4.8.0
gogo2464 pushed a commit to gogo2464/pwntools that referenced this issue Sep 10, 2023
While at it, drop the hard-to-maintain code.
We lose the signature in py2, but its support is second-class anyway.

Fixes Gallopsled#2145
Closes Gallopsled#2148
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant