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 cmake)
27
  #:use-module (guix build-system gnu)
28
  #:use-module (guix build-system python)
29
  #:use-module (gnu packages check)
30
  #:use-module (gnu packages compression)
31
  #:use-module (gnu packages glib)
32
  #:use-module (gnu packages libffi)
33
  #:use-module (gnu packages multiprecision)
34
  #:use-module (gnu packages pkg-config)
35
  #:use-module (gnu packages python)
36
  #:use-module (gnu packages python-crypto)
37
  #:use-module (gnu packages qt)
38
  #:use-module (gnu packages tls)
39
  #:use-module (more packages python)
40
  #:use-module (more packages smt))
41
42
(define-public python-pyelftools
43
  (package
44
    (name "python-pyelftools")
45
    (version "0.24")
46
    (source (origin
47
              (method url-fetch)
48
              (uri (string-append "https://github.com/eliben/pyelftools/archive/v"
49
                                  version ".tar.gz"))
50
              (file-name (string-append name "-" version ".tar.gz"))
51
              (sha256
52
               (base32
53
                "1iw47b20brg0ah86s9a2dn1f70qfmdv20p04q131vmnwa9g066f4"))))
54
    (build-system python-build-system)
55
    (native-inputs
56
     `(("utils" ,python-utils)))
57
    (arguments
58
     `(#:tests? #f))
59
    (home-page "https://github.com/eliben/pyelftools")
60
    (synopsis "Parsing and analyzing ELF files and DWARF debugging information")
61
    (description
62
      "Python library for parsing and analyzing ELF files and DWARF debugging information.")
63
    (license license:public-domain)))
64
65
(define-public python2-pyelftools
66
  (package
67
    (inherit (package-with-python2 python-pyelftools))
68
    (arguments
69
     `(#:tests? #t
70
       #:python ,python-2))))
71
    
72
;; rc required by python2-angr
73
(define-public capstone
74
  (package
75
    (name "capstone")
76
    (version "3.0.5-rc2")
77
    (source (origin
78
              (method url-fetch)
79
              (uri (string-append "https://github.com/aquynh/capstone/archive/"
80
                                  version ".tar.gz"))
81
              (file-name (string-append name "-" version ".tar.gz"))
82
              (sha256
83
               (base32
84
                "1cqms9r2p43aiwp5spd84zaccp16ih03r7sjhrv16nddahj0jz2q"))))
85
    (build-system gnu-build-system)
86
    (arguments
87
     `(#:tests? #f
88
       #:make-flags (list (string-append "PREFIX=" %output)
89
                          "CC=gcc")
90
       #:phases
91
       (modify-phases %standard-phases
92
         (delete 'configure)
93
         (add-before 'build 'fix-cstool-ldflags
94
           (lambda* (#:key outputs #:allow-other-keys)
95
             (substitute* "cstool/Makefile"
96
               (("LDFLAGS =")
97
                (string-append "LDFLAGS = -Wl,-rpath=" (assoc-ref outputs "out")
98
                               "/lib"))))))))
99
    (home-page "http://www.capstone-engine.org")
100
    (synopsis "Disassembler")
101
    (description
102
     "Capstone can disassemble machine code for many supported architectures
103
such as x86, x86_64, arm, arm64, mips, ppc, sparc, sysz and xcore.  It provides
104
bindings for Python, Java, OCaml and more.")
105
    (license (list license:bsd-3 license:expat))))
106
107
;; This package has a timestamp embedded in
108
;; lib/python3.5/site-packages/capstone/__pycache__/__iti__.cpython-35.pyc
109
(define-public python-capstone
110
  (package
111
    (inherit capstone)
112
    (name "python-capstone")
113
    (propagated-inputs
114
     `(("capstone" ,capstone)))
115
    (build-system python-build-system)
116
    (arguments
117
     `(#:tests? #f
118
       #:phases
119
       (modify-phases %standard-phases
120
         (add-after 'unpack 'chdir-and-fix-setup-py
121
           (lambda _
122
             (chdir "bindings/python")
123
             (substitute* "setup.py" ((".*   build_libraries.*") ""))
124
             (substitute* "capstone/__init__.py"
125
               (("pkg_resources.resource_filename.*")
126
                (string-append "'" (assoc-ref %build-inputs "capstone") "/lib',\n")))
127
             #t)))))))
128
129
(define-public python2-capstone
130
  (package-with-python2 python-capstone))
131
132
(define-public capstone-git
133
  (package
134
    (inherit capstone)
135
    (version "3.0.5-rc2")
136
    (name "capstone-git")
137
    (source (origin
138
              (method git-fetch)
139
              (uri (git-reference (url "https://github.com/aquynh/capstone.git")
140
                                  (commit "b6c4c3f5c79684b02d0672b50b4db494f6ce60f9")))
141
              (file-name (string-append name "-" version))
142
              (sha256
143
               (base32
144
                "0kqdfp0flx5czzwr490pzn9mzsxcw8qpcfz4y7bpf2cklsr4mh25"))))
145
    (arguments
146
     `(#:tests? #f
147
       #:make-flags (list (string-append "PREFIX=" (assoc-ref %outputs "out"))
148
                          "CC=gcc")
149
       #:phases
150
       (modify-phases %standard-phases
151
         (delete 'configure)
152
         (add-before 'build 'fix-cstool
153
           (lambda* (#:key outputs #:allow-other-keys)
154
             (substitute* "cstool/Makefile"
155
               (("LDFLAGS =")
156
                (string-append "LDFLAGS = -Wl,-rpath=" (assoc-ref outputs "out") "/lib"))))))))))
157
158
(define-public python-capstone-git
159
  (package
160
    (inherit capstone-git)
161
    (name "python-capstone-git")
162
    (propagated-inputs
163
     `(("capstone" ,capstone-git)))
164
    (build-system python-build-system)
165
    (arguments
166
     `(#:tests? #f
167
       #:phases
168
       (modify-phases %standard-phases
169
         (add-after 'unpack 'chdir-and-fix-setup-py
170
           (lambda _
171
             (chdir "bindings/python")
172
             (substitute* "setup.py" (("   *build_libraries.*") "\n"))
173
             (substitute* "capstone/__init__.py"
174
               (("pkg_resources.resource_filename.*")
175
                (string-append "\"" (assoc-ref %build-inputs "capstone") "/lib\",\n")))
176
             #t)))))))
177
178
(define-public python2-capstone-git
179
  (package-with-python2 python-capstone-git))
180
181
 
182
(define-public python-pefile
183
  (package
184
    (name "python-pefile")
185
    (version "2017.11.5")
186
    (source
187
      (origin
188
        (method url-fetch)
189
        (uri (pypi-uri "pefile" version))
190
        (sha256
191
         (base32
192
          "0m2q0bdjdlf6lbidb33y43k3ikzjgy58vx6jh2gdnxqn1vp3ap37"))))
193
    (build-system python-build-system)
194
    (arguments
195
     `(#:tests? #f)); no test
196
    (home-page "https://github.com/erocarrera/pefile")
197
    (synopsis "Parse and work with Portable Executable (aka PE) files")
198
    (description "Pefile is a multi-platform Python module to parse and work
199
with Portable Executable (aka PE) files.  Most of the information contained in
200
the PE headers is accessible as well as all sections' details and their data.
201
The structures defined in the Windows header files will be accessible as
202
attributes in the PE instance.  The naming of fields/attributes will try to
203
adhere to the naming scheme in those headers.  Only shortcuts added for
204
convenience will depart from that convention.")
205
    (license license:expat)))
206
207
(define-public python2-pefile
208
  (package-with-python2 python-pefile))
209
210
(define-public python2-archinfo
211
  (package
212
    (name "python2-archinfo")
213
    (version "7.7.12.16")
214
    (source (origin
215
              (method url-fetch)
216
              (uri (pypi-uri "archinfo" version))
217
              (sha256
218
               (base32
219
                "0xlgq1qnsrqywv43ij54k6ciyxmwf0krygsqdq13x3a6gd02a85l"))))
220
    (build-system python-build-system)
221
    (arguments
222
     `(#:python ,python-2))
223
    (home-page "https://github.com/angr/archinfo")
224
    (synopsis "Collection of classes that contain architecture-specific information")
225
    (description "Archinfo is a collection of classes that contain
226
architecture-specific information.  It is useful for cross-architecture tools
227
(such as pyvex).")
228
    (license license:bsd-2)))
229
230
(define-public angr-vex
231
  (package
232
    (name "angr-vex")
233
    (version "0.20180104")
234
    (source (origin
235
              (method git-fetch)
236
              (uri (git-reference
237
                    (url "https://github.com/angr/vex.git")
238
                    (commit "7394e917fc86c8f042d8ce51a609810a97c20fd7")))
239
              (sha256
240
               (base32
241
                "1fw97l9wqirny0p2x0d1xr475b05s4zbq0hd0sip7q7f15claiy0"))
242
              (file-name (string-append name "-" version))))
243
    (build-system gnu-build-system)
244
    (arguments
245
     `(#:make-flags
246
       (list "CC=gcc" "CC_NATIVE=gcc")
247
       #:tests? #f
248
       #:phases
249
       (modify-phases %standard-phases
250
         (delete 'configure)
251
         (add-before 'build 'get-Makefile
252
           (lambda _
253
             (copy-file "Makefile-gcc" "Makefile")))
254
         (replace 'install
255
           (lambda* (#:key outputs #:allow-other-keys)
256
             (let* ((out (assoc-ref outputs "out"))
257
                   (lib (string-append out "/lib"))
258
                   (include (string-append out "/include")))
259
               (mkdir-p lib)
260
               (mkdir-p include)
261
               (copy-recursively "pub" include)
262
               (copy-file "libvex.a" (string-append lib "/libvex.a"))))))))
263
    (home-page "https://github.com/angr/vex")
264
    (synopsis "Fork of libVEX for PyVEX")
265
    (description "This is a mirror of libVEX (of the Valgrind project:
266
valgrind.org) for use with PyVEX.")
267
    (license license:gpl2+)))
268
269
(define-public python2-pyvex
270
  (package
271
    (name "python2-pyvex")
272
    (version "7.7.12.16")
273
    (source (origin
274
              (method url-fetch)
275
              (uri (pypi-uri "pyvex" version))
276
              (sha256
277
               (base32
278
                "1jn4ivs75vs2x7fsmbyy0pbcspjff0h1vlw463kz9qf9ppr7fshc"))))
279
    (build-system python-build-system)
280
    (inputs `(("angr-vex" ,angr-vex)))
281
    (propagated-inputs
282
     `(("archinfo" ,python2-archinfo)
283
       ("pycparser" ,python2-pycparser)
284
       ("cffi" ,python2-cffi)))
285
    (native-inputs
286
     `(("python2-bitstring" ,python2-bitstring)))
287
    (arguments
288
     `(#:python ,python-2
289
       #:phases
290
       (modify-phases %standard-phases
291
         (add-before 'build 'fix-setup.py
292
           (lambda* (#:key inputs #:allow-other-keys)
293
             (substitute* "setup.py"
294
               (("VEX_PATH = .*")
295
                (string-append "VEX_PATH = '" (assoc-ref inputs "angr-vex") "'"))
296
               ((".*self.execute\\(_build_vex.*")
297
                "")
298
               (("e\\['VEX_LIB_PATH'\\] = .*")
299
                "e['VEX_LIB_PATH'] = os.path.join(VEX_PATH, 'lib')\n")
300
               (("'pub'")
301
                "'include'")))))))
302
    (home-page "https://github.com/angr/pyvex")
303
    (synopsis "PyVEX exposes VEX into Python")
304
    (description "VEX is an intermediate representation that is useful to carry
305
analyses on binary.  PyVEX exposes VEX into Python.")
306
    (license license:bsd-2)))
307
308
(define-public unicorn
309
  (package
310
    (name "unicorn")
311
    (version "1.0.1")
312
    (source (origin
313
              (method url-fetch)
314
              (uri (string-append "https://github.com/unicorn-engine/unicorn/archive/"
315
                                  version ".tar.gz"))
316
              (file-name (string-append name "-" version ".tar.gz"))
317
              (sha256
318
               (base32
319
                "0z01apwmvhvdldm372ww9pjfn45awkw3m90c0h4v0nj0ihmlysis"))))
320
    (build-system gnu-build-system)
321
    (arguments
322
     `(#:phases
323
       (modify-phases %standard-phases
324
         (delete 'configure))
325
       #:tests? #f
326
       #:make-flags
327
       (list "CC=gcc"
328
             (string-append "PREFIX=" (assoc-ref %outputs "out")))))
329
    (native-inputs
330
     `(("python" ,python-2)
331
       ("pkg-config" ,pkg-config)))
332
    (home-page "http://www.unicorn-engine.org/")
333
    (synopsis "CPU emulator")
334
    (description "Unicorn is a lightweight multi-platform, multi-architecture
335
CPU emulator framework.")
336
    (license (list license:gpl2 license:lgpl2.0))))
337
338
;; Not reproducible
339
(define-public python-unicorn
340
  (package
341
    (inherit unicorn)
342
    (name "python-unicorn")
343
    (propagated-inputs
344
     `(("unicorn" ,unicorn)))
345
    (build-system python-build-system)
346
    (arguments
347
     `(#:phases (modify-phases %standard-phases
348
                  (add-after 'unpack 'chdir-and-fix-setup-py
349
                    (lambda _
350
                      (chdir "bindings/python")
351
                      (substitute* "setup.py" (("build_libraries\\(\\)\n") "\n"))
352
                      (substitute* "unicorn/unicorn.py"
353
                        (("'',")
354
                         (string-append "'"
355
                                        (assoc-ref %build-inputs "unicorn")
356
                                        "/lib',")))
357
                      #t)))))))
358
359
(define-public python2-unicorn
360
  (package
361
    (inherit (package-with-python2 python-unicorn))
362
    (propagated-inputs
363
     `(("unicorn" ,unicorn)
364
       ("pyvex" ,python2-pyvex)))))
365
366
(define-public python2-simuvex
367
  (package
368
    (name "python2-simuvex")
369
    (version "7.7.9.8")
370
    (source (origin
371
              (method url-fetch)
372
              (uri (pypi-uri "simuvex" version))
373
              (sha256
374
               (base32
375
                "02485bb8cl3q2yrd42mgd6nnbx915y8xqz7fmb03wkj7alzm58pr"))
376
              (modules '((guix build utils)))
377
              (snippet
378
               '(substitute* "setup.py"
379
                  (("dpkt-fix") "dpkt")))))
380
    (build-system python-build-system)
381
    (native-inputs
382
     `(("pkg-config" ,pkg-config)
383
       ("enum34" ,python2-enum34)))
384
    (propagated-inputs
385
     `(("pyvex" ,python2-pyvex)
386
       ("bintrees" ,python2-bintrees)
387
       ("dpkt" ,python2-dpkt)
388
       ("cooldict" ,python2-cooldict)
389
       ("cachetools" ,python2-cachetools)
390
       ("claripy" ,python2-claripy)
391
       ("unicorn" ,python2-unicorn)
392
       ("glib" ,glib)))
393
    (inputs
394
     `(("zlib" ,zlib)))
395
    (arguments
396
     `(#:python ,python-2
397
       ;; Simuvex requires angr to be tested
398
       #:tests? #f))
399
    (home-page "https://github.com/angr/cle")
400
    (synopsis "Abstraction of process memory")
401
    (description "CLE loads binaries and their associated libraries, resolves
402
imports and provides an abstraction of process memory the same way as if it was
403
loaded by the OS's loader.")
404
    (license license:bsd-2)))
405
406
(define-public python2-cle
407
  (package
408
    (name "python2-cle")
409
    (version "7.7.12.16")
410
    (source (origin
411
              (method url-fetch)
412
              (uri (pypi-uri "cle" version))
413
              (sha256
414
               (base32
415
                "04q15iflmapvm47vx4wblvmnj4hzg69hn2zd6h5wzkccgnkchb25"))
416
              (modules '((guix build utils)))
417
              (snippet
418
               '(substitute* "setup.py"
419
                  (("'idalink',") ""))))); Idalink is not acceptable
420
    (build-system python-build-system)
421
    (propagated-inputs
422
     `(("pyelftools" ,python2-pyelftools)
423
       ("cffi" ,python2-cffi)
424
       ("archinfo" ,python2-archinfo)
425
       ("future" ,python2-future)
426
       ("pyvex" ,python2-pyvex)
427
       ("pefile" ,python2-pefile)))
428
    (native-inputs
429
     `(("python2-bitstring" ,python2-bitstring)))
430
    (arguments
431
     `(#:python ,python-2))
432
    (home-page "https://github.com/angr/cle")
433
    (synopsis "Abstraction of process memory")
434
    (description "CLE loads binaries and their associated libraries, resolves
435
imports and provides an abstraction of process memory the same way as if it was
436
loaded by the OS's loader.")
437
    (license license:bsd-2)))
438
439
(define-public python2-angr
440
  (package
441
    (name "python2-angr")
442
    (version "7.7.12.16")
443
    (source (origin
444
              (method url-fetch)
445
              (uri (pypi-uri "angr" version))
446
              (sha256
447
               (base32
448
                "177z45ki580dphmrpsv2ln1249n8jcjf7mjl8ymjcki5yzan26yy"))))
449
    (build-system python-build-system)
450
    (arguments
451
     `(#:python ,python-2
452
       ;; Tests require pygit 0.1
453
       #:tests? #f))
454
    (propagated-inputs
455
     `(("python2-bitstring" ,python2-bitstring)
456
       ("python2-cle" ,python2-cle)
457
       ("python2-capstone" ,python2-capstone)
458
       ("python2-six" ,python2-six)
459
       ("python2-utils" ,python2-utils)
460
       ("python2-mulpyplexer" ,python2-mulpyplexer)
461
       ("python2-rpyc" ,python2-rpyc)
462
       ("python2-enum34" ,python2-enum34)
463
       ("python2-networkx" ,python2-networkx)
464
       ("python2-futures" ,python2-futures)
465
       ("python2-progressbar" ,python2-progressbar2)
466
       ("python2-simuvex" ,python2-simuvex)))
467
    (home-page "https://github.com/angr/angr")
468
    (synopsis "Angr is a python framework for analyzing binaries")
469
    (description "angr is a python framework for analyzing binaries.  It
470
focuses on both static and dynamic symbolic (\"concolic\") analysis, making it
471
applicable to a variety of tasks.")
472
    (license license:bsd-2)))
473
474
(define-public sandsifter
475
  (package
476
    (name "sandsifter")
477
    (version "0")
478
    (source (origin
479
              (method git-fetch)
480
              (uri (git-reference
481
                     (url "https://github.com/xoreaxeaxeax/sandsifter")
482
                     (commit "dff63246fed84d90118441b8ba5b5d3bdd094427")))
483
              (sha256
484
               (base32
485
                "1f4hfdhqmam8cz2hixv8zpwggqy17fmczsnc5k9gz87ff7bpqrnk"))))
486
    (build-system gnu-build-system)
487
    (arguments
488
     `(#:make-flags (list "CC=gcc")
489
       #:tests? #f
490
       #:phases
491
       (modify-phases %standard-phases
492
         (delete 'configure)
493
         (replace 'install
494
           (lambda* (#:key inputs outputs #:allow-other-keys)
495
             (let* ((out (assoc-ref outputs "out"))
496
                    (bin (string-append out "/bin"))
497
                    (lib (string-append out "/lib/python2.7/site-packages/sandsifter"))
498
                    (pyutil (string-append lib "/pyutil"))
499
                    (gui (string-append lib "/gui")))
500
               ;(substitute* "summarize.py"
501
               ;  (("pyutil.progress") "sandsifter.pyutil.progress")
502
               ;  (("gui.gui") "sandsifter.gui.gui"))
503
               (substitute* "sifter.py"
504
                 (("./injector") (string-append lib "/injector")))
505
               (mkdir-p bin)
506
               (with-output-to-file (string-append bin "/sifter")
507
                 (lambda _
508
                   (format #t
509
                     "#!~a~@
510
                     PYTHONPATH=~a ~a/bin/python ~a/sifter.py $@"
511
                     (which "sh")
512
                     (string-append (assoc-ref inputs "py-capstone")
513
                                    "/lib/python2.7/site-packages:"
514
                                    (dirname lib))
515
                     (assoc-ref inputs "python2") lib)))
516
               (chmod (string-append bin "/sifter") #o755)
517
               (with-output-to-file (string-append bin "/sifter-summarize")
518
                 (lambda _
519
                   (format #t
520
                     "#!~a~@
521
                     PYTHONPATH=~a ~a/bin/python ~a/summarize.py $@"
522
                     (which "sh")
523
                     (string-append (assoc-ref inputs "py-capstone")
524
                                    "/lib/python2.7/site-packages:"
525
                                    lib)
526
                     (assoc-ref inputs "python2") lib)))
527
               (chmod (string-append bin "/sifter-summarize") #o755)
528
               (install-file "sifter.py" lib)
529
               (install-file "summarize.py" lib)
530
               (install-file "injector" lib)
531
               (install-file "pyutil/__init__.py" pyutil)
532
               (install-file "pyutil/colors.py" pyutil)
533
               (install-file "pyutil/progress.py" pyutil)
534
               (install-file "gui/__init__.py" gui)
535
               (install-file "gui/gui.py" gui)))))))
536
    (inputs
537
     `(("capstone" ,capstone)
538
       ("python2" ,python-2)
539
       ("py-capstone" ,python2-capstone)))
540
    (home-page "https://github.com/xoreaxeaxeax/sandsifter")
541
    (synopsis "X86 processor fuzzer")
542
    (description "The sandsifter audits x86 processors for hidden instructions
543
and hardware bugs, by systematically generating machine code to search through
544
a processor's instruction set, and monitoring execution for anomalies.
545
Sandsifter has uncovered secret processor instructions from every major vendor;
546
ubiquitous software bugs in disassemblers, assemblers, and emulators; flaws in
547
enterprise hypervisors; and both benign and security-critical hardware bugs in
548
x86 chips.")
549
    ;; No license!
550
    (license license:expat)))
551
552
(define-public veles
553
  (package
554
    (name "veles")
555
    (version "2017.06.0.1")
556
    (source (origin
557
              (method url-fetch)
558
              (uri (string-append "https://github.com/codilime/veles/archive/"
559
                                  version ".tar.gz"))
560
              (file-name (string-append name "-" version ".tar.gz"))
561
              (sha256
562
               (base32
563
                "0sv0y0sbx9pjdg755ily3ga7h021531066s0q8niy8nsz7ql9m9b"))))
564
    (build-system cmake-build-system)
565
    (arguments
566
     `(#:configure-flags
567
       (list (string-append "-DMSGPACK_INCLUDE_PATH="
568
                            (assoc-ref %build-inputs "python-msgpack")
569
                            "/include"))
570
       #:phases
571
       (modify-phases %standard-phases
572
         (add-before 'configure 'fix-python-deps
573
           (lambda _
574
             (substitute* "python/requirements.txt"
575
               (("six==1.10.0") "six>=1.10.0")
576
               (("msgpack-python==0.4.8") "msgpack>=0.4.8"))
577
             #t)))))
578
    (inputs
579
     `(("openssl" ,openssl)
580
       ("python" ,python)
581
       ("python-msgpack" ,python-msgpack)
582
       ("python-pbr" ,python-pbr)
583
       ("python-pyopenssl" ,python-pyopenssl)
584
       ("python-six" ,python-six)
585
       ("qtbase" ,qtbase)
586
       ("zlib" ,zlib)))
587
    (native-inputs
588
     `(("googletest" ,googletest)))
589
    (home-page "https://codisec.com/veles/")
590
    (synopsis "")
591
    (description "")
592
    (license license:asl2.0)))
593