Gallopsled / pwntools

CTF framework and exploit development library
http://pwntools.com
Other
11.98k stars 1.7k forks source link

[Windows] Using "Process" raises "AttributeError: module 'os' has no attribute 'getuid'" #2406

Closed MatthiasHeinz closed 4 months ago

MatthiasHeinz commented 4 months ago

On Windows: When trying to invoke process, pwntools crashes with the following error.

> python .\solver.py DEBUG LOG_FILE=log.txt
Traceback (most recent call last):
  File "F:\some_dir\solver.py", line 12, in <module>
    conn = process(['python', 'chall.py'])
  File "D:\Python3.10.4\lib\site-packages\pwnlib\tubes\process.py", line 260, in __init__
    executable_val, argv_val, env_val = self._validate(cwd, executable, argv, env)
  File "D:\Python3.10.4\lib\site-packages\pwnlib\tubes\process.py", line 553, in _validate
    elif os.path.sep not in executable and which(executable, path=path):
  File "D:\Python3.10.4\lib\site-packages\pwnlib\util\misc.py", line 163, in which
    isroot = os.getuid() == 0
AttributeError: module 'os' has no attribute 'getuid'

log.txt

================================================================================
= Started at 2024-05-12T20:03:11                                               =
= sys.argv = [                                                                 =
=   '.\\solver.py',                                                            =
= ]                                                                            =
================================================================================
================================================================================
= Started at 2024-05-12T20:03:11                                               =
= sys.argv = [                                                                 =
=   '.\\solver.py',                                                            =
= ]                                                                            =
================================================================================

solver.py

from pwn import *
conn = process(['python', 'chall.py'])

chall.py

print(1)

Could be related to #2379.

peace-maker commented 4 months ago

You are looking for https://github.com/Gallopsled/pwntools/pull/2310 which is only available in the beta. Try pip install --upgrade --pre pwntools to switch to the 4.13 beta. That support is very new and I'm interested if it works out for you!

MatthiasHeinz commented 4 months ago

Seems to work beautifully. Thanks for pointing me into the right direction!