Gallopsled / Gallopsled/pwntools

Do not store files in /tmp or pyinstaller can not work

Open
#2,086 1 comment 0 reactions 0 assignees View on GitHub
backport-required code style enhancement help-wanted
Dominant language
Python
Stars
13.7k
Forks
1.9k
Avg merge
6d 23h
Merged PRs (30d)
3

Description

I can not import pwntools and then use my python program with pyinstaller.

## Update Pwntools First

I even tried with pwntools from source.

## Debug Output

```sh
$ virtualenv -p python3 myenv ;
$ source myenv/bin/activate
$ pyinstaller ./script.py -y --onefile
$ ./script
```

```File "pwnlib/shellcraft/__init__.py", line 171, in
File "pwnlib/shellcraft/__init__.py", line 37, in __init__
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/_MEICaCgkD/pwnlib/shellcraft/templates/__doc__'
[547041] Failed to execute script 'main' due to unhandled exception!```

When doing:

`from pwn import *`

and then pyinstaller ./script.py -y --onefile
I got errors with at the end:

```File "pwnlib/shellcraft/__init__.py", line 171, in
File "pwnlib/shellcraft/__init__.py", line 37, in __init__
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/_MEICaCgkD/pwnlib/shellcraft/templates/__doc__'
[547041] Failed to execute script 'main' due to unhandled exception!```

After investigation, I think the setup.py somewhere store the doc in the /tmp folder. This may raise issue for pyinstaller.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the reported virtualenv and PyInstaller command with script.py, then inspect pwnlib/shellcraft/__init__.py and the setup.py packaging configuration around the shellcraft templates and __doc__ path. Done means the bundled executable imports pwntools without looking for missing files under /tmp, with a regression test or documented verification of the PyInstaller case.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.