guix-more/more/packages/binary.scm

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.4.12")
209
    (source (origin
210
              (method url-fetch)
211
              (uri (pypi-uri "archinfo" version))
212
              (sha256
213
               (base32
214
                "1kfc9nk73i5rr3xz8mv00cp76p7dc62h9pd8hvnda414jhx7n0pb"))))
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 "1")
229
    (source (origin
230
              (method git-fetch)
231
              (uri (git-reference
232
                    (url "https://github.com/angr/vex.git")
233
                    (commit "3a620e43ecc71cb9e5470995a45bbce4a600293f")))
234
              (sha256
235
               (base32
236
                "1qxpwi9961140dnys1iywm043nbm13qg2vw9xi1bjjdh80hbnfw4"))
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.4.12")
268
    (source (origin
269
              (method url-fetch)
270
              (uri (pypi-uri "pyvex" version))
271
              (sha256
272
               (base32
273
                "1x57aq96ka7gz6qcj9zqwdcylfks4q3iiykismyk1g0vp68qlwv9"))))
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-rc3")
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
                "18sf8vbmf08ss27qhiv7la492k39q0ci8kpjx836bv7rq3cbgb2q"))))
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
     `(#:tests? #f
341
       #:phases (modify-phases %standard-phases
342
                  (add-after 'unpack 'chdir-and-fix-setup-py
343
                    (lambda _
344
                      (chdir "bindings/python")
345
                      (substitute* "setup.py" (("build_libraries\\(\\)\n") "\n"))
346
                      (substitute* "unicorn/unicorn.py"
347
                        (("'',")
348
                         (string-append "'"
349
                                        (assoc-ref %build-inputs "unicorn")
350
                                        "/lib',")))
351
                      #t)))))))
352
353
(define-public python2-unicorn
354
  (package
355
    (inherit (package-with-python2 python-unicorn))
356
    (propagated-inputs
357
     `(("unicorn" ,unicorn)
358
       ("pyvex" ,python2-pyvex)))))
359
360
(define-public python2-simuvex
361
  (package
362
    (name "python2-simuvex")
363
    (version "6.7.4.12")
364
    (source (origin
365
              (method url-fetch)
366
              (uri (pypi-uri "simuvex" version))
367
              (sha256
368
               (base32
369
                "03rqdk7f1ynm6p50rbl4abq6hgnfvb7qd5k26m7cyxjii09waa2x"))
370
              (modules '((guix build utils)))
371
              (snippet
372
               '(substitute* "setup.py"
373
                  (("dpkt-fix") "dpkt")))))
374
    (build-system python-build-system)
375
    (native-inputs
376
     `(("pkg-config" ,pkg-config)
377
       ("enum34" ,python2-enum34)))
378
    (propagated-inputs
379
     `(("pyvex" ,python2-pyvex)
380
       ("bintrees" ,python2-bintrees)
381
       ("dpkt" ,python2-dpkt)
382
       ("cooldict" ,python2-cooldict)
383
       ("cachetools" ,python2-cachetools)
384
       ("claripy" ,python2-claripy)
385
       ("unicorn" ,python2-unicorn)
386
       ("glib" ,glib)))
387
    (inputs
388
     `(("zlib" ,zlib)))
389
    (arguments
390
     `(#:python ,python-2))
391
    (home-page "https://github.com/angr/cle")
392
    (synopsis "Abstraction of process memory")
393
    (description "CLE loads binaries and their associated libraries, resolves
394
imports and provides an abstraction of process memory the same way as if it was
395
loaded by the OS's loader.")
396
    (license license:bsd-2)))
397
398
(define-public python2-cle
399
  (package
400
    (name "python2-cle")
401
    (version "6.7.4.12")
402
    (source (origin
403
              (method url-fetch)
404
              (uri (pypi-uri "cle" version))
405
              (sha256
406
               (base32
407
                "1fx21jx2nmc5lbz7hgpz4p7ccvzrnrcnf0wj2fbqdyjb9s0w2sfw"))
408
              (modules '((guix build utils)))
409
              (snippet
410
               '(substitute* "setup.py"
411
                  ((", \"idalink\"") ""))))); Idalink is not acceptable
412
    (build-system python-build-system)
413
    (propagated-inputs
414
     `(("pyelftools" ,python2-pyelftools)
415
       ("cffi" ,python2-cffi)
416
       ("archinfo" ,python2-archinfo)
417
       ("future" ,python2-future)
418
       ("pyvex" ,python2-pyvex)
419
       ("pefile" ,python2-pefile)))
420
    (arguments
421
     `(#:python ,python-2))
422
    (home-page "https://github.com/angr/cle")
423
    (synopsis "Abstraction of process memory")
424
    (description "CLE loads binaries and their associated libraries, resolves
425
imports and provides an abstraction of process memory the same way as if it was
426
loaded by the OS's loader.")
427
    (license license:bsd-2)))
428
429
(define-public python2-angr
430
  (package
431
    (name "python2-angr")
432
    (version "6.7.4.12")
433
    (source (origin
434
              (method url-fetch)
435
              (uri (pypi-uri "angr" version))
436
              (sha256
437
               (base32
438
                "0cqqakh2drb593wcbdcq0vq3pcf1ckxwy486cg378667lrb4042i"))))
439
    (build-system python-build-system)
440
    (arguments
441
     `(#:python ,python-2))
442
    (propagated-inputs
443
     `(("cle" ,python2-cle)
444
       ("capstone" ,python2-capstone)
445
       ("six" ,python2-six)
446
       ("utils" ,python2-utils)
447
       ("mulpyplexer" ,python2-mulpyplexer)
448
       ("rpyc" ,python2-rpyc)
449
       ("enum34" ,python2-enum34)
450
       ("networkx" ,python2-networkx)
451
       ("futures" ,python2-futures)
452
       ("progressbar" ,python2-progressbar2)
453
       ("simuvex" ,python2-simuvex)))
454
    (home-page "https://github.com/angr/angr")
455
    (synopsis "Angr is a python framework for analyzing binaries")
456
    (description "angr is a python framework for analyzing binaries.  It
457
focuses on both static and dynamic symbolic (\"concolic\") analysis, making it
458
applicable to a variety of tasks.")
459
    (license license:bsd-2)))
460
461
(define-public radare2
462
  (package
463
    (name "radare2")
464
    (version "1.6.0")
465
    (source (origin
466
              (method url-fetch)
467
              (uri (string-append "http://radare.mikelloc.com/get/" version "/"
468
                                  name "-" version ".tar.gz"))
469
              (sha256
470
               (base32
471
                "16ggsk40zz6hyvclvqj1r4bh4hb78jf0d6ppry1jk4r0j30wm7cm"))
472
              (modules '((guix build utils)))
473
              (snippet
474
                '(begin
475
                  (substitute* "libr/asm/p/Makefile"
476
                    (("LDFLAGS\\+=") "LDFLAGS+=-Wl,-rpath=$(LIBDIR) "))
477
                  (substitute* "libr/parse/p/Makefile"
478
                    (("LDFLAGS\\+=") "LDFLAGS+=-Wl,-rpath=$(LIBDIR) "))
479
                  (substitute* "libr/bin/p/Makefile"
480
                    (("LDFLAGS\\+=") "LDFLAGS+=-Wl,-rpath=$(LIBDIR) "))))))
481
    (build-system gnu-build-system)
482
    (arguments
483
     '(#:tests? #f
484
       #:phases
485
       (modify-phases %standard-phases
486
         (add-before 'configure 'mklibdir
487
           (lambda* (#:key inputs #:allow-other-keys)
488
             (mkdir-p (string-append (assoc-ref %outputs "out") "/lib")))))
489
       #:configure-flags
490
       (list "--with-sysmagic" "--with-syszip" "--with-openssl"
491
             "--without-nonpic" "--with-rpath" "--with-syscapstone")
492
       #:make-flags
493
       (list "CC=gcc")))
494
    (inputs
495
     `(("openssl" ,openssl)
496
       ("zip" ,zip)
497
       ("gmp" ,gmp)
498
       ("capstone" ,capstone)))
499
    (native-inputs
500
     `(("pkg-config" ,pkg-config)))
501
    (home-page "https://rada.re/")
502
    (synopsis "Binary analysis tool")
503
    (description
504
      "Radare2 is a tool for reversing binaries.")
505
    (license license:gpl3+)))
506