forked from jfoote/exploitable
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
125 lines (105 loc) · 4.16 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#!/usr/bin/env python
# The MIT License (MIT)
#
# Copyright (c) 2013 Jonathan Foote
# (c) 2015 rc0r
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of
# this software and associated documentation files (the "Software"), to deal in
# the Software without restriction, including without limitation the rights to
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
# the Software, and to permit persons to whom the Software is furnished to do so,
# subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
'''
A distutils-compatible setup.py script.
This script includes a hack to support both virtualenv and standard
installation paths on Ubuntu 15.04. See the following URL for more information:
https://github.com/jfoote/exploitable/pull/34#issuecomment-168158763
'''
from setuptools.command.bdist_egg import bdist_egg
from setuptools import setup, Command, find_packages
import os
import subprocess
import shlex
class CustomBdistEgg(bdist_egg):
"""
Our custom "install" class that overrides the default setuptools
bdist_egg procedure. We use bdist_egg here because in contrary
to a custom install it also gets called when setup is run from
easy_install.
"""
def run(self):
# run default setup procedure
bdist_egg.run(self)
import sys
# Check whether setup.py is run from inside a virtualenv and get the
# appropriate install location for exploitable.py.
if hasattr(sys, 'real_prefix'):
# Inside virtualenv:
# Use Python standard library location.
from distutils.sysconfig import get_python_lib
install_base_path = get_python_lib()
else:
# Not inside virtualenv, operating on a real Python environment:
# Use location for Python site-specific, platform-specific files.
from sysconfig import get_path
install_base_path = get_path('platlib')
path_to_exploitable = os.path.join(install_base_path,
os.path.basename(self.egg_output),
'exploitable',
'exploitable.py')
print('\x1b[0;32m**********************************************')
print(' Install complete! Source exploitable.py from')
print(' your .gdbinit to make it available in GDB:')
print('')
print(' \x1b[1;37mecho \"source %s\" >> ~/.gdbinit\x1b[0;32m' % path_to_exploitable)
print('**********************************************\x1b[0m')
class TestCommand(Command):
"""
Custom test command.
"""
description = 'Run exploitable tests.'
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
print("testing for x86, for ARM and more args, see scripts in test/ dir")
run("test/x86.sh build run_test clean")
print("done")
def run(cmd):
try:
print(cmd)
subprocess.check_call(shlex.split(cmd))
except subprocess.CalledProcessError:
pass
dependencies = []
setup(
name='exploitable',
version='1.32',
url='https://github.com/jfoote/exploitable',
author='Jonathan Foote',
author_email='[email protected]',
description='The \'exploitable\' GDB plugin.',
long_description=open('./README.md', 'r').read(),
requires=dependencies,
packages=find_packages(),
platforms=[
'Any'
],
cmdclass={
'bdist_egg': CustomBdistEgg,
'test': TestCommand
}
)