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 | ;; rc required by python2-angr |
69 | (define-public capstone |
70 | (package |
71 | (name "capstone") |
72 | (version "3.0.5-rc2") |
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 | "1cqms9r2p43aiwp5spd84zaccp16ih03r7sjhrv16nddahj0jz2q")))) |
81 | (build-system gnu-build-system) |
82 | (arguments |
83 | `(#:tests? #f |
84 | #:make-flags (list (string-append "PREFIX=" %output) |
85 | "CC=gcc") |
86 | #:phases |
87 | (modify-phases %standard-phases |
88 | (delete 'configure) |
89 | (add-before 'build 'fix-cstool-ldflags |
90 | (lambda* (#:key outputs #:allow-other-keys) |
91 | (substitute* "cstool/Makefile" |
92 | (("LDFLAGS =") |
93 | (string-append "LDFLAGS = -Wl,-rpath=" (assoc-ref outputs "out") |
94 | "/lib")))))))) |
95 | (home-page "http://www.capstone-engine.org") |
96 | (synopsis "Disassembler") |
97 | (description |
98 | "Capstone can disassemble machine code for many supported architectures |
99 | such as x86, x86_64, arm, arm64, mips, ppc, sparc, sysz and xcore. It provides |
100 | bindings for Python, Java, OCaml and more.") |
101 | (license (list license:bsd-3 license:expat)))) |
102 | |
103 | ;; This package has a timestamp embedded in |
104 | ;; lib/python3.5/site-packages/capstone/__pycache__/__iti__.cpython-35.pyc |
105 | (define-public python-capstone |
106 | (package |
107 | (inherit capstone) |
108 | (name "python-capstone") |
109 | (propagated-inputs |
110 | `(("capstone" ,capstone))) |
111 | (build-system python-build-system) |
112 | (arguments |
113 | `(#:tests? #f |
114 | #:phases |
115 | (modify-phases %standard-phases |
116 | (add-after 'unpack 'chdir-and-fix-setup-py |
117 | (lambda _ |
118 | (chdir "bindings/python") |
119 | (substitute* "setup.py" ((".* build_libraries.*") "")) |
120 | (substitute* "capstone/__init__.py" |
121 | (("pkg_resources.resource_filename.*") |
122 | (string-append "'" (assoc-ref %build-inputs "capstone") "/lib',\n"))) |
123 | #t))))))) |
124 | |
125 | (define-public python2-capstone |
126 | (package-with-python2 python-capstone)) |
127 | |
128 | (define-public capstone-git |
129 | (package |
130 | (inherit capstone) |
131 | (version "3.0.5-rc2") |
132 | (name "capstone-git") |
133 | (source (origin |
134 | (method git-fetch) |
135 | (uri (git-reference (url "https://github.com/aquynh/capstone.git") |
136 | (commit "b6c4c3f5c79684b02d0672b50b4db494f6ce60f9"))) |
137 | (file-name (string-append name "-" version)) |
138 | (sha256 |
139 | (base32 |
140 | "0kqdfp0flx5czzwr490pzn9mzsxcw8qpcfz4y7bpf2cklsr4mh25")))) |
141 | (arguments |
142 | `(#:tests? #f |
143 | #:make-flags (list (string-append "PREFIX=" (assoc-ref %outputs "out")) |
144 | "CC=gcc") |
145 | #:phases |
146 | (modify-phases %standard-phases |
147 | (delete 'configure) |
148 | (add-before 'build 'fix-cstool |
149 | (lambda* (#:key outputs #:allow-other-keys) |
150 | (substitute* "cstool/Makefile" |
151 | (("LDFLAGS =") |
152 | (string-append "LDFLAGS = -Wl,-rpath=" (assoc-ref outputs "out") "/lib")))))))))) |
153 | |
154 | (define-public python-capstone-git |
155 | (package |
156 | (inherit capstone-git) |
157 | (name "python-capstone-git") |
158 | (propagated-inputs |
159 | `(("capstone" ,capstone-git))) |
160 | (build-system python-build-system) |
161 | (arguments |
162 | `(#:tests? #f |
163 | #:phases |
164 | (modify-phases %standard-phases |
165 | (add-after 'unpack 'chdir-and-fix-setup-py |
166 | (lambda _ |
167 | (chdir "bindings/python") |
168 | (substitute* "setup.py" ((" *build_libraries.*") "\n")) |
169 | (substitute* "capstone/__init__.py" |
170 | (("pkg_resources.resource_filename.*") |
171 | (string-append "\"" (assoc-ref %build-inputs "capstone") "/lib\",\n"))) |
172 | #t))))))) |
173 | |
174 | (define-public python2-capstone-git |
175 | (package-with-python2 python-capstone-git)) |
176 | |
177 | |
178 | (define-public python-pefile |
179 | (package |
180 | (name "python-pefile") |
181 | (version "2016.3.28") |
182 | (source |
183 | (origin |
184 | (method url-fetch) |
185 | (uri (pypi-uri "pefile" version)) |
186 | (sha256 |
187 | (base32 |
188 | "0ysz17ci0nhc5gi6j9si0fg87lzc7vcz3ccbi6qgfgjwbc422h7j")))) |
189 | (build-system python-build-system) |
190 | (arguments |
191 | `(#:tests? #f)); no test |
192 | (home-page "https://github.com/erocarrera/pefile") |
193 | (synopsis "Parse and work with Portable Executable (aka PE) files") |
194 | (description "Pefile is a multi-platform Python module to parse and work |
195 | with Portable Executable (aka PE) files. Most of the information contained in |
196 | the PE headers is accessible as well as all sections' details and their data. |
197 | The structures defined in the Windows header files will be accessible as |
198 | attributes in the PE instance. The naming of fields/attributes will try to |
199 | adhere to the naming scheme in those headers. Only shortcuts added for |
200 | convenience will depart from that convention.") |
201 | (license license:expat))) |
202 | |
203 | (define-public python2-pefile |
204 | (package-with-python2 python-pefile)) |
205 | |
206 | (define-public python2-archinfo |
207 | (package |
208 | (name "python2-archinfo") |
209 | (version "6.7.4.12") |
210 | (source (origin |
211 | (method url-fetch) |
212 | (uri (pypi-uri "archinfo" version)) |
213 | (sha256 |
214 | (base32 |
215 | "1kfc9nk73i5rr3xz8mv00cp76p7dc62h9pd8hvnda414jhx7n0pb")))) |
216 | (build-system python-build-system) |
217 | (arguments |
218 | `(#:python ,python-2)) |
219 | (home-page "https://github.com/angr/archinfo") |
220 | (synopsis "Collection of classes that contain architecture-specific information") |
221 | (description "Archinfo is a collection of classes that contain |
222 | architecture-specific information. It is useful for cross-architecture tools |
223 | (such as pyvex).") |
224 | (license license:bsd-2))) |
225 | |
226 | (define-public angr-vex |
227 | (package |
228 | (name "angr-vex") |
229 | (version "1") |
230 | (source (origin |
231 | (method git-fetch) |
232 | (uri (git-reference |
233 | (url "https://github.com/angr/vex.git") |
234 | (commit "3a620e43ecc71cb9e5470995a45bbce4a600293f"))) |
235 | (sha256 |
236 | (base32 |
237 | "1qxpwi9961140dnys1iywm043nbm13qg2vw9xi1bjjdh80hbnfw4")) |
238 | (file-name (string-append name "-" version)))) |
239 | (build-system gnu-build-system) |
240 | (arguments |
241 | `(#:make-flags |
242 | (list "CC=gcc" "CC_NATIVE=gcc") |
243 | #:tests? #f |
244 | #:phases |
245 | (modify-phases %standard-phases |
246 | (delete 'configure) |
247 | (add-before 'build 'get-Makefile |
248 | (lambda _ |
249 | (copy-file "Makefile-gcc" "Makefile"))) |
250 | (replace 'install |
251 | (lambda* (#:key outputs #:allow-other-keys) |
252 | (let* ((out (assoc-ref outputs "out")) |
253 | (lib (string-append out "/lib")) |
254 | (include (string-append out "/include"))) |
255 | (mkdir-p lib) |
256 | (mkdir-p include) |
257 | (copy-recursively "pub" include) |
258 | (copy-file "libvex.a" (string-append lib "/libvex.a")))))))) |
259 | (home-page "https://github.com/angr/vex") |
260 | (synopsis "Fork of libVEX for PyVEX") |
261 | (description "This is a mirror of libVEX (of the Valgrind project: |
262 | valgrind.org) for use with PyVEX.") |
263 | (license license:gpl2+))) |
264 | |
265 | (define-public python2-pyvex |
266 | (package |
267 | (name "python2-pyvex") |
268 | (version "6.7.4.12") |
269 | (source (origin |
270 | (method url-fetch) |
271 | (uri (pypi-uri "pyvex" version)) |
272 | (sha256 |
273 | (base32 |
274 | "1x57aq96ka7gz6qcj9zqwdcylfks4q3iiykismyk1g0vp68qlwv9")))) |
275 | (build-system python-build-system) |
276 | (inputs `(("angr-vex" ,angr-vex))) |
277 | (propagated-inputs |
278 | `(("archinfo" ,python2-archinfo) |
279 | ("pycparser" ,python2-pycparser) |
280 | ("cffi" ,python2-cffi))) |
281 | (arguments |
282 | `(#:python ,python-2 |
283 | #:phases |
284 | (modify-phases %standard-phases |
285 | (add-before 'build 'fix-setup.py |
286 | (lambda* (#:key inputs #:allow-other-keys) |
287 | (substitute* "setup.py" |
288 | (("VEX_PATH = .*") |
289 | (string-append "VEX_PATH = '" (assoc-ref inputs "angr-vex") "'")) |
290 | ((".*self.execute\\(_build_vex.*") |
291 | "") |
292 | (("e\\['VEX_LIB_PATH'\\] = .*") |
293 | "e['VEX_LIB_PATH'] = os.path.join(VEX_PATH, 'lib')\n") |
294 | (("'pub'") |
295 | "'include'"))))))) |
296 | (home-page "https://github.com/angr/pyvex") |
297 | (synopsis "PyVEX exposes VEX into Python") |
298 | (description "VEX is an intermediate representation that is useful to carry |
299 | analyses on binary. PyVEX exposes VEX into Python.") |
300 | (license license:bsd-2))) |
301 | |
302 | (define-public unicorn |
303 | (package |
304 | (name "unicorn") |
305 | (version "1.0-rc3") |
306 | (source (origin |
307 | (method url-fetch) |
308 | (uri (string-append "https://github.com/unicorn-engine/unicorn/archive/" |
309 | version ".tar.gz")) |
310 | (file-name (string-append name "-" version ".tar.gz")) |
311 | (sha256 |
312 | (base32 |
313 | "18sf8vbmf08ss27qhiv7la492k39q0ci8kpjx836bv7rq3cbgb2q")))) |
314 | (build-system gnu-build-system) |
315 | (arguments |
316 | `(#:phases |
317 | (modify-phases %standard-phases |
318 | (delete 'configure)) |
319 | #:tests? #f |
320 | #:make-flags |
321 | (list "CC=gcc" |
322 | (string-append "PREFIX=" (assoc-ref %outputs "out"))))) |
323 | (native-inputs |
324 | `(("python" ,python-2) |
325 | ("pkg-config" ,pkg-config))) |
326 | (home-page "http://www.unicorn-engine.org/") |
327 | (synopsis "CPU emulator") |
328 | (description "Unicorn is a lightweight multi-platform, multi-architecture |
329 | CPU emulator framework.") |
330 | (license (list license:gpl2 license:lgpl2.0)))) |
331 | |
332 | ;; Not reproducible |
333 | (define-public python-unicorn |
334 | (package |
335 | (inherit unicorn) |
336 | (name "python-unicorn") |
337 | (propagated-inputs |
338 | `(("unicorn" ,unicorn))) |
339 | (build-system python-build-system) |
340 | (arguments |
341 | `(#:tests? #f |
342 | #:phases (modify-phases %standard-phases |
343 | (add-after 'unpack 'chdir-and-fix-setup-py |
344 | (lambda _ |
345 | (chdir "bindings/python") |
346 | (substitute* "setup.py" (("build_libraries\\(\\)\n") "\n")) |
347 | (substitute* "unicorn/unicorn.py" |
348 | (("'',") |
349 | (string-append "'" |
350 | (assoc-ref %build-inputs "unicorn") |
351 | "/lib',"))) |
352 | #t))))))) |
353 | |
354 | (define-public python2-unicorn |
355 | (package |
356 | (inherit (package-with-python2 python-unicorn)) |
357 | (propagated-inputs |
358 | `(("unicorn" ,unicorn) |
359 | ("pyvex" ,python2-pyvex))))) |
360 | |
361 | (define-public python2-simuvex |
362 | (package |
363 | (name "python2-simuvex") |
364 | (version "6.7.4.12") |
365 | (source (origin |
366 | (method url-fetch) |
367 | (uri (pypi-uri "simuvex" version)) |
368 | (sha256 |
369 | (base32 |
370 | "03rqdk7f1ynm6p50rbl4abq6hgnfvb7qd5k26m7cyxjii09waa2x")) |
371 | (modules '((guix build utils))) |
372 | (snippet |
373 | '(substitute* "setup.py" |
374 | (("dpkt-fix") "dpkt"))))) |
375 | (build-system python-build-system) |
376 | (native-inputs |
377 | `(("pkg-config" ,pkg-config) |
378 | ("enum34" ,python2-enum34))) |
379 | (propagated-inputs |
380 | `(("pyvex" ,python2-pyvex) |
381 | ("bintrees" ,python2-bintrees) |
382 | ("dpkt" ,python2-dpkt) |
383 | ("cooldict" ,python2-cooldict) |
384 | ("cachetools" ,python2-cachetools) |
385 | ("claripy" ,python2-claripy) |
386 | ("unicorn" ,python2-unicorn) |
387 | ("glib" ,glib))) |
388 | (inputs |
389 | `(("zlib" ,zlib))) |
390 | (arguments |
391 | `(#:python ,python-2)) |
392 | (home-page "https://github.com/angr/cle") |
393 | (synopsis "Abstraction of process memory") |
394 | (description "CLE loads binaries and their associated libraries, resolves |
395 | imports and provides an abstraction of process memory the same way as if it was |
396 | loaded by the OS's loader.") |
397 | (license license:bsd-2))) |
398 | |
399 | (define-public python2-cle |
400 | (package |
401 | (name "python2-cle") |
402 | (version "6.7.4.12") |
403 | (source (origin |
404 | (method url-fetch) |
405 | (uri (pypi-uri "cle" version)) |
406 | (sha256 |
407 | (base32 |
408 | "1fx21jx2nmc5lbz7hgpz4p7ccvzrnrcnf0wj2fbqdyjb9s0w2sfw")) |
409 | (modules '((guix build utils))) |
410 | (snippet |
411 | '(substitute* "setup.py" |
412 | ((", \"idalink\"") ""))))); Idalink is not acceptable |
413 | (build-system python-build-system) |
414 | (propagated-inputs |
415 | `(("pyelftools" ,python2-pyelftools) |
416 | ("cffi" ,python2-cffi) |
417 | ("archinfo" ,python2-archinfo) |
418 | ("future" ,python2-future) |
419 | ("pyvex" ,python2-pyvex) |
420 | ("pefile" ,python2-pefile))) |
421 | (arguments |
422 | `(#:python ,python-2)) |
423 | (home-page "https://github.com/angr/cle") |
424 | (synopsis "Abstraction of process memory") |
425 | (description "CLE loads binaries and their associated libraries, resolves |
426 | imports and provides an abstraction of process memory the same way as if it was |
427 | loaded by the OS's loader.") |
428 | (license license:bsd-2))) |
429 | |
430 | (define-public python2-angr |
431 | (package |
432 | (name "python2-angr") |
433 | (version "6.7.4.12") |
434 | (source (origin |
435 | (method url-fetch) |
436 | (uri (pypi-uri "angr" version)) |
437 | (sha256 |
438 | (base32 |
439 | "0cqqakh2drb593wcbdcq0vq3pcf1ckxwy486cg378667lrb4042i")))) |
440 | (build-system python-build-system) |
441 | (arguments |
442 | `(#:python ,python-2)) |
443 | (propagated-inputs |
444 | `(("cle" ,python2-cle) |
445 | ("capstone" ,python2-capstone) |
446 | ("six" ,python2-six) |
447 | ("utils" ,python2-utils) |
448 | ("mulpyplexer" ,python2-mulpyplexer) |
449 | ("rpyc" ,python2-rpyc) |
450 | ("enum34" ,python2-enum34) |
451 | ("networkx" ,python2-networkx) |
452 | ("futures" ,python2-futures) |
453 | ("progressbar" ,python2-progressbar2) |
454 | ("simuvex" ,python2-simuvex))) |
455 | (home-page "https://github.com/angr/angr") |
456 | (synopsis "Angr is a python framework for analyzing binaries") |
457 | (description "angr is a python framework for analyzing binaries. It |
458 | focuses on both static and dynamic symbolic (\"concolic\") analysis, making it |
459 | applicable to a variety of tasks.") |
460 | (license license:bsd-2))) |
461 | |
462 | (define-public radare2 |
463 | (package |
464 | (name "radare2") |
465 | (version "1.4.0") |
466 | (source (origin |
467 | (method url-fetch) |
468 | (uri (string-append "http://cloud.radare.org/get/" version "/" |
469 | name "-" version ".tar.gz")) |
470 | (sha256 |
471 | (base32 |
472 | "0gp9ngi2lcd76zgwzjii8bsgncw4449qnfsn6qwqv0nm9zcrlvmz")) |
473 | (modules '((guix build utils))) |
474 | (snippet |
475 | '(begin |
476 | (substitute* "libr/asm/p/Makefile" |
477 | (("LDFLAGS\\+=") "LDFLAGS+=-Wl,-rpath=$(LIBDIR) ")) |
478 | (substitute* "libr/parse/p/Makefile" |
479 | (("LDFLAGS\\+=") "LDFLAGS+=-Wl,-rpath=$(LIBDIR) ")) |
480 | (substitute* "libr/bin/p/Makefile" |
481 | (("LDFLAGS\\+=") "LDFLAGS+=-Wl,-rpath=$(LIBDIR) ")))))) |
482 | (build-system gnu-build-system) |
483 | (arguments |
484 | '(#:tests? #f |
485 | #:phases |
486 | (modify-phases %standard-phases |
487 | (add-before 'configure 'mklibdir |
488 | (lambda* (#:key inputs #:allow-other-keys) |
489 | (mkdir-p (string-append (assoc-ref %outputs "out") "/lib"))))) |
490 | #:configure-flags |
491 | (list "--with-sysmagic" "--with-syszip" "--with-openssl" |
492 | "--without-nonpic" "--with-rpath" "--with-syscapstone") |
493 | #:make-flags |
494 | (list "CC=gcc"))) |
495 | (inputs |
496 | `(("openssl" ,openssl) |
497 | ("zip" ,zip) |
498 | ("gmp" ,gmp) |
499 | ("capstone" ,capstone))) |
500 | (native-inputs |
501 | `(("pkg-config" ,pkg-config))) |
502 | (home-page "https://rada.re/") |
503 | (synopsis "Binary analysis tool") |
504 | (description |
505 | "Radare2 is a tool for reversing binaries.") |
506 | (license license:gpl3+))) |
507 |