Thursday, September 28, 2017


A very good utility which might come handy in a pentest is py2exe.

This is an extension which helps you convert the Python Scripts in to a Windows Executable program and helps you run the same without the Python Installation altogether. But yes you will require Python on the machine where you are using py2exe.

Lets see on one of the scripts that helped me create a exe file to be run on a compromised Windows machine.

python to exe

from distutils.core import setup
import py2exe, sys, os
    options = {'py2exe': {'bundle_files': 1, 'compressed': True}},
    windows = [{'script': ""}],
    zipfile = None,

Lets look into this closely.

If you are aware of python programming the first few lines will be easy to understand. It actually calls some of the libraries including the DistUtlis with some of the function calls.

Then we call py2exe so that its functionality can be used to create our executable.

You will see something called as bundle_files which is used to create single-file executable. There are values that can be used for that as below:

Valid values for bundle_files are:

3 (default) don't bundle
2 bundle everything but the Python interpreter
1 bundle everything, including the Python interpreter

We also set the zipfile to None so that the files will be bundle within the executable.

This approach does not require extracting files to a temporary location, which provides much faster program startup.

I will say that visit their page and i am sure that you will not be disappointed.


This is pretty useful.

No comments:

Post a Comment