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 (gnu packages zip)
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 python-pefile
129
  (package
130
    (name "python-pefile")
131
    (version "2016.3.28")
132
    (source
133
      (origin
134
        (method url-fetch)
135
        (uri (pypi-uri "pefile" version))
136
        (sha256
137
         (base32
138
          "0ysz17ci0nhc5gi6j9si0fg87lzc7vcz3ccbi6qgfgjwbc422h7j"))))
139
    (build-system python-build-system)
140
    (arguments
141
     `(#:tests? #f)); no test
142
    (home-page "https://github.com/erocarrera/pefile")
143
    (synopsis "Parse and work with Portable Executable (aka PE) files")
144
    (description "Pefile is a multi-platform Python module to parse and work
145
with Portable Executable (aka PE) files.  Most of the information contained in
146
the PE headers is accessible as well as all sections' details and their data.
147
The structures defined in the Windows header files will be accessible as
148
attributes in the PE instance.  The naming of fields/attributes will try to
149
adhere to the naming scheme in those headers.  Only shortcuts added for
150
convenience will depart from that convention.")
151
    (license license:expat)))
152
153
(define-public python2-pefile
154
  (package-with-python2 python-pefile))
155
156
(define-public python2-archinfo
157
  (package
158
    (name "python2-archinfo")
159
    (version "6.7.4.12")
160
    (source (origin
161
              (method url-fetch)
162
              (uri (pypi-uri "archinfo" version))
163
              (sha256
164
               (base32
165
                "1kfc9nk73i5rr3xz8mv00cp76p7dc62h9pd8hvnda414jhx7n0pb"))))
166
    (build-system python-build-system)
167
    (arguments
168
     `(#:python ,python-2))
169
    (home-page "https://github.com/angr/archinfo")
170
    (synopsis "Collection of classes that contain architecture-specific information")
171
    (description "Archinfo is a collection of classes that contain
172
architecture-specific information.  It is useful for cross-architecture tools
173
(such as pyvex).")
174
    (license license:bsd-2)))
175
176
(define-public angr-vex
177
  (package
178
    (name "angr-vex")
179
    (version "1")
180
    (source (origin
181
              (method git-fetch)
182
              (uri (git-reference
183
                    (url "https://github.com/angr/vex.git")
184
                    (commit "3a620e43ecc71cb9e5470995a45bbce4a600293f")))
185
              (sha256
186
               (base32
187
                "1qxpwi9961140dnys1iywm043nbm13qg2vw9xi1bjjdh80hbnfw4"))
188
              (file-name (string-append name "-" version))))
189
    (build-system gnu-build-system)
190
    (arguments
191
     `(#:make-flags
192
       (list "CC=gcc" "CC_NATIVE=gcc")
193
       #:tests? #f
194
       #:phases
195
       (modify-phases %standard-phases
196
         (delete 'configure)
197
         (add-before 'build 'get-Makefile
198
           (lambda _
199
             (copy-file "Makefile-gcc" "Makefile")))
200
         (replace 'install
201
           (lambda* (#:key outputs #:allow-other-keys)
202
             (let* ((out (assoc-ref outputs "out"))
203
                   (lib (string-append out "/lib"))
204
                   (include (string-append out "/include")))
205
               (mkdir-p lib)
206
               (mkdir-p include)
207
               (copy-recursively "pub" include)
208
               (copy-file "libvex.a" (string-append lib "/libvex.a"))))))))
209
    (home-page "https://github.com/angr/vex")
210
    (synopsis "Fork of libVEX for PyVEX")
211
    (description "This is a mirror of libVEX (of the Valgrind project:
212
valgrind.org) for use with PyVEX.")
213
    (license license:gpl2+)))
214
215
(define-public python2-pyvex
216
  (package
217
    (name "python2-pyvex")
218
    (version "6.7.4.12")
219
    (source (origin
220
              (method url-fetch)
221
              (uri (pypi-uri "pyvex" version))
222
              (sha256
223
               (base32
224
                "1x57aq96ka7gz6qcj9zqwdcylfks4q3iiykismyk1g0vp68qlwv9"))))
225
    (build-system python-build-system)
226
    (inputs `(("angr-vex" ,angr-vex)))
227
    (propagated-inputs
228
     `(("archinfo" ,python2-archinfo)
229
       ("pycparser" ,python2-pycparser)
230
       ("cffi" ,python2-cffi)))
231
    (arguments
232
     `(#:python ,python-2
233
       #:phases
234
       (modify-phases %standard-phases
235
         (add-before 'build 'fix-setup.py
236
           (lambda* (#:key inputs #:allow-other-keys)
237
             (substitute* "setup.py"
238
               (("VEX_PATH = .*")
239
                (string-append "VEX_PATH = '" (assoc-ref inputs "angr-vex") "'"))
240
               ((".*self.execute\\(_build_vex.*")
241
                "")
242
               (("e\\['VEX_LIB_PATH'\\] = .*")
243
                "e['VEX_LIB_PATH'] = os.path.join(VEX_PATH, 'lib')\n")
244
               (("'pub'")
245
                "'include'")))))))
246
    (home-page "https://github.com/angr/pyvex")
247
    (synopsis "PyVEX exposes VEX into Python")
248
    (description "VEX is an intermediate representation that is useful to carry
249
analyses on binary.  PyVEX exposes VEX into Python.")
250
    (license license:bsd-2)))
251
252
(define-public unicorn
253
  (package
254
    (name "unicorn")
255
    (version "1.0-rc3")
256
    (source (origin
257
              (method url-fetch)
258
              (uri (string-append "https://github.com/unicorn-engine/unicorn/archive/"
259
                                  version ".tar.gz"))
260
              (file-name (string-append name "-" version ".tar.gz"))
261
              (sha256
262
               (base32
263
                "18sf8vbmf08ss27qhiv7la492k39q0ci8kpjx836bv7rq3cbgb2q"))))
264
    (build-system gnu-build-system)
265
    (arguments
266
     `(#:phases
267
       (modify-phases %standard-phases
268
         (delete 'configure))
269
       #:tests? #f
270
       #:make-flags
271
       (list "CC=gcc"
272
             (string-append "PREFIX=" (assoc-ref %outputs "out")))))
273
    (native-inputs
274
     `(("python" ,python-2)
275
       ("pkg-config" ,pkg-config)))
276
    (home-page "http://www.unicorn-engine.org/")
277
    (synopsis "CPU emulator")
278
    (description "Unicorn is a lightweight multi-platform, multi-architecture
279
CPU emulator framework.")
280
    (license (list license:gpl2 license:lgpl2.0))))
281
282
;; Not reproducible
283
(define-public python-unicorn
284
  (package
285
    (inherit unicorn)
286
    (name "python-unicorn")
287
    (propagated-inputs
288
     `(("unicorn" ,unicorn)))
289
    (build-system python-build-system)
290
    (arguments
291
     `(#:tests? #f
292
       #:phases (modify-phases %standard-phases
293
                  (add-after 'unpack 'chdir-and-fix-setup-py
294
                    (lambda _
295
                      (chdir "bindings/python")
296
                      (substitute* "setup.py" (("build_libraries\\(\\)\n") "\n"))
297
                      (substitute* "unicorn/unicorn.py"
298
                        (("'',")
299
                         (string-append "'"
300
                                        (assoc-ref %build-inputs "unicorn")
301
                                        "/lib',")))
302
                      #t)))))))
303
304
(define-public python2-unicorn
305
  (package
306
    (inherit (package-with-python2 python-unicorn))
307
    (propagated-inputs
308
     `(("unicorn" ,unicorn)
309
       ("pyvex" ,python2-pyvex)))))
310
311
(define-public python2-simuvex
312
  (package
313
    (name "python2-simuvex")
314
    (version "6.7.4.12")
315
    (source (origin
316
              (method url-fetch)
317
              (uri (pypi-uri "simuvex" version))
318
              (sha256
319
               (base32
320
                "03rqdk7f1ynm6p50rbl4abq6hgnfvb7qd5k26m7cyxjii09waa2x"))
321
              (modules '((guix build utils)))
322
              (snippet
323
               '(substitute* "setup.py"
324
                  (("dpkt-fix") "dpkt")))))
325
    (build-system python-build-system)
326
    (native-inputs
327
     `(("pkg-config" ,pkg-config)
328
       ("enum34" ,python2-enum34)))
329
    (propagated-inputs
330
     `(("pyvex" ,python2-pyvex)
331
       ("bintrees" ,python2-bintrees)
332
       ("dpkt" ,python2-dpkt)
333
       ("cooldict" ,python2-cooldict)
334
       ("cachetools" ,python2-cachetools)
335
       ("claripy" ,python2-claripy)
336
       ("unicorn" ,python2-unicorn)
337
       ("glib" ,glib)))
338
    (inputs
339
     `(("zlib" ,zlib)))
340
    (arguments
341
     `(#:python ,python-2))
342
    (home-page "https://github.com/angr/cle")
343
    (synopsis "Abstraction of process memory")
344
    (description "CLE loads binaries and their associated libraries, resolves
345
imports and provides an abstraction of process memory the same way as if it was
346
loaded by the OS's loader.")
347
    (license license:bsd-2)))
348
349
(define-public python2-cle
350
  (package
351
    (name "python2-cle")
352
    (version "6.7.4.12")
353
    (source (origin
354
              (method url-fetch)
355
              (uri (pypi-uri "cle" version))
356
              (sha256
357
               (base32
358
                "1fx21jx2nmc5lbz7hgpz4p7ccvzrnrcnf0wj2fbqdyjb9s0w2sfw"))
359
              (modules '((guix build utils)))
360
              (snippet
361
               '(substitute* "setup.py"
362
                  ((", \"idalink\"") ""))))); Idalink is not acceptable
363
    (build-system python-build-system)
364
    (propagated-inputs
365
     `(("pyelftools" ,python2-pyelftools)
366
       ("cffi" ,python2-cffi)
367
       ("archinfo" ,python2-archinfo)
368
       ("future" ,python2-future)
369
       ("pyvex" ,python2-pyvex)
370
       ("pefile" ,python2-pefile)))
371
    (arguments
372
     `(#:python ,python-2))
373
    (home-page "https://github.com/angr/cle")
374
    (synopsis "Abstraction of process memory")
375
    (description "CLE loads binaries and their associated libraries, resolves
376
imports and provides an abstraction of process memory the same way as if it was
377
loaded by the OS's loader.")
378
    (license license:bsd-2)))
379
380
(define-public python2-angr
381
  (package
382
    (name "python2-angr")
383
    (version "6.7.4.12")
384
    (source (origin
385
              (method url-fetch)
386
              (uri (pypi-uri "angr" version))
387
              (sha256
388
               (base32
389
                "0cqqakh2drb593wcbdcq0vq3pcf1ckxwy486cg378667lrb4042i"))))
390
    (build-system python-build-system)
391
    (arguments
392
     `(#:python ,python-2))
393
    (propagated-inputs
394
     `(("cle" ,python2-cle)
395
       ("capstone" ,python2-capstone)
396
       ("six" ,python2-six)
397
       ("utils" ,python2-utils)
398
       ("mulpyplexer" ,python2-mulpyplexer)
399
       ("rpyc" ,python2-rpyc)
400
       ("enum34" ,python2-enum34)
401
       ("networkx" ,python2-networkx)
402
       ("futures" ,python2-futures)
403
       ("progressbar" ,python2-progressbar2)
404
       ("simuvex" ,python2-simuvex)))
405
    (home-page "https://github.com/angr/angr")
406
    (synopsis "Angr is a python framework for analyzing binaries")
407
    (description "angr is a python framework for analyzing binaries.  It
408
focuses on both static and dynamic symbolic (\"concolic\") analysis, making it
409
applicable to a variety of tasks.")
410
    (license license:bsd-2)))
411
412
(define-public radare2
413
  (package
414
    (name "radare2")
415
    (version "1.4.0")
416
    (source (origin
417
              (method url-fetch)
418
              (uri (string-append "http://cloud.radare.org/get/" version "/"
419
                                  name "-" version ".tar.gz"))
420
              (sha256
421
               (base32
422
                "0gp9ngi2lcd76zgwzjii8bsgncw4449qnfsn6qwqv0nm9zcrlvmz"))
423
              (modules '((guix build utils)))
424
              (snippet
425
                '(begin
426
                  (substitute* "libr/asm/p/Makefile"
427
                    (("LDFLAGS\\+=") "LDFLAGS+=-Wl,-rpath=$(LIBDIR) "))
428
                  (substitute* "libr/parse/p/Makefile"
429
                    (("LDFLAGS\\+=") "LDFLAGS+=-Wl,-rpath=$(LIBDIR) "))
430
                  (substitute* "libr/bin/p/Makefile"
431
                    (("LDFLAGS\\+=") "LDFLAGS+=-Wl,-rpath=$(LIBDIR) "))))))
432
    (build-system gnu-build-system)
433
    (arguments
434
     '(#:tests? #f
435
       #:phases
436
       (modify-phases %standard-phases
437
         (add-before 'configure 'mklibdir
438
           (lambda* (#:key inputs #:allow-other-keys)
439
             (mkdir-p (string-append (assoc-ref %outputs "out") "/lib")))))
440
       #:configure-flags
441
       (list "--with-sysmagic" "--with-syszip" "--with-openssl"
442
             "--without-nonpic" "--with-rpath" "--with-syscapstone")
443
       #:make-flags
444
       (list "CC=gcc")))
445
    (inputs
446
     `(("openssl" ,openssl)
447
       ("zip" ,zip)
448
       ("gmp" ,gmp)
449
       ("capstone" ,capstone)))
450
    (native-inputs
451
     `(("pkg-config" ,pkg-config)))
452
    (home-page "https://rada.re/")
453
    (synopsis "Binary analysis tool")
454
    (description
455
      "Radare2 is a tool for reversing binaries.")
456
    (license license:gpl3+)))
457