Install PaiMei on Snow Leopard

Da PiemonteWireless.

Indice

How to install python PaiMei on Mac OSX Snow Leopard

PaiMei, is a reverse engineering framework consisting of multiple extensible components. The framework can essentially be thought of as a reverse engineer's swiss army knife and has already been proven effective for a wide range of both static and dynamic tasks such as fuzzer assistance, code coverage tracking, data flow tracking and more.

Install VirtualEnv

Usually I use VirtualEnv to separate various Python lilbrary installation.

$ easy_install virtualenv

Create Python2.5 virtual environment

I named this virtualenv "debuggerenv25"

$ virtualenv --python=python2.5 debuggerenv25

Every time you open a terminal and you want to use a virtual environment you need to do:

$ source bin/activate

Install PaiMei

Now you need to checkout PaiMei from SVN:

$ svn co http://paimei.googlecode.com/svn/trunk/MacOSX MacOSX

Now you nedd a little patch do made it work. Edit the file pydbg\my_ctypes.py:

- c_types = (Structure, c_char, c_byte, c_ubyte, c_short, c_ushort, c_int, c_uint, c_long, c_ulong, c_longlong, \
+ class Structure2(Structure):
+    pass
+
+ c_types = (Structure2, c_char, c_byte, c_ubyte, c_short, c_ushort, c_int, c_uint, c_long, c_ulong, c_longlong, \

Leave PaiMei and go on installing all its requirements

Install ctypes

Download from sourceforge:

ctypes-1.0.2.tar.gz

You need to make a change to make it compiling on "Snow Leopard". Edit file ctypes-1.0.2/source/libffi/fficonfig.py.in and change the row 33:

- all_darwin = ('X86_DARWIN', 'POWERPC_DARWIN')
+ all_darwin = ('X86_DARWIN', )

Now you can install it:

python setup.py build
python setup.py install

Install wxPython

Download from sourceforge:

wxPython2.8-osx-ansi-2.8.10.1-universal-py2.5.dmg

and install it with package.

Install MySQL

PAY ATTENTION: YOU NEED TO INSTALL THE 32bit VERSION!!!

Download the 32bit Mysql version for Mac from here:

Mac OS X 10.5 (x86)

Install the package and then drag the MySQL.PrefPane file on your Library/PreferencePane Then go to System Preference and start Mysql

Finally add /usr/local/mysql/bin to environment variable PATH (.bash_profile if you use bash)

Install Mysql-Python

Now download Mysql-Python from here:

MySQL-python-1.2.3c1.tar.gz

Before install edit site.cfg

threadsafe = False

Install libdasm

Download and install libdasm from here:

libdasm-1.5.tar.gz

python setup.py build_ext
python setup.py install


Procmod group

sudo chgrp procmod debuggerenv25/bin/python2.5
sudo chmod 2755 debuggerenv25/bin/python2.5

To study in deep this, google for mach kernel security setting and kern.tfp.policy

Add pythonw to virtual environment

Create this two files:

pythonw.c

/*
 * This wrapper program executes a python executable hidden inside an
 * application bundle inside the Python framework. This is needed to run
 * GUI code: some GUI API's don't work unless the program is inside an
 * application bundle.
 */
#include <unistd.h>
#include <err.h>

static char Python[] = PYTHONWEXECUTABLE;

int main(int argc, char **argv) {
	argv[0] = Python;
	execv(Python, argv);
	err(1, "execv: %s", Python);
	/* NOTREACHED */
}

install_pythonw.py

#!/usr/bin/python2.5

import os
from os import path
import shutil
from subprocess import call
import sys


USAGE = """
Usage: install_pythonw.py ENVPATH
"""


def main(env_path, script_path):
    # If Python.app already exists, exit.
    python_app_dest = path.join(env_path, 'Python.app')
    if path.exists(python_app_dest):
        print python_app_dest, 'already exists; exiting.'
        return 1
    # Find pythonw.c in script path.
    pythonw_c = path.join(script_path, 'pythonw.c')
    if not path.exists(pythonw_c):
        print pythonw_c, 'does not exist; exiting.'
        return 1
    # Find .Python symlink.
    dot_python = path.join(env_path, '.Python')
    if not path.exists(dot_python):
        print dot_python, 'does not exist; exiting.'
        return 1
    # Find symlink source.
    dot_python_src = os.readlink(dot_python)
    if not path.exists(dot_python_src):
        print dot_python_src, 'does not exist; exiting.'
        return 1
    # Find Python.app in PARDIR/Resources/
    python_app_src = path.join(
        path.dirname(dot_python_src), 'Resources', 'Python.app')
    if not path.exists(python_app_src):
        print python_app_src, 'does not exist; exiting.'
        return 1
    # Copy Python.app to env_path
    shutil.copytree(python_app_src, python_app_dest)
    # Change install names in Python.app binary.
    pythonw_executable = path.join(
        python_app_dest, 'Contents', 'MacOS', 'Python')
    call([
        'install_name_tool',
        '-change',
        dot_python_src,
        dot_python,
        pythonw_executable,
        ])
    # Compile pythonw to bin directory.
    pythonw_dest = path.join(env_path, 'bin', 'pythonw')
    call([
        'cc',
        '-DPYTHONWEXECUTABLE="' + pythonw_executable + '"',
        '-o',
        pythonw_dest,
        pythonw_c,
        ])


if __name__ == '__main__':
    if len(sys.argv) != 2:
        print USAGE
        sys.exit(1)
    env_path = path.abspath(sys.argv[1])
    script_path = path.abspath(path.dirname(sys.argv[0]ÿ
    sys.exit(main(env_path, script_pathÿ

Then execute install_pythonw.py passing as argument the path of the virtualenv debuggerenv25. In this way you add pythonw bin to virtual enviroment becouse it's needed to start Paimei console.

install_pythonw.py debuggerenv25

Completed. Now you can use PaiMei

Use sudo to start python if you have problem with normal execution. To start console go to PaiMei and run:

sudo pythonw console/PAIMEIconsole.pyw



Riferimenti:


Name (required):

Website:

Comment:

Discussione:Install PaiMei on Snow Leopard

1599 Rating: 2.1/5 (20 votes cast)

Strumenti personali