Header Banner
Null Byte Logo
Null Byte
wonderhowto.mark.png
Cyber Weapons Lab Forum Metasploit Basics Facebook Hacks Password Cracking Top Wi-Fi Adapters Wi-Fi Hacking Linux Basics Mr. Robot Hacks Hack Like a Pro Forensics Recon Social Engineering Networking Basics Antivirus Evasion Spy Tactics MitM Advice from a Hacker

How to Convert Python Script to Exe

Aug 21, 2015 02:41 PM
Aug 22, 2015 08:33 AM
Python programming language logo

There are a lot of great tutorials on Null Byte using Python to create backdoors, reverse shells etc, so I thought it might be worthwhile making a tutorial on how to convert these python scripts to exe files for Windows victim machines.

This has a number of benefits:

1) The victim doesn't have to have python installed to be able to run your program

2) The victim cannot read the source code (though of course they could disassemble the exe that's probably not the type of person you're targeting ;) )

3) The exe will bundle third party python modules when it's compiled, meaning they don't have to be setup on the victim's system

Download and Install Py2Exe for Windows

http://sourceforge.net/projects/py2exe/files/py2exe/0.6.9/Py2Exe

Unfortunately it's only available for windows :(

Create the Python Program You Want to Compile

Code snippet for a Python program prompting user for bank account details.

I called mine myScript.py

Create setup.py

This is the python script that py2exe uses to create your exe. I think it's fairly self-explanatory.

Make sure you save it in the same directory as the file you want to compile.

Python script for setting up a console application using distutils.

Note, if you are using any third party python modules, you must specify them in this file.

For example, if myScript.py made use of the pandas module, I would specify it here like so:

Python script for setting up a package with py2exe including pandas dependency.

Compile!

Now go to your command prompt and compile your program, by running the following:

python setup.py py2exe

Test Out Your Exe

Py2Exe will have created two folders: build and dist.

The dist folder contains your exe, and it's safe to delete the build folder.

Happy Compiling!

Not a very exciting tutorial, but one that you'll hopefully find useful :)

Image credits: interskill.com.au

You already know how to use your phone. With Gadget Hacks' newsletter, we'll show you how to master it. Each week, we explore features, hidden tools, and advanced settings that give you more control over iOS and Android than most users even know exists.

Sign up for Gadget Hacks Weekly and start unlocking your phone's full potential.

Related Articles

Comments

No Comments Exist

Be the first, drop a comment!