Skip to content
This repository has been archived by the owner on Jan 4, 2020. It is now read-only.

FileNotFoundError #5

Open
naweiss opened this issue Nov 28, 2017 · 3 comments
Open

FileNotFoundError #5

naweiss opened this issue Nov 28, 2017 · 3 comments

Comments

@naweiss
Copy link

naweiss commented Nov 28, 2017

Trying to run 32bit elf on 64bit ubuntu, gives you the following erroe:

[x] Starting program './program'
[-] Starting program './program': Failed
Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
  File "/home/naweiss2/.local/lib/python3.5/site-packages/pwnlib/tubes/process.py", line 284, in __init__
    preexec_fn=self._preexec_fn)
  File "/usr/lib/python3.5/subprocess.py", line 947, in __init__
    restore_signals, start_new_session)
  File "/usr/lib/python3.5/subprocess.py", line 1551, in _execute_child
    raise child_exception_type(errno_num, err_msg)
FileNotFoundError: [Errno 2] No such file or directory: './program'

Used multiple ways, for example:

from pwn import *
context.update(arch='i386',bits='32')
p = process('./program')
p.interactive()

Note: using qemu-i386 ./program manualy works fine

@arthaud
Copy link
Owner

arthaud commented Nov 29, 2017

Hi @naweiss,

Sorry, I cannot reproduce it. I see pwntools spawning qemu-i386 ./program.

You can try ipdb to debug this. I would put a breakpoint at pwnlib/tubes/process.py#L275

Example of debugging session:

% ipdb test.py
> /tmp/test.py(1)<module>()
----> 1 from pwn import *
      2 context.update(arch='i386', bits='32')
      3 p = process('./program')

ipdb> break pwnlib/tubes/process.py:275
Breakpoint 1 at /tmp/env/lib/python3.6/site-packages/pwnlib/tubes/process.py:275
ipdb> continue
[x] Starting program './program'
> /tmp/env/lib/python3.6/site-packages/pwnlib/tubes/process.py(275)__init__()
    274                 try:
1-> 275                     self.proc = subprocess.Popen(args=prefix + argv,
    276                                                  shell=shell,

ipdb> print(prefix + argv)
['./program']
ipdb> continue
> /tmp/env/lib/python3.6/site-packages/pwnlib/tubes/process.py(275)__init__()
    274                 try:
1-> 275                     self.proc = subprocess.Popen(args=prefix + argv,
    276                                                  shell=shell,

ipdb> print(prefix + argv)
['qemu-i386', './program']
ipdb> print(cwd)
None
ipdb>

@naweiss
Copy link
Author

naweiss commented Nov 30, 2017

Sorry I accidentally tested qemu-i386 ./program on my other machine.
On my machine the output is /lib/ld-linux.so.2: No such file or directory.

But I don't have access to /lib, so I can't copy ld-linux.so.2 to there.
any help?

Update: used the -L flag to run qemu-i386 worked.
pwntools for python2 seems to have similar thing QEMU_LD_PREFIX
Why this version of pwntools doesn't have same thing?

@arthaud
Copy link
Owner

arthaud commented Dec 3, 2017

python3-pwntools is way behind the original pwntools in terms of commits.

This is because I have to merge manually pwntools into python3-pwntools, and this is a bit painful. I get tons on conflicts, and then I have to rewrite part of the python2 stuff in python3.

I don't plan to keep doing this indefinitely. I would like to work directly on the official repo and make it python3-compatible. I didn't find the time and motivation yet..

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

No branches or pull requests

2 participants