Python Exploit Framework (Compiling Exploits)

Questions about programming languages and debugging
Post Reply
User avatar
maboroshi
Dr. Mab
Dr. Mab
Posts: 1624
Joined: 28 Aug 2005, 16:00
18

Python Exploit Framework (Compiling Exploits)

Post by maboroshi »

This tutorial is about how to compile python standalone executables using RPYTHON the goal is to use shellcodes/payloads

Why the title? Well its a goal of mine to turn these snippets of mine into an exploit framework. So enjoy!

RPython is a restricted subset of python RPython (Restricted Python) is statically typed

What will we cover in this tutorial is setting up an environment for building exploits in RPython

First you will need to download PyPy and MinGW

(the pypy translator is only available in the source of PyPy we will need translate.py later to compile the executable. So get the latest source using Mercurial)

Download Mercurial here http://mercurial.selenic.com and install it. Using Mercurial run this command from your cmd prompt
Now you will have PyPy downloaded. I just moved it to the directory C:\pypy for easy reference. Next we will add an Environment Variable to the directory containing translate.py it should be in C:\pypy\pypy\translator\goal\ the file translate.py will be in this goal directory

Now you will need to install MinGW

http://sourceforge.net/projects/mingw/f ... -get-inst/

Installing the C++ compiler and the MSYS tools also

pretty much everything, although you don't need the J++ compiler or csharp compiler I think they had

Add the bin directory of MinGW to your path as well as \msys\1.0\bin; so if you installed MinGW to to C:\MinGW it would be C:\MinGW\bin and C:\MinGW\msys\1.0\bin;
You will need to use MinGW to compile a dll before we can start. This is so we can use CTYPES. MinGW will also be our compiler for RPython
Now download the libffi source http://sourceware.org/libffi/ once again this will allow for CTypes in PyPy and MingW

cd to the libffi source directory and type

Code: Select all

sh ./configure
make
this will create a dll in .libs in the directory where you untared the libffi. The dll will be called:
libffi-5.dll
Next add this to a folder on your C drive and add it to your Environment Variable/Path

Now you should be able to compile the source attached to this post

type in cmd

Code: Select all

translate.py --cc=mingw32 --output test.exe test.py
Obviously changing directories to where you downloaded test.py. That sums it up the development environment is set up. This was really only to be a reference for me
Attachments
test.zip
(998 Bytes) Downloaded 99 times

Post Reply