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