binary.scm
1 | ;;; GNU Guix --- Functional package management for GNU |
2 | ;;; Copyright © 2017 Julien Lepiller <julien@lepiller.eu> |
3 | ;;; |
4 | ;;; This file is part of GNU Guix. |
5 | ;;; |
6 | ;;; GNU Guix is free software; you can redistribute it and/or modify it |
7 | ;;; under the terms of the GNU General Public License as published by |
8 | ;;; the Free Software Foundation; either version 3 of the License, or (at |
9 | ;;; your option) any later version. |
10 | ;;; |
11 | ;;; GNU Guix is distributed in the hope that it will be useful, but |
12 | ;;; WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | ;;; GNU General Public License for more details. |
15 | ;;; |
16 | ;;; You should have received a copy of the GNU General Public License |
17 | ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. |
18 | |
19 | (define-module (more packages binary) |
20 | #:use-module ((guix licenses) #:prefix license:) |
21 | #:use-module (gnu packages) |
22 | #:use-module (guix packages) |
23 | #:use-module (guix download) |
24 | #:use-module (guix git-download) |
25 | #:use-module (guix utils) |
26 | #:use-module (guix build-system gnu) |
27 | #:use-module (guix build-system python) |
28 | #:use-module (gnu packages compression) |
29 | #:use-module (gnu packages glib) |
30 | #:use-module (gnu packages multiprecision) |
31 | #:use-module (gnu packages pkg-config) |
32 | #:use-module (gnu packages python) |
33 | #:use-module (gnu packages tls) |
34 | #:use-module (gnu packages zip) |
35 | #:use-module (more packages python) |
36 | #:use-module (more packages smt)) |
37 | |
38 | (define-public python-pyelftools |
39 | (package |
40 | (name "python-pyelftools") |
41 | (version "0.24") |
42 | (source (origin |
43 | (method url-fetch) |
44 | (uri (string-append "https://github.com/eliben/pyelftools/archive/v" |
45 | version ".tar.gz")) |
46 | (file-name (string-append name "-" version ".tar.gz")) |
47 | (sha256 |
48 | (base32 |
49 | "1iw47b20brg0ah86s9a2dn1f70qfmdv20p04q131vmnwa9g066f4")))) |
50 | (build-system python-build-system) |
51 | (native-inputs |
52 | `(("utils" ,python-utils))) |
53 | (arguments |
54 | `(#:tests? #f)) |
55 | (home-page "https://github.com/eliben/pyelftools") |
56 | (synopsis "Parsing and analyzing ELF files and DWARF debugging information") |
57 | (description |
58 | "Python library for parsing and analyzing ELF files and DWARF debugging information.") |
59 | (license license:public-domain))) |
60 | |
61 | (define-public python2-pyelftools |
62 | (package |
63 | (inherit (package-with-python2 python-pyelftools)) |
64 | (arguments |
65 | `(#:tests? #t |
66 | #:python ,python-2)))) |
67 | |
68 | |
69 | (define-public capstone |
70 | (package |
71 | (name "capstone") |
72 | (version "3.0.4") |
73 | (source (origin |
74 | (method url-fetch) |
75 | (uri (string-append "https://github.com/aquynh/capstone/archive/" |
76 | version ".tar.gz")) |
77 | (file-name (string-append name "-" version ".tar.gz")) |
78 | (sha256 |
79 | (base32 |
80 | "1whl5c8j6vqvz2j6ay2pyszx0jg8d3x8hq66cvgghmjchvsssvax")))) |
81 | (build-system gnu-build-system) |
82 | (arguments |
83 | `(#:tests? #f |
84 | #:make-flags (list (string-append "PREFIX=" (assoc-ref %outputs "out")) |
85 | "CC=gcc") |
86 | #:phases |
87 | (modify-phases %standard-phases |
88 | (delete 'configure)))) |
89 | (home-page "http://www.capstone-engine.org") |
90 | (synopsis "Disassembler") |
91 | (description |
92 | "Capstone can disassemble machine code for many supported architectures |
93 | such as x86, x86_64, arm, arm64, mips, ppc, sparc, sysz and xcore. It provides |
94 | bindings for Python, Java, OCaml and more.") |
95 | (license (list license:bsd-3 license:expat)))) |
96 | |
97 | ;; This package has a timestamp embedded in |
98 | ;; lib/python3.5/site-packages/capstone/__pycache__/__iti__.cpython-35.pyc |
99 | (define-public python-capstone |
100 | (package |
101 | (inherit capstone) |
102 | (name "python-capstone") |
103 | (propagated-inputs |
104 | `(("capstone" ,capstone))) |
105 | (build-system python-build-system) |
106 | (arguments |
107 | `(#:tests? #f |
108 | #:phases |
109 | (modify-phases %standard-phases |
110 | (add-after 'unpack 'chdir-and-fix-setup-py |
111 | (lambda _ |
112 | (chdir "bindings/python") |
113 | (substitute* "setup.py" (("data_files=.*") "")) |
114 | (substitute* "capstone/__init__.py" |
115 | (("_lib_path =.*") |
116 | (string-append "_lib_path = '" |
117 | (assoc-ref %build-inputs "capstone") |
118 | "/lib'\n"))) |
119 | #t))))))) |
120 | |
121 | (define-public python2-capstone |
122 | (package-with-python2 python-capstone)) |
123 | |
124 | (define-public python-pefile |
125 | (package |
126 | (name "python-pefile") |
127 | (version "2016.3.28") |
128 | (source |
129 | (origin |
130 | (method url-fetch) |
131 | (uri (pypi-uri "pefile" version)) |
132 | (sha256 |
133 | (base32 |
134 | "0ysz17ci0nhc5gi6j9si0fg87lzc7vcz3ccbi6qgfgjwbc422h7j")))) |
135 | (build-system python-build-system) |
136 | (arguments |
137 | `(#:tests? #f)); no test |
138 | (home-page "https://github.com/erocarrera/pefile") |
139 | (synopsis "Parse and work with Portable Executable (aka PE) files") |
140 | (description "Pefile is a multi-platform Python module to parse and work |
141 | with Portable Executable (aka PE) files. Most of the information contained in |
142 | the PE headers is accessible as well as all sections' details and their data. |
143 | The structures defined in the Windows header files will be accessible as |
144 | attributes in the PE instance. The naming of fields/attributes will try to |
145 | adhere to the naming scheme in those headers. Only shortcuts added for |
146 | convenience will depart from that convention.") |
147 | (license license:expat))) |
148 | |
149 | (define-public python2-pefile |
150 | (package-with-python2 python-pefile)) |
151 | |
152 | (define-public python2-archinfo |
153 | (package |
154 | (name "python2-archinfo") |
155 | (version "6.7.1.13") |
156 | (source (origin |
157 | (method url-fetch) |
158 | (uri (pypi-uri "archinfo" version)) |
159 | (sha256 |
160 | (base32 |
161 | "0x896mk98r6g9h3rxpqq9ri0s6v9n937jx0fzn7i61zn61n7whzw")))) |
162 | (build-system python-build-system) |
163 | (arguments |
164 | `(#:python ,python-2)) |
165 | (home-page "https://github.com/angr/archinfo") |
166 | (synopsis "Collection of classes that contain architecture-specific information") |
167 | (description "Archinfo is a collection of classes that contain |
168 | architecture-specific information. It is useful for cross-architecture tools |
169 | (such as pyvex).") |
170 | (license license:bsd-2))) |
171 | |
172 | (define-public angr-vex |
173 | (package |
174 | (name "angr-vex") |
175 | (version "1") |
176 | (source (origin |
177 | (method git-fetch) |
178 | (uri (git-reference |
179 | (url "https://github.com/angr/vex.git") |
180 | (commit "058410ede7ee74231255f6ae77cae8476c8a3ef4"))) |
181 | (sha256 |
182 | (base32 |
183 | "02wi1705pa0xbwfqx3jj6g7nnvzi8whgmnd29fp1i7n4qz20gcgb")) |
184 | (file-name (string-append name "-" version)))) |
185 | (build-system gnu-build-system) |
186 | (arguments |
187 | `(#:make-flags |
188 | (list "CC=gcc") |
189 | #:tests? #f |
190 | #:phases |
191 | (modify-phases %standard-phases |
192 | (delete 'configure) |
193 | (replace 'install |
194 | (lambda* (#:key outputs #:allow-other-keys) |
195 | (let* ((out (assoc-ref outputs "out")) |
196 | (lib (string-append out "/lib")) |
197 | (include (string-append out "/include"))) |
198 | (mkdir-p lib) |
199 | (mkdir-p include) |
200 | (copy-recursively "pub" include) |
201 | (copy-file "libvex.a" (string-append lib "/libvex.a")))))))) |
202 | (home-page "https://github.com/angr/vex") |
203 | (synopsis "Fork of libVEX for PyVEX") |
204 | (description "This is a mirror of libVEX (of the Valgrind project: |
205 | valgrind.org) for use with PyVEX.") |
206 | (license license:gpl2+))) |
207 | |
208 | (define-public python2-pyvex |
209 | (package |
210 | (name "python2-pyvex") |
211 | (version "6.7.1.31") |
212 | (source (origin |
213 | (method url-fetch) |
214 | (uri (pypi-uri "pyvex" version)) |
215 | (sha256 |
216 | (base32 |
217 | "0wwz1jqrjbkg8j7mr3wrgw84aaph7h9v2r7j4q035rn7b38n5x54")))) |
218 | (build-system python-build-system) |
219 | (inputs `(("angr-vex" ,angr-vex))) |
220 | (propagated-inputs |
221 | `(("archinfo" ,python2-archinfo) |
222 | ("pycparser" ,python2-pycparser) |
223 | ("cffi" ,python2-cffi))) |
224 | (arguments |
225 | `(#:python ,python-2 |
226 | #:phases |
227 | (modify-phases %standard-phases |
228 | (add-before 'build 'fix-setup.py |
229 | (lambda* (#:key inputs #:allow-other-keys) |
230 | (substitute* "setup.py" |
231 | (("VEX_PATH = .*") |
232 | (string-append "VEX_PATH = '" (assoc-ref inputs "angr-vex") "'")) |
233 | ((".*self.execute\\(_build_vex.*") |
234 | "") |
235 | (("e\\['VEX_LIB_PATH'\\] = .*") |
236 | "e['VEX_LIB_PATH'] = os.path.join(VEX_PATH, 'lib')\n") |
237 | (("'pub'") |
238 | "'include'"))))))) |
239 | (home-page "https://github.com/angr/pyvex") |
240 | (synopsis "PyVEX exposes VEX into Python") |
241 | (description "VEX is an intermediate representation that is useful to carry |
242 | analyses on binary. PyVEX exposes VEX into Python.") |
243 | (license license:bsd-2))) |
244 | |
245 | (define-public unicorn |
246 | (package |
247 | (name "unicorn") |
248 | (version "1.0-rc3") |
249 | (source (origin |
250 | (method url-fetch) |
251 | (uri (string-append "https://github.com/unicorn-engine/unicorn/archive/" |
252 | version ".tar.gz")) |
253 | (file-name (string-append name "-" version ".tar.gz")) |
254 | (sha256 |
255 | (base32 |
256 | "18sf8vbmf08ss27qhiv7la492k39q0ci8kpjx836bv7rq3cbgb2q")))) |
257 | (build-system gnu-build-system) |
258 | (arguments |
259 | `(#:phases |
260 | (modify-phases %standard-phases |
261 | (delete 'configure)) |
262 | #:tests? #f |
263 | #:make-flags |
264 | (list "CC=gcc" |
265 | (string-append "PREFIX=" (assoc-ref %outputs "out"))))) |
266 | (native-inputs |
267 | `(("python" ,python-2) |
268 | ("pkg-config" ,pkg-config))) |
269 | (home-page "http://www.unicorn-engine.org/") |
270 | (synopsis "CPU emulator") |
271 | (description "Unicorn is a lightweight multi-platform, multi-architecture |
272 | CPU emulator framework.") |
273 | (license (list license:gpl2 license:lgpl2.0)))) |
274 | |
275 | ;; Not reproducible |
276 | (define-public python-unicorn |
277 | (package |
278 | (inherit unicorn) |
279 | (name "python-unicorn") |
280 | (propagated-inputs |
281 | `(("unicorn" ,unicorn))) |
282 | (build-system python-build-system) |
283 | (arguments |
284 | `(#:tests? #f |
285 | #:phases (modify-phases %standard-phases |
286 | (add-after 'unpack 'chdir-and-fix-setup-py |
287 | (lambda _ |
288 | (chdir "bindings/python") |
289 | (substitute* "setup.py" (("build_libraries\\(\\)\n") "\n")) |
290 | (substitute* "unicorn/unicorn.py" |
291 | (("'',") |
292 | (string-append "'" |
293 | (assoc-ref %build-inputs "unicorn") |
294 | "/lib',"))) |
295 | #t))))))) |
296 | |
297 | (define-public python2-unicorn |
298 | (package |
299 | (inherit (package-with-python2 python-unicorn)) |
300 | (propagated-inputs |
301 | `(("unicorn" ,unicorn) |
302 | ("pyvex" ,python2-pyvex))))) |
303 | |
304 | (define-public python2-simuvex |
305 | (package |
306 | (name "python2-simuvex") |
307 | (version "6.7.1.31") |
308 | (source (origin |
309 | (method url-fetch) |
310 | (uri (pypi-uri "simuvex" version)) |
311 | (sha256 |
312 | (base32 |
313 | "150jwf55pib7ndz7bjb4fxifqqgdxx7n1f5qa87mz6349qvi1xji")) |
314 | (modules '((guix build utils))) |
315 | (snippet |
316 | '(substitute* "setup.py" |
317 | (("dpkt-fix") "dpkt"))))) |
318 | (build-system python-build-system) |
319 | (native-inputs |
320 | `(("pkg-config" ,pkg-config) |
321 | ("enum34" ,python2-enum34))) |
322 | (propagated-inputs |
323 | `(("pyvex" ,python2-pyvex) |
324 | ("bintrees" ,python2-bintrees) |
325 | ("dpkt" ,python2-dpkt) |
326 | ("cooldict" ,python2-cooldict) |
327 | ("cachetools" ,python2-cachetools) |
328 | ("claripy" ,python2-claripy) |
329 | ("unicorn" ,python2-unicorn) |
330 | ("glib" ,glib))) |
331 | (inputs |
332 | `(("zlib" ,zlib))) |
333 | (arguments |
334 | `(#:python ,python-2)) |
335 | (home-page "https://github.com/angr/cle") |
336 | (synopsis "Abstraction of process memory") |
337 | (description "CLE loads binaries and their associated libraries, resolves |
338 | imports and provides an abstraction of process memory the same way as if it was |
339 | loaded by the OS's loader.") |
340 | (license license:bsd-2))) |
341 | |
342 | (define-public python2-cle |
343 | (package |
344 | (name "python2-cle") |
345 | (version "6.7.1.31") |
346 | (source (origin |
347 | (method url-fetch) |
348 | (uri (pypi-uri "cle" version)) |
349 | (sha256 |
350 | (base32 |
351 | "0llk54f9p3b73f1pk19axlhw8yw80fdv07jkghqmqwd6xrnpnmmc")) |
352 | (modules '((guix build utils))) |
353 | (snippet |
354 | '(substitute* "setup.py" |
355 | ((", \"idalink\"") ""))))); Idalink is not acceptable |
356 | (build-system python-build-system) |
357 | (propagated-inputs |
358 | `(("pyelftools" ,python2-pyelftools) |
359 | ("cffi" ,python2-cffi) |
360 | ("archinfo" ,python2-archinfo) |
361 | ("future" ,python2-future) |
362 | ("pyvex" ,python2-pyvex) |
363 | ("pefile" ,python2-pefile))) |
364 | (arguments |
365 | `(#:python ,python-2)) |
366 | (home-page "https://github.com/angr/cle") |
367 | (synopsis "Abstraction of process memory") |
368 | (description "CLE loads binaries and their associated libraries, resolves |
369 | imports and provides an abstraction of process memory the same way as if it was |
370 | loaded by the OS's loader.") |
371 | (license license:bsd-2))) |
372 | |
373 | (define-public python2-angr |
374 | (package |
375 | (name "python2-angr") |
376 | (version "6.7.1.31") |
377 | (source (origin |
378 | (method url-fetch) |
379 | (uri (pypi-uri "angr" version)) |
380 | (sha256 |
381 | (base32 |
382 | "19msllsjwc869824sx1qah6vnb03z22s71fph215ykbbb2843p1k")))) |
383 | (build-system python-build-system) |
384 | (arguments |
385 | `(#:python ,python-2)) |
386 | (propagated-inputs |
387 | `(("cle" ,python2-cle) |
388 | ("capstone" ,python2-capstone) |
389 | ("six" ,python2-six) |
390 | ("utils" ,python2-utils) |
391 | ("mulpyplexer" ,python2-mulpyplexer) |
392 | ("rpyc" ,python2-rpyc) |
393 | ("enum34" ,python2-enum34) |
394 | ("networkx" ,python2-networkx) |
395 | ("futures" ,python2-futures) |
396 | ("progressbar" ,python2-progressbar2) |
397 | ("simuvex" ,python2-simuvex))) |
398 | (home-page "https://github.com/angr/angr") |
399 | (synopsis "Angr is a python framework for analyzing binaries") |
400 | (description "angr is a python framework for analyzing binaries. It |
401 | focuses on both static and dynamic symbolic (\"concolic\") analysis, making it |
402 | applicable to a variety of tasks.") |
403 | (license license:bsd-2))) |
404 | |
405 | (define-public radare2 |
406 | (package |
407 | (name "radare2") |
408 | (version "1.2.1") |
409 | (source (origin |
410 | (method url-fetch) |
411 | (uri (string-append "http://cloud.radare.org/get/" version "/" |
412 | name "-" version ".tar.gz")) |
413 | (sha256 |
414 | (base32 |
415 | "1rj9xinvasd819f39yf7lwwqykdagypfwi0jdmf4nzvhhndra5cf")) |
416 | (modules '((guix build utils))) |
417 | (snippet |
418 | '(begin |
419 | (substitute* "libr/asm/p/Makefile" |
420 | (("LDFLAGS\\+=") "LDFLAGS+=-Wl,-rpath=$(LIBDIR) ")) |
421 | (substitute* "libr/parse/p/Makefile" |
422 | (("LDFLAGS\\+=") "LDFLAGS+=-Wl,-rpath=$(LIBDIR) ")) |
423 | (substitute* "libr/bin/p/Makefile" |
424 | (("LDFLAGS\\+=") "LDFLAGS+=-Wl,-rpath=$(LIBDIR) ")))))) |
425 | (build-system gnu-build-system) |
426 | (arguments |
427 | '(#:tests? #f |
428 | #:phases |
429 | (modify-phases %standard-phases |
430 | (add-before 'configure 'mklibdir |
431 | (lambda* (#:key inputs #:allow-other-keys) |
432 | (mkdir-p (string-append (assoc-ref %outputs "out") "/lib"))))) |
433 | #:configure-flags |
434 | (list "--with-sysmagic" "--with-syszip" "--with-openssl" |
435 | "--without-nonpic" "--with-rpath" "--with-syscapstone") |
436 | #:make-flags |
437 | (list "CC=gcc"))) |
438 | (inputs |
439 | `(("openssl" ,openssl) |
440 | ("zip" ,zip) |
441 | ("gmp" ,gmp) |
442 | ("capstone" ,capstone))) |
443 | (native-inputs |
444 | `(("pkg-config" ,pkg-config))) |
445 | (home-page "https://rada.re/") |
446 | (synopsis "Binary analysis tool") |
447 | (description |
448 | "Radare2 is a tool for reversing binaries.") |
449 | (license license:gpl3+))) |
450 |