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 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 "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.7.27")
210
    (source (origin
211
              (method url-fetch)
212
              (uri (pypi-uri "archinfo" version))
213
              (sha256
214
               (base32
215
                "1amcavk8x9xch18sfzbla5sgas955clj06g6hx20n47q87bw22vz"))))
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 "20170130")
230
    (source (origin
231
              (method git-fetch)
232
              (uri (git-reference
233
                    (url "https://github.com/angr/vex.git")
234
                    (commit "fc6a0b1187cd614e97e204046b4d4be482e7ab3f")))
235
              (sha256
236
               (base32
237
                "1qfv5j2hpvh5mv8mschrcd5sga4h910iggppr2g8jr6k9r3x725i"))
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.7.27")
269
    (source (origin
270
              (method url-fetch)
271
              (uri (pypi-uri "pyvex" version))
272
              (sha256
273
               (base32
274
                "1bqag7hb1ysrq9hb31cn8l7b8ad91rfw52bm3kh9gbma8rmxi0hl"))))
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.1")
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
                "0z01apwmvhvdldm372ww9pjfn45awkw3m90c0h4v0nj0ihmlysis"))))
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
     `(#: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.7.27")
364
    (source (origin
365
              (method url-fetch)
366
              (uri (pypi-uri "simuvex" version))
367
              (sha256
368
               (base32
369
                "1awc078861x7nj44g3x1p3mjdc3fhz85gqgx7rfk6918s6nbx848"))
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.7.27")
402
    (source (origin
403
              (method url-fetch)
404
              (uri (pypi-uri "cle" version))
405
              (sha256
406
               (base32
407
                "0x4cyl1qkhwj18860nhxdylzaxq45264jv4449cl0vl6y23lbk8v"))
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.7.27")
433
    (source (origin
434
              (method url-fetch)
435
              (uri (pypi-uri "angr" version))
436
              (sha256
437
               (base32
438
                "1k9vr9kds956jqyv126fc57ygly400jhhga98ms8clr4m3k3xlzn"))))
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 sandsifter
462
  (package
463
    (name "sandsifter")
464
    (version "0")
465
    (source (origin
466
              (method git-fetch)
467
              (uri (git-reference
468
                     (url "https://github.com/xoreaxeaxeax/sandsifter")
469
                     (commit "dff63246fed84d90118441b8ba5b5d3bdd094427")))
470
              (sha256
471
               (base32
472
                "1f4hfdhqmam8cz2hixv8zpwggqy17fmczsnc5k9gz87ff7bpqrnk"))))
473
    (build-system gnu-build-system)
474
    (arguments
475
     `(#:make-flags (list "CC=gcc")
476
       #:tests? #f
477
       #:phases
478
       (modify-phases %standard-phases
479
         (delete 'configure)
480
         (replace 'install
481
           (lambda* (#:key inputs outputs #:allow-other-keys)
482
             (let* ((out (assoc-ref outputs "out"))
483
                    (bin (string-append out "/bin"))
484
                    (lib (string-append out "/lib/python2.7/site-packages/sandsifter"))
485
                    (pyutil (string-append lib "/pyutil"))
486
                    (gui (string-append lib "/gui")))
487
               ;(substitute* "summarize.py"
488
               ;  (("pyutil.progress") "sandsifter.pyutil.progress")
489
               ;  (("gui.gui") "sandsifter.gui.gui"))
490
               (substitute* "sifter.py"
491
                 (("./injector") (string-append lib "/injector")))
492
               (mkdir-p bin)
493
               (with-output-to-file (string-append bin "/sifter")
494
                 (lambda _
495
                   (format #t
496
                     "#!~a~@
497
                     PYTHONPATH=~a ~a/bin/python ~a/sifter.py $@"
498
                     (which "sh")
499
                     (string-append (assoc-ref inputs "py-capstone")
500
                                    "/lib/python2.7/site-packages:"
501
                                    (dirname lib))
502
                     (assoc-ref inputs "python2") lib)))
503
               (chmod (string-append bin "/sifter") #o755)
504
               (with-output-to-file (string-append bin "/sifter-summarize")
505
                 (lambda _
506
                   (format #t
507
                     "#!~a~@
508
                     PYTHONPATH=~a ~a/bin/python ~a/summarize.py $@"
509
                     (which "sh")
510
                     (string-append (assoc-ref inputs "py-capstone")
511
                                    "/lib/python2.7/site-packages:"
512
                                    lib)
513
                     (assoc-ref inputs "python2") lib)))
514
               (chmod (string-append bin "/sifter-summarize") #o755)
515
               (install-file "sifter.py" lib)
516
               (install-file "summarize.py" lib)
517
               (install-file "injector" lib)
518
               (install-file "pyutil/__init__.py" pyutil)
519
               (install-file "pyutil/colors.py" pyutil)
520
               (install-file "pyutil/progress.py" pyutil)
521
               (install-file "gui/__init__.py" gui)
522
               (install-file "gui/gui.py" gui)))))))
523
    (inputs
524
     `(("capstone" ,capstone)
525
       ("python2" ,python-2)
526
       ("py-capstone" ,python2-capstone)))
527
    (home-page "https://github.com/xoreaxeaxeax/sandsifter")
528
    (synopsis "X86 processor fuzzer")
529
    (description "The sandsifter audits x86 processors for hidden instructions
530
and hardware bugs, by systematically generating machine code to search through
531
a processor's instruction set, and monitoring execution for anomalies.
532
Sandsifter has uncovered secret processor instructions from every major vendor;
533
ubiquitous software bugs in disassemblers, assemblers, and emulators; flaws in
534
enterprise hypervisors; and both benign and security-critical hardware bugs in
535
x86 chips.")
536
    ;; No license!
537
    (license license:expat)))
538