lief 0.8.0__zip

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of lief might be problematic. Click here for more details.

lief-0.8.0/MANIFEST.in ADDED
@@ -0,0 +1 @@
1
+ include README setup.cfg
lief-0.8.0/PKG-INFO ADDED
@@ -0,0 +1,27 @@
1
+ Metadata-Version: 1.1
2
+ Name: lief
3
+ Version: 0.8.0
4
+ Summary: LIEF is a library to instrument executable formats
5
+ Home-page: https://lief.quarkslab.com
6
+ Author: Romain Thomas
7
+ Author-email: rthomas@quarkslab.com
8
+ License: Apache 2.0
9
+ Description-Content-Type: UNKNOWN
10
+ Description: UNKNOWN
11
+ Keywords: parser,elf,pe,macho
12
+ Platform: UNKNOWN
13
+ Classifier: License :: OSI Approved :: Apache Software License
14
+ Classifier: Development Status :: 4 - Beta
15
+ Classifier: Environment :: Console
16
+ Classifier: Intended Audience :: Developers
17
+ Classifier: Intended Audience :: Science/Research
18
+ Classifier: Operating System :: MacOS :: MacOS X
19
+ Classifier: Operating System :: POSIX :: Linux
20
+ Classifier: Operating System :: Microsoft :: Windows
21
+ Classifier: Programming Language :: C++
22
+ Classifier: Programming Language :: Python :: 2
23
+ Classifier: Programming Language :: Python :: 3
24
+ Classifier: Topic :: Software Development :: Libraries
25
+ Classifier: Topic :: Security
26
+ Classifier: Topic :: Scientific/Engineering :: Information Analysis
27
+ Classifier: Topic :: Software Development :: Build Tools
lief-0.8.0/README ADDED
@@ -0,0 +1,15 @@
1
+ LIEF - Python API
2
+ -----------------
3
+
4
+ The purpose of this project is to provide a cross platform library which can parse, modify and abstract ELF, PE and MachO formats.
5
+
6
+ Main features:
7
+
8
+ * Parsing: LIEF can parse ELF, PE, MachO and provides an user-friendly API to access to format internals.
9
+ * Modify: LIEF enables to modify some parts of these formats
10
+ * Abstract: Three formats have common features like sections, symbols, entry point... LIEF factors them.
11
+ * API: LIEF can be used in C, C++ and Python
12
+
13
+
14
+
15
+
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env python
2
+
3
+ import sys
4
+ import _pylief
5
+ from _pylief import *
6
+
7
+ __version__ = _pylief.__version__
8
+
9
+ sys.modules["lief.PE"] = _pylief.PE
10
+ sys.modules["lief.ELF"] = _pylief.ELF
11
+
12
+ sys.modules["lief.ELF.ELF32"] = _pylief.ELF.ELF32
13
+ sys.modules["lief.ELF.ELF64"] = _pylief.ELF.ELF64
14
+
15
+ sys.modules["lief.MachO"] = _pylief.MachO
@@ -0,0 +1,27 @@
1
+ Metadata-Version: 1.1
2
+ Name: lief
3
+ Version: 0.8.0
4
+ Summary: LIEF is a library to instrument executable formats
5
+ Home-page: https://lief.quarkslab.com
6
+ Author: Romain Thomas
7
+ Author-email: rthomas@quarkslab.com
8
+ License: Apache 2.0
9
+ Description-Content-Type: UNKNOWN
10
+ Description: UNKNOWN
11
+ Keywords: parser,elf,pe,macho
12
+ Platform: UNKNOWN
13
+ Classifier: License :: OSI Approved :: Apache Software License
14
+ Classifier: Development Status :: 4 - Beta
15
+ Classifier: Environment :: Console
16
+ Classifier: Intended Audience :: Developers
17
+ Classifier: Intended Audience :: Science/Research
18
+ Classifier: Operating System :: MacOS :: MacOS X
19
+ Classifier: Operating System :: POSIX :: Linux
20
+ Classifier: Operating System :: Microsoft :: Windows
21
+ Classifier: Programming Language :: C++
22
+ Classifier: Programming Language :: Python :: 2
23
+ Classifier: Programming Language :: Python :: 3
24
+ Classifier: Topic :: Software Development :: Libraries
25
+ Classifier: Topic :: Security
26
+ Classifier: Topic :: Scientific/Engineering :: Information Analysis
27
+ Classifier: Topic :: Software Development :: Build Tools
@@ -0,0 +1,10 @@
1
+ MANIFEST.in
2
+ README
3
+ setup.cfg
4
+ setup.py
5
+ lief/__init__.py
6
+ lief.egg-info/PKG-INFO
7
+ lief.egg-info/SOURCES.txt
8
+ lief.egg-info/dependency_links.txt
9
+ lief.egg-info/not-zip-safe
10
+ lief.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,2 @@
1
+ _pylief
2
+ lief
lief-0.8.0/setup.cfg ADDED
@@ -0,0 +1,33 @@
1
+ [metadata]
2
+ name = lief
3
+ description = LIEF is a library to instrument executable formats
4
+ author = Romain Thomas
5
+ author_email = rthomas@quarkslab.com
6
+ url = https://lief.quarkslab.com
7
+ license = Apache 2.0
8
+ keywords = parser, elf, pe, macho
9
+ classifiers =
10
+ License :: OSI Approved :: Apache Software License
11
+ Development Status :: 4 - Beta
12
+ Environment :: Console
13
+ Intended Audience :: Developers
14
+ Intended Audience :: Science/Research
15
+ Operating System :: MacOS :: MacOS X
16
+ Operating System :: POSIX :: Linux
17
+ Operating System :: Microsoft :: Windows
18
+ Programming Language :: C++
19
+ Programming Language :: Python :: 2
20
+ Programming Language :: Python :: 3
21
+ Topic :: Software Development :: Libraries
22
+ Topic :: Security
23
+ Topic :: Scientific/Engineering :: Information Analysis
24
+ Topic :: Software Development :: Build Tools
25
+
26
+ [options]
27
+ zip_safe = False
28
+ packages = lief
29
+
30
+ [egg_info]
31
+ tag_build =
32
+ tag_date = 0
33
+
lief-0.8.0/setup.py ADDED
@@ -0,0 +1,277 @@
1
+ #!/usr/bin/env python
2
+ # -*- coding: utf-8 -*-
3
+ from setuptools import setup
4
+ from setuptools.command.build_ext import build_ext
5
+ from distutils.dir_util import remove_tree, mkpath
6
+ from setuptools.command.bdist_egg import bdist_egg
7
+ from setuptools.command.bdist_egg import log as bdist_egg_log
8
+
9
+ from setuptools.command.sdist import sdist
10
+ from setuptools.command.sdist import log as sdist_log
11
+
12
+ from setuptools.extension import Extension
13
+
14
+ import re
15
+ import os
16
+ import platform
17
+ import shutil
18
+ import sys
19
+ import struct
20
+ import zipfile
21
+
22
+ try:
23
+ from urllib.request import urlopen, Request
24
+ except:
25
+ from urllib2 import urlopen, Request
26
+
27
+
28
+ try:
29
+ from io import BytesIO
30
+ except:
31
+ try:
32
+ from cStringIO import StringIO as BytesIO
33
+ except:
34
+ from StringIO import StringIO as BytesIO
35
+
36
+ package_dir = os.path.dirname(os.path.realpath(__file__))
37
+ pkg_info = os.path.join(package_dir, "PKG-INFO")
38
+ in_source_package = os.path.isfile(pkg_info) # (e.g. pip)
39
+
40
+ is_branch = False
41
+
42
+ libpylief = {
43
+ 'Windows': "_pylief.pyd",
44
+ 'Darwin': "_pylief.so",
45
+ 'Linux': "_pylief.so",
46
+ }
47
+ version_re = r"Version:\s+(?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)\.?(.*)"
48
+ if in_source_package:
49
+ with open(pkg_info, "r") as f:
50
+ major, minor, patch, branch = re.findall(version_re, f.read(), re.MULTILINE)[0]
51
+ lief_version = "{:d}.{:d}.{:d}".format(int(major), int(minor), int(patch))
52
+ is_branch = len(branch.strip()) > 0
53
+ else:
54
+ lief_version = "0.8.0"
55
+
56
+ package_description = open(os.path.join(package_dir, "README")).read()
57
+
58
+
59
+ def get_lief_platform_name():
60
+ system = platform.system()
61
+ arch = struct.calcsize('P') * 8
62
+
63
+ if system == 'Windows':
64
+ return "windows_x64" if arch == 64 else "windows_x32"
65
+ elif system == 'Darwin':
66
+ return "osx" if arch == 64 else "osx_x32"
67
+ elif system == 'Linux':
68
+ return "linux" if arch == 64 else "linux_x32"
69
+
70
+
71
+ class lief_sdist(sdist):
72
+
73
+ user_options = sdist.user_options + [
74
+ ('dev', None, "Add a dev marker")
75
+ ]
76
+
77
+ def initialize_options(self):
78
+ sdist.initialize_options(self)
79
+ self.dev = 0
80
+
81
+ def run(self):
82
+ if self.dev:
83
+ suffix = '.dev-{:s}'.format("0d14f9e")
84
+ self.distribution.metadata.version += suffix
85
+ sdist.run(self)
86
+
87
+ def make_distribution(self):
88
+ sdist.make_distribution(self)
89
+ base_dir = self.distribution.get_fullname()
90
+ base_name = os.path.join(self.dist_dir, base_dir)
91
+ for fmt in self.formats:
92
+ if fmt == 'gztar':
93
+ fmt = 'tar.gz'
94
+
95
+ if fmt == 'bztar':
96
+ fmt = 'tar.bz2'
97
+
98
+ if fmt == 'ztar':
99
+ fmt = 'tar.Z'
100
+
101
+ new_name = "py{name}-{version}.{ext}".format(
102
+ name=self.distribution.get_name(),
103
+ version=lief_version,
104
+ ext=fmt)
105
+
106
+ if self.dev:
107
+ new_name = "py{name}-{version}.dev.{ext}".format(
108
+ name=self.distribution.get_name(),
109
+ version=lief_version,
110
+ ext=fmt)
111
+ new_name = os.path.join(self.dist_dir, new_name)
112
+ shutil.move(base_name + "." + fmt, new_name)
113
+
114
+
115
+
116
+
117
+ class lief_bdist_egg(bdist_egg):
118
+ def initialize_options(self):
119
+ bdist_egg.initialize_options(self)
120
+
121
+ if not in_source_package:
122
+ self.plat_name = get_lief_platform_name()
123
+
124
+
125
+ def run(self):
126
+ if in_source_package:
127
+ self._build_from_source_package()
128
+ else:
129
+ bdist_egg.run(self)
130
+
131
+ def _build_from_source_package(self):
132
+ python_version = sys.version_info
133
+ python_major_version = python_version[0]
134
+ os_version = get_lief_platform_name()
135
+
136
+ url_branch_fmt = "https://github.com/lief-project/packages/raw/lief-{branch}-latest/lief-{version}-py{pyversion}-{platform}.{ext}"
137
+ url_release_fmt = "https://github.com/lief-project/LIEF/releases/download/{version}/lief-{version}-py{pyversion}-{platform}.{ext}"
138
+ url_userpath = "~/lief-{version}-py{pyversion}-{platform}.{ext}"
139
+
140
+ url = ""
141
+ if is_branch:
142
+ url = url_branch_fmt.format(
143
+ branch='master',
144
+ platform=os_version,
145
+ version=lief_version,
146
+ pyversion="{}.{}".format(python_version[0], python_version[1]),
147
+ ext="egg")
148
+ else:
149
+ url = url_release_fmt.format(
150
+ platform=os_version,
151
+ version=lief_version,
152
+ pyversion="{}.{}".format(python_version[0], python_version[1]),
153
+ ext="egg")
154
+
155
+ bdist_egg_log.info("Url: {}".format(url))
156
+ egg_data = None
157
+ network_error = None
158
+ try:
159
+ egg_data = urlopen(url).read()
160
+ except Exception as e:
161
+ network_error = e
162
+
163
+
164
+ if network_error is not None:
165
+ bdist_egg_log.warn(network_error)
166
+ url = url_userpath.format(
167
+ platform=os_version,
168
+ version=lief_version,
169
+ pyversion="{}.{}".format(python_version[0], python_version[1]),
170
+ ext="egg")
171
+ url = os.path.expanduser(url)
172
+ if os.path.isfile(url):
173
+ with open(url, 'rb') as f:
174
+ egg_data = f.read()
175
+ else:
176
+ raise Exception("Unable to find {}".format(url))
177
+
178
+
179
+ egg_file = BytesIO(egg_data)
180
+
181
+ mkpath(os.path.dirname(self.egg_output))
182
+
183
+ bdist_egg_log.info("Output: {}".format(self.egg_output))
184
+ with open(self.egg_output, 'wb') as f:
185
+ f.write(egg_file.getvalue())
186
+
187
+ getattr(self.distribution, 'dist_files', []).append(
188
+ ('bdist_egg', "{}.{}".format(python_version[0], python_version[1]), self.egg_output))
189
+
190
+
191
+
192
+ class lief_build_ext(build_ext):
193
+
194
+
195
+ def build_extension(self, ext):
196
+ self.target = self.get_ext_fullpath(ext.name)
197
+ target_dir = os.path.dirname(self.target)
198
+
199
+ try:
200
+ os.makedirs(target_dir)
201
+ except:
202
+ pass
203
+
204
+ if in_source_package:
205
+ self._install_from_source_package()
206
+ else:
207
+ shutil.copyfile(libpylief[platform.system()], self.target)
208
+
209
+
210
+ def _install_from_source_package(self):
211
+ python_version = sys.version_info
212
+ python_major_version = python_version[0]
213
+ os_version = get_lief_platform_name()
214
+ target_extension = os.path.splitext(self.target)[1]
215
+
216
+ url_branch_fmt = "https://github.com/lief-project/packages/raw/lief-{branch}-latest/lief-{version}-py{pyversion}-{platform}.{ext}"
217
+ url_release_fmt = "https://github.com/lief-project/LIEF/releases/download/{version}/lief-{version}-py{pyversion}-{platform}.{ext}"
218
+ url_userpath = "~/lief-{version}-py{pyversion}-{platform}.{ext}"
219
+
220
+ url = ""
221
+ if is_branch:
222
+ url = url_branch_fmt.format(
223
+ branch='master',
224
+ platform=os_version,
225
+ version=lief_version,
226
+ pyversion="{}.{}".format(python_version[0], python_version[1]),
227
+ ext="egg")
228
+ else:
229
+ url = url_release_fmt.format(
230
+ platform=os_version,
231
+ version=lief_version,
232
+ pyversion="{}.{}".format(python_version[0], python_version[1]),
233
+ ext="egg")
234
+
235
+ bdist_egg_log.info("Url: {}".format(url))
236
+ egg_data = None
237
+ network_error = None
238
+ try:
239
+ egg_data = urlopen(url).read()
240
+ except Exception as e:
241
+ network_error = e
242
+
243
+ if network_error is not None:
244
+ bdist_egg_log.warn(network_error)
245
+ url = url_userpath.format(
246
+ platform=os_version,
247
+ version=lief_version,
248
+ pyversion="{}.{}".format(python_version[0], python_version[1]),
249
+ ext="egg")
250
+ url = os.path.expanduser(url)
251
+ if os.path.isfile(url):
252
+ with open(url, 'rb') as f:
253
+ egg_data = f.read()
254
+ else:
255
+ raise Exception("Unable to find {}".format(url))
256
+
257
+
258
+
259
+
260
+
261
+ egg_file = BytesIO(egg_data)
262
+
263
+ egg_zip = zipfile.ZipFile(egg_file)
264
+ extension_member = [info for info in egg_zip.infolist() if info.filename.endswith(target_extension)][0]
265
+ extension_data = egg_zip.read(extension_member)
266
+ with open(self.target, 'wb') as f:
267
+ f.write(extension_data)
268
+
269
+ setup(
270
+ version = lief_version,
271
+ ext_modules = [Extension('_pylief', [])],
272
+ cmdclass={
273
+ 'build_ext': lief_build_ext,
274
+ 'bdist_egg': lief_bdist_egg,
275
+ 'sdist': lief_sdist
276
+ },
277
+ )