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

context.bits will not automatically switch when setting context.arch twice. #2498

Open
RocketMaDev opened this issue Nov 10, 2024 · 1 comment

Comments

@RocketMaDev
Copy link

I was using IPython to do some quick poc work that time, first I switched context.arch to 'amd64' and assembled cdqe and then I suddenly would like to try what if I assemble cdqe in 32-bit mode. So I switched context.arch back to 'i386' and wanted to assemble, only to find an error: AttributeError: Invalid arch/bits combination: i386/64

Pwntools may can not handle context.arch correctly, it could change context.bits accordingly when first setting it. However, when setting context.arch the second time, context.bits left unchanged. I guess this bug is related to self._tls?

poc:

屏幕截图_20241111_003054

one more poc:

from pwn import *
print(f"{context.arch}/{context.bits}")
context.arch = 'amd64'
print(f"{context.arch}/{context.bits}")
context.arch = 'i386'
print(f"{context.arch}/{context.bits}")
@RocketMaDev
Copy link
Author

BTW, the document has a wrong source code reference. When clicking on property arch [source], it jumps to file /pwnlib/context.py, which don't exist. The correct file should be pwnlib/context/__init__.py.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant