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 libffi) |
31 | #:use-module (gnu packages multiprecision) |
32 | #:use-module (gnu packages pkg-config) |
33 | #:use-module (gnu packages python) |
34 | #:use-module (gnu packages tls) |
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 "2017.11.5") |
182 | (source |
183 | (origin |
184 | (method url-fetch) |
185 | (uri (pypi-uri "pefile" version)) |
186 | (sha256 |
187 | (base32 |
188 | "0m2q0bdjdlf6lbidb33y43k3ikzjgy58vx6jh2gdnxqn1vp3ap37")))) |
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 "7.7.12.16") |
210 | (source (origin |
211 | (method url-fetch) |
212 | (uri (pypi-uri "archinfo" version)) |
213 | (sha256 |
214 | (base32 |
215 | "0xlgq1qnsrqywv43ij54k6ciyxmwf0krygsqdq13x3a6gd02a85l")))) |
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 "0.20180104") |
230 | (source (origin |
231 | (method git-fetch) |
232 | (uri (git-reference |
233 | (url "https://github.com/angr/vex.git") |
234 | (commit "7394e917fc86c8f042d8ce51a609810a97c20fd7"))) |
235 | (sha256 |
236 | (base32 |
237 | "1fw97l9wqirny0p2x0d1xr475b05s4zbq0hd0sip7q7f15claiy0")) |
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 "7.7.12.16") |
269 | (source (origin |
270 | (method url-fetch) |
271 | (uri (pypi-uri "pyvex" version)) |
272 | (sha256 |
273 | (base32 |
274 | "1jn4ivs75vs2x7fsmbyy0pbcspjff0h1vlw463kz9qf9ppr7fshc")))) |
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 | (native-inputs |
282 | `(("python2-bitstring" ,python2-bitstring))) |
283 | (arguments |
284 | `(#:python ,python-2 |
285 | #:phases |
286 | (modify-phases %standard-phases |
287 | (add-before 'build 'fix-setup.py |
288 | (lambda* (#:key inputs #:allow-other-keys) |
289 | (substitute* "setup.py" |
290 | (("VEX_PATH = .*") |
291 | (string-append "VEX_PATH = '" (assoc-ref inputs "angr-vex") "'")) |
292 | ((".*self.execute\\(_build_vex.*") |
293 | "") |
294 | (("e\\['VEX_LIB_PATH'\\] = .*") |
295 | "e['VEX_LIB_PATH'] = os.path.join(VEX_PATH, 'lib')\n") |
296 | (("'pub'") |
297 | "'include'"))))))) |
298 | (home-page "https://github.com/angr/pyvex") |
299 | (synopsis "PyVEX exposes VEX into Python") |
300 | (description "VEX is an intermediate representation that is useful to carry |
301 | analyses on binary. PyVEX exposes VEX into Python.") |
302 | (license license:bsd-2))) |
303 | |
304 | (define-public unicorn |
305 | (package |
306 | (name "unicorn") |
307 | (version "1.0.1") |
308 | (source (origin |
309 | (method url-fetch) |
310 | (uri (string-append "https://github.com/unicorn-engine/unicorn/archive/" |
311 | version ".tar.gz")) |
312 | (file-name (string-append name "-" version ".tar.gz")) |
313 | (sha256 |
314 | (base32 |
315 | "0z01apwmvhvdldm372ww9pjfn45awkw3m90c0h4v0nj0ihmlysis")))) |
316 | (build-system gnu-build-system) |
317 | (arguments |
318 | `(#:phases |
319 | (modify-phases %standard-phases |
320 | (delete 'configure)) |
321 | #:tests? #f |
322 | #:make-flags |
323 | (list "CC=gcc" |
324 | (string-append "PREFIX=" (assoc-ref %outputs "out"))))) |
325 | (native-inputs |
326 | `(("python" ,python-2) |
327 | ("pkg-config" ,pkg-config))) |
328 | (home-page "http://www.unicorn-engine.org/") |
329 | (synopsis "CPU emulator") |
330 | (description "Unicorn is a lightweight multi-platform, multi-architecture |
331 | CPU emulator framework.") |
332 | (license (list license:gpl2 license:lgpl2.0)))) |
333 | |
334 | ;; Not reproducible |
335 | (define-public python-unicorn |
336 | (package |
337 | (inherit unicorn) |
338 | (name "python-unicorn") |
339 | (propagated-inputs |
340 | `(("unicorn" ,unicorn))) |
341 | (build-system python-build-system) |
342 | (arguments |
343 | `(#:phases (modify-phases %standard-phases |
344 | (add-after 'unpack 'chdir-and-fix-setup-py |
345 | (lambda _ |
346 | (chdir "bindings/python") |
347 | (substitute* "setup.py" (("build_libraries\\(\\)\n") "\n")) |
348 | (substitute* "unicorn/unicorn.py" |
349 | (("'',") |
350 | (string-append "'" |
351 | (assoc-ref %build-inputs "unicorn") |
352 | "/lib',"))) |
353 | #t))))))) |
354 | |
355 | (define-public python2-unicorn |
356 | (package |
357 | (inherit (package-with-python2 python-unicorn)) |
358 | (propagated-inputs |
359 | `(("unicorn" ,unicorn) |
360 | ("pyvex" ,python2-pyvex))))) |
361 | |
362 | (define-public python2-simuvex |
363 | (package |
364 | (name "python2-simuvex") |
365 | (version "7.7.9.8") |
366 | (source (origin |
367 | (method url-fetch) |
368 | (uri (pypi-uri "simuvex" version)) |
369 | (sha256 |
370 | (base32 |
371 | "02485bb8cl3q2yrd42mgd6nnbx915y8xqz7fmb03wkj7alzm58pr")) |
372 | (modules '((guix build utils))) |
373 | (snippet |
374 | '(substitute* "setup.py" |
375 | (("dpkt-fix") "dpkt"))))) |
376 | (build-system python-build-system) |
377 | (native-inputs |
378 | `(("pkg-config" ,pkg-config) |
379 | ("enum34" ,python2-enum34))) |
380 | (propagated-inputs |
381 | `(("pyvex" ,python2-pyvex) |
382 | ("bintrees" ,python2-bintrees) |
383 | ("dpkt" ,python2-dpkt) |
384 | ("cooldict" ,python2-cooldict) |
385 | ("cachetools" ,python2-cachetools) |
386 | ("claripy" ,python2-claripy) |
387 | ("unicorn" ,python2-unicorn) |
388 | ("glib" ,glib))) |
389 | (inputs |
390 | `(("zlib" ,zlib))) |
391 | (arguments |
392 | `(#:python ,python-2 |
393 | ;; Simuvex requires angr to be tested |
394 | #:tests? #f)) |
395 | (home-page "https://github.com/angr/cle") |
396 | (synopsis "Abstraction of process memory") |
397 | (description "CLE loads binaries and their associated libraries, resolves |
398 | imports and provides an abstraction of process memory the same way as if it was |
399 | loaded by the OS's loader.") |
400 | (license license:bsd-2))) |
401 | |
402 | (define-public python2-cle |
403 | (package |
404 | (name "python2-cle") |
405 | (version "7.7.12.16") |
406 | (source (origin |
407 | (method url-fetch) |
408 | (uri (pypi-uri "cle" version)) |
409 | (sha256 |
410 | (base32 |
411 | "04q15iflmapvm47vx4wblvmnj4hzg69hn2zd6h5wzkccgnkchb25")) |
412 | (modules '((guix build utils))) |
413 | (snippet |
414 | '(substitute* "setup.py" |
415 | (("'idalink',") ""))))); Idalink is not acceptable |
416 | (build-system python-build-system) |
417 | (propagated-inputs |
418 | `(("pyelftools" ,python2-pyelftools) |
419 | ("cffi" ,python2-cffi) |
420 | ("archinfo" ,python2-archinfo) |
421 | ("future" ,python2-future) |
422 | ("pyvex" ,python2-pyvex) |
423 | ("pefile" ,python2-pefile))) |
424 | (native-inputs |
425 | `(("python2-bitstring" ,python2-bitstring))) |
426 | (arguments |
427 | `(#:python ,python-2)) |
428 | (home-page "https://github.com/angr/cle") |
429 | (synopsis "Abstraction of process memory") |
430 | (description "CLE loads binaries and their associated libraries, resolves |
431 | imports and provides an abstraction of process memory the same way as if it was |
432 | loaded by the OS's loader.") |
433 | (license license:bsd-2))) |
434 | |
435 | (define-public python2-angr |
436 | (package |
437 | (name "python2-angr") |
438 | (version "7.7.12.16") |
439 | (source (origin |
440 | (method url-fetch) |
441 | (uri (pypi-uri "angr" version)) |
442 | (sha256 |
443 | (base32 |
444 | "177z45ki580dphmrpsv2ln1249n8jcjf7mjl8ymjcki5yzan26yy")))) |
445 | (build-system python-build-system) |
446 | (arguments |
447 | `(#:python ,python-2 |
448 | ;; Tests require pygit 0.1 |
449 | #:tests? #f)) |
450 | (propagated-inputs |
451 | `(("python2-bitstring" ,python2-bitstring) |
452 | ("python2-cle" ,python2-cle) |
453 | ("python2-capstone" ,python2-capstone) |
454 | ("python2-six" ,python2-six) |
455 | ("python2-utils" ,python2-utils) |
456 | ("python2-mulpyplexer" ,python2-mulpyplexer) |
457 | ("python2-rpyc" ,python2-rpyc) |
458 | ("python2-enum34" ,python2-enum34) |
459 | ("python2-networkx" ,python2-networkx) |
460 | ("python2-futures" ,python2-futures) |
461 | ("python2-progressbar" ,python2-progressbar2) |
462 | ("python2-simuvex" ,python2-simuvex))) |
463 | (home-page "https://github.com/angr/angr") |
464 | (synopsis "Angr is a python framework for analyzing binaries") |
465 | (description "angr is a python framework for analyzing binaries. It |
466 | focuses on both static and dynamic symbolic (\"concolic\") analysis, making it |
467 | applicable to a variety of tasks.") |
468 | (license license:bsd-2))) |
469 | |
470 | (define-public sandsifter |
471 | (package |
472 | (name "sandsifter") |
473 | (version "0") |
474 | (source (origin |
475 | (method git-fetch) |
476 | (uri (git-reference |
477 | (url "https://github.com/xoreaxeaxeax/sandsifter") |
478 | (commit "dff63246fed84d90118441b8ba5b5d3bdd094427"))) |
479 | (sha256 |
480 | (base32 |
481 | "1f4hfdhqmam8cz2hixv8zpwggqy17fmczsnc5k9gz87ff7bpqrnk")))) |
482 | (build-system gnu-build-system) |
483 | (arguments |
484 | `(#:make-flags (list "CC=gcc") |
485 | #:tests? #f |
486 | #:phases |
487 | (modify-phases %standard-phases |
488 | (delete 'configure) |
489 | (replace 'install |
490 | (lambda* (#:key inputs outputs #:allow-other-keys) |
491 | (let* ((out (assoc-ref outputs "out")) |
492 | (bin (string-append out "/bin")) |
493 | (lib (string-append out "/lib/python2.7/site-packages/sandsifter")) |
494 | (pyutil (string-append lib "/pyutil")) |
495 | (gui (string-append lib "/gui"))) |
496 | ;(substitute* "summarize.py" |
497 | ; (("pyutil.progress") "sandsifter.pyutil.progress") |
498 | ; (("gui.gui") "sandsifter.gui.gui")) |
499 | (substitute* "sifter.py" |
500 | (("./injector") (string-append lib "/injector"))) |
501 | (mkdir-p bin) |
502 | (with-output-to-file (string-append bin "/sifter") |
503 | (lambda _ |
504 | (format #t |
505 | "#!~a~@ |
506 | PYTHONPATH=~a ~a/bin/python ~a/sifter.py $@" |
507 | (which "sh") |
508 | (string-append (assoc-ref inputs "py-capstone") |
509 | "/lib/python2.7/site-packages:" |
510 | (dirname lib)) |
511 | (assoc-ref inputs "python2") lib))) |
512 | (chmod (string-append bin "/sifter") #o755) |
513 | (with-output-to-file (string-append bin "/sifter-summarize") |
514 | (lambda _ |
515 | (format #t |
516 | "#!~a~@ |
517 | PYTHONPATH=~a ~a/bin/python ~a/summarize.py $@" |
518 | (which "sh") |
519 | (string-append (assoc-ref inputs "py-capstone") |
520 | "/lib/python2.7/site-packages:" |
521 | lib) |
522 | (assoc-ref inputs "python2") lib))) |
523 | (chmod (string-append bin "/sifter-summarize") #o755) |
524 | (install-file "sifter.py" lib) |
525 | (install-file "summarize.py" lib) |
526 | (install-file "injector" lib) |
527 | (install-file "pyutil/__init__.py" pyutil) |
528 | (install-file "pyutil/colors.py" pyutil) |
529 | (install-file "pyutil/progress.py" pyutil) |
530 | (install-file "gui/__init__.py" gui) |
531 | (install-file "gui/gui.py" gui))))))) |
532 | (inputs |
533 | `(("capstone" ,capstone) |
534 | ("python2" ,python-2) |
535 | ("py-capstone" ,python2-capstone))) |
536 | (home-page "https://github.com/xoreaxeaxeax/sandsifter") |
537 | (synopsis "X86 processor fuzzer") |
538 | (description "The sandsifter audits x86 processors for hidden instructions |
539 | and hardware bugs, by systematically generating machine code to search through |
540 | a processor's instruction set, and monitoring execution for anomalies. |
541 | Sandsifter has uncovered secret processor instructions from every major vendor; |
542 | ubiquitous software bugs in disassemblers, assemblers, and emulators; flaws in |
543 | enterprise hypervisors; and both benign and security-critical hardware bugs in |
544 | x86 chips.") |
545 | ;; No license! |
546 | (license license:expat))) |
547 |