Extracting .pyc From PyInstaller exe

This is the place for queries that don't fit in any of the other categories.

Extracting .pyc From PyInstaller exe

Postby Amran » Fri Aug 02, 2013 2:15 am

I had written a simple application in late 2011 using Python and have since misplaced the source. Recently I've been hopeful to add features, or even write a new version using the original as reference. It was packaged into an exe using PyInstaller (1.5.1 to be precise) and I'm wondering if anyone here can help give me instructions on how I might go about extracting a pyc/pyo file from this exe.

The main file I'm searching for was called 'convert.py' before being compiled into the exe.

If I load the exe using the ArchiveViewer included with PyInstaller, I'm able to see a number of files. opening one of these (titled 'outPYZ1.pyz') displays another list including a file named 'convert'. If I then extact this file using the 'x convert' command and open it in notepad I can see various snippets of plaintext strings used in the application. I had been hopeful that this might be the pyc, but trying to decompile it returns an error that it is invalid.

If anyone could give me tips, or even be willing to look into the file, it would be appreciated. Thanks!
Amran
 
Posts: 2
Joined: Fri Aug 02, 2013 2:10 am

Re: Extracting .pyc From PyInstaller exe

Postby micseydel » Fri Aug 02, 2013 2:25 am

I have no idea about your particular problem, and hopefully someone will be able to help you, but I'd like to take this moment for a PSA that Github and Bitbucket are your friend, because not only do you get to show off and share your work, but you also can't really misplace it :)
Join the #python-forum IRC channel on irc.freenode.net!

Please do not PM members regarding questions which are meant to be discussed publicly. The point of the forum is so that others can benefit from it. We don't want to help you over PMs or emails.
User avatar
micseydel
 
Posts: 1385
Joined: Tue Feb 12, 2013 2:18 am
Location: Mountain View, CA

Re: Extracting .pyc From PyInstaller exe

Postby Mekire » Fri Aug 02, 2013 4:37 am

I recently did this with a py2exe created file. I have yet to do it with a pyinstaller one.

Maybe you can find the information you need here:
http://reverseengineering.stackexchange.com/questions/160/how-do-you-reverse-engineer-an-exe-compiled-with-pyinstaller

-Mek
User avatar
Mekire
 
Posts: 988
Joined: Thu Feb 07, 2013 11:33 pm
Location: Amakusa, Japan

Re: Extracting .pyc From PyInstaller exe

Postby Amran » Fri Aug 02, 2013 12:03 pm

Mekire wrote:I recently did this with a py2exe created file. I have yet to do it with a pyinstaller one.

Maybe you can find the information you need here:
http://reverseengineering.stackexchange.com/questions/160/how-do-you-reverse-engineer-an-exe-compiled-with-pyinstaller

-Mek


Thanks for posting the link, that's one of the pages I've been referring to while trying to recover the source.

Maybe I'm a little bit lost, but I'm still having some trouble when following the top answer.
1. I use ArchiveViewer to extract the pyz file.
2. Using ArchiveViewer again, I extract the 'Convert' file from the pyz. Note that when extracted, it has no extension by default.
3. I haven't yet been able to decompile this as I receive messages akin to 'not a valid pyc pyo file'.

Here's the extracted file. As far as I can tell it is a pyc or pyo file, but I could be wrong?
Amran
 
Posts: 2
Joined: Fri Aug 02, 2013 2:10 am


Return to General Coding Help

Who is online

Users browsing this forum: Bing [Bot] and 4 guests