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 pkg-config)
31
  #:use-module (gnu packages python)
32
  #:use-module (more packages python)
33
  #:use-module (more packages smt))
34
35
(define-public python-pyelftools
36
  (package
37
    (name "python-pyelftools")
38
    (version "0.24")
39
    (source (origin
40
              (method url-fetch)
41
              (uri (string-append "https://github.com/eliben/pyelftools/archive/v"
42
                                  version ".tar.gz"))
43
              (file-name (string-append name "-" version ".tar.gz"))
44
              (sha256
45
               (base32
46
                "1iw47b20brg0ah86s9a2dn1f70qfmdv20p04q131vmnwa9g066f4"))))
47
    (build-system python-build-system)
48
    (home-page "https://github.com/eliben/pyelftools")
49
    (synopsis "Parsing and analyzing ELF files and DWARF debugging information")
50
    (description
51
      "Python library for parsing and analyzing ELF files and DWARF debugging information.")
52
    (license license:public-domain)))
53
54
(define-public python2-pyelftools
55
  (package-with-python2 python-pyelftools))
56
57
(define-public capstone
58
  (package
59
    (name "capstone")
60
    (version "3.0.4")
61
    (source (origin
62
              (method url-fetch)
63
              (uri (string-append "https://github.com/aquynh/capstone/archive/"
64
                                  version ".tar.gz"))
65
              (file-name (string-append name "-" version ".tar.gz"))
66
              (sha256
67
               (base32
68
                "1whl5c8j6vqvz2j6ay2pyszx0jg8d3x8hq66cvgghmjchvsssvax"))))
69
    (build-system gnu-build-system)
70
    (arguments
71
     `(#:tests? #f
72
       #:make-flags (list (string-append "PREFIX=" (assoc-ref %outputs "out"))
73
                          "CC=gcc")
74
       #:phases
75
       (modify-phases %standard-phases
76
         (delete 'configure))))
77
    (home-page "http://www.capstone-engine.org")
78
    (synopsis "Disassembler")
79
    (description
80
     "Capstone can disassemble machine code for many supported architectures
81
such as x86, x86_64, arm, arm64, mips, ppc, sparc, sysz and xcore.  It provides
82
bindings for Python, Java, OCaml and more.")
83
    (license (list license:bsd-3 license:expat))))
84
85
;; This package has a timestamp embedded in
86
;; lib/python3.5/site-packages/capstone/__pycache__/__iti__.cpython-35.pyc
87
(define-public python-capstone
88
  (package
89
    (inherit capstone)
90
    (name "python-capstone")
91
    (propagated-inputs
92
     `(("capstone" ,capstone)))
93
    (build-system python-build-system)
94
    (arguments
95
     `(#:tests? #f
96
       #:phases
97
       (modify-phases %standard-phases
98
         (add-after 'unpack 'chdir-and-fix-setup-py
99
           (lambda _
100
             (chdir "bindings/python")
101
             (substitute* "setup.py" (("data_files=.*") ""))
102
             (substitute* "capstone/__init__.py"
103
               (("_lib_path =.*")
104
                (string-append "_lib_path = '"
105
                               (assoc-ref %build-inputs "capstone")
106
                               "/lib'\n")))
107
             #t)))))))
108
109
(define-public python2-capstone
110
  (package-with-python2 python-capstone))
111
 
112
(define-public python-pefile
113
  (package
114
    (name "python-pefile")
115
    (version "2016.3.28")
116
    (source
117
      (origin
118
        (method url-fetch)
119
        (uri (pypi-uri "pefile" version))
120
        (sha256
121
         (base32
122
          "0ysz17ci0nhc5gi6j9si0fg87lzc7vcz3ccbi6qgfgjwbc422h7j"))))
123
    (build-system python-build-system)
124
    (home-page "https://github.com/erocarrera/pefile")
125
    (synopsis "Parse and work with Portable Executable (aka PE) files")
126
    (description "Pefile is a multi-platform Python module to parse and work
127
with Portable Executable (aka PE) files.  Most of the information contained in
128
the PE headers is accessible as well as all sections' details and their data.
129
The structures defined in the Windows header files will be accessible as
130
attributes in the PE instance.  The naming of fields/attributes will try to
131
adhere to the naming scheme in those headers.  Only shortcuts added for
132
convenience will depart from that convention.")
133
    (license license:expat)))
134
135
(define-public python2-pefile
136
  (package-with-python2 python-pefile))
137
138
(define-public python-archinfo
139
  (package
140
    (name "python-archinfo")
141
    (version "6.7.1.13")
142
    (source (origin
143
              (method url-fetch)
144
              (uri (pypi-uri "archinfo" version))
145
              (sha256
146
               (base32
147
                "0x896mk98r6g9h3rxpqq9ri0s6v9n937jx0fzn7i61zn61n7whzw"))))
148
    (build-system python-build-system)
149
    (home-page "https://github.com/angr/archinfo")
150
    (synopsis "Collection of classes that contain architecture-specific information")
151
    (description "Archinfo is a collection of classes that contain
152
architecture-specific information.  It is useful for cross-architecture tools
153
(such as pyvex).")
154
    (license license:bsd-2)))
155
156
(define-public python2-archinfo
157
  (package-with-python2 python-archinfo))
158
159
(define-public angr-vex
160
  (package
161
    (name "angr-vex")
162
    (version "1")
163
    (source (origin
164
              (method git-fetch)
165
              (uri (git-reference
166
                    (url "https://github.com/angr/vex.git")
167
                    (commit "058410ede7ee74231255f6ae77cae8476c8a3ef4")))
168
              (sha256
169
               (base32
170
                "02wi1705pa0xbwfqx3jj6g7nnvzi8whgmnd29fp1i7n4qz20gcgb"))
171
              (file-name (string-append name "-" version))))
172
    (build-system gnu-build-system)
173
    (arguments
174
     `(#:make-flags
175
       (list "CC=gcc")
176
       #:tests? #f
177
       #:phases
178
       (modify-phases %standard-phases
179
         (delete 'configure)
180
         (replace 'install
181
           (lambda* (#:key outputs #:allow-other-keys)
182
             (let* ((out (assoc-ref outputs "out"))
183
                   (lib (string-append out "/lib"))
184
                   (include (string-append out "/include")))
185
               (mkdir-p lib)
186
               (mkdir-p include)
187
               (copy-recursively "pub" include)
188
               (copy-file "libvex.a" (string-append lib "/libvex.a"))))))))
189
    (home-page "https://github.com/angr/vex")
190
    (synopsis "Fork of libVEX for PyVEX")
191
    (description "This is a mirror of libVEX (of the Valgrind project:
192
valgrind.org) for use with PyVEX.")
193
    (license license:gpl2+)))
194
195
(define-public python2-pyvex
196
  (package
197
    (name "python2-pyvex")
198
    (version "6.7.1.13.post2")
199
    (source (origin
200
              (method url-fetch)
201
              (uri (pypi-uri "pyvex" version))
202
              (sha256
203
               (base32
204
                "1x9s88hgrw9xz8v9x9njjz0jq4fxkwyn479074bg4wbqjsp9n7qd"))))
205
    (build-system python-build-system)
206
    (inputs `(("angr-vex" ,angr-vex)))
207
    (propagated-inputs
208
     `(("archinfo" ,python2-archinfo)
209
       ("pycparser" ,python2-pycparser)
210
       ("cffi" ,python2-cffi)))
211
    (arguments
212
     `(#:python ,python-2
213
       #:phases
214
       (modify-phases %standard-phases
215
         (add-before 'build 'fix-setup.py
216
           (lambda* (#:key inputs #:allow-other-keys)
217
             (substitute* "setup.py"
218
               (("VEX_PATH = .*")
219
                (string-append "VEX_PATH = '" (assoc-ref inputs "angr-vex") "'"))
220
               ((".*self.execute\\(_build_vex.*")
221
                "")
222
               (("e\\['VEX_LIB_PATH'\\] = .*")
223
                "e['VEX_LIB_PATH'] = os.path.join(VEX_PATH, 'lib')\n")
224
               (("'pub'")
225
                "'include'")))))))
226
    (home-page "https://github.com/angr/pyvex")
227
    (synopsis "PyVEX exposes VEX into Python")
228
    (description "VEX is an intermediate representation that is useful to carry
229
analyses on binary.  PyVEX exposes VEX into Python.")
230
    (license license:bsd-2)))
231
232
(define-public unicorn
233
  (package
234
    (name "unicorn")
235
    (version "1.0-rc3")
236
    (source (origin
237
              (method url-fetch)
238
              (uri (string-append "https://github.com/unicorn-engine/unicorn/archive/"
239
                                  version ".tar.gz"))
240
              (file-name (string-append name "-" version ".tar.gz"))
241
              (sha256
242
               (base32
243
                "18sf8vbmf08ss27qhiv7la492k39q0ci8kpjx836bv7rq3cbgb2q"))))
244
    (build-system gnu-build-system)
245
    (arguments
246
     `(#:phases
247
       (modify-phases %standard-phases
248
         (delete 'configure))
249
       #:tests? #f
250
       #:make-flags
251
       (list "CC=gcc"
252
             (string-append "PREFIX=" (assoc-ref %outputs "out")))))
253
    (native-inputs
254
     `(("python" ,python-2)
255
       ("pkg-config" ,pkg-config)))
256
    (home-page "http://www.unicorn-engine.org/")
257
    (synopsis "CPU emulator")
258
    (description "Unicorn is a lightweight multi-platform, multi-architecture
259
CPU emulator framework.")
260
    (license (list license:gpl2 license:lgpl2.0))))
261
262
;; Not reproducible
263
(define-public python-unicorn
264
  (package
265
    (inherit unicorn)
266
    (name "python-unicorn")
267
    (propagated-inputs
268
     `(("unicorn" ,unicorn)))
269
    (build-system python-build-system)
270
    (arguments
271
     `(#:tests? #f
272
       #:phases (modify-phases %standard-phases
273
                  (add-after 'unpack 'chdir-and-fix-setup-py
274
                    (lambda _
275
                      (chdir "bindings/python")
276
                      (substitute* "setup.py" (("build_libraries\\(\\)\n") "\n"))
277
                      (substitute* "unicorn/unicorn.py"
278
                        (("'',")
279
                         (string-append "'"
280
                                        (assoc-ref %build-inputs "unicorn")
281
                                        "/lib',")))
282
                      #t)))))))
283
284
(define-public python2-unicorn
285
  (package
286
    (inherit (package-with-python2 python-unicorn))
287
    (propagated-inputs
288
     `(("unicorn" ,unicorn)
289
       ("pyvex" ,python2-pyvex)))))
290
291
;; TODO: Requires dpkt-fix for testing
292
(define-public python2-simuvex
293
  (package
294
    (name "python2-simuvex")
295
    (version "6.7.1.31")
296
    (source (origin
297
              (method url-fetch)
298
              (uri (pypi-uri "simuvex" version))
299
              (sha256
300
               (base32
301
                "150jwf55pib7ndz7bjb4fxifqqgdxx7n1f5qa87mz6349qvi1xji"))))
302
    (build-system python-build-system)
303
    (native-inputs
304
     `(("pkg-config" ,pkg-config)))
305
    (propagated-inputs
306
     `(("pyvex" ,python2-pyvex)
307
       ("bintrees" ,python2-bintrees)
308
       ("dpkt" ,python2-dpkt)
309
       ("cooldict" ,python2-cooldict)
310
       ("cachetools" ,python2-cachetools)
311
       ("claripy" ,python2-claripy)
312
       ("unicorn" ,python2-unicorn)
313
       ("glib" ,glib)))
314
    (inputs
315
     `(("zlib" ,zlib)))
316
    (arguments
317
     `(#:python ,python-2))
318
    (home-page "https://github.com/angr/cle")
319
    (synopsis "Abstraction of process memory")
320
    (description "CLE loads binaries and their associated libraries, resolves
321
imports and provides an abstraction of process memory the same way as if it was
322
loaded by the OS's loader.")
323
    (license license:bsd-2)))
324
325
(define-public python-cle
326
  (package
327
    (name "python-cle")
328
    (version "6.7.1.31")
329
    (source (origin
330
              (method url-fetch)
331
              (uri (pypi-uri "cle" version))
332
              (sha256
333
               (base32
334
                "0llk54f9p3b73f1pk19axlhw8yw80fdv07jkghqmqwd6xrnpnmmc"))))
335
    (build-system python-build-system)
336
    (propagated-inputs
337
     `(("pyelftools" ,python-pyelftools)
338
       ("cffi" ,python-cffi)
339
       ("archinfo" ,python-archinfo)
340
       ("pefile" ,python-pefile)))
341
    (home-page "https://github.com/angr/cle")
342
    (synopsis "Abstraction of process memory")
343
    (description "CLE loads binaries and their associated libraries, resolves
344
imports and provides an abstraction of process memory the same way as if it was
345
loaded by the OS's loader.")
346
    (license license:bsd-2)))
347
348
(define-public python2-cle
349
  (package
350
    (inherit (package-with-python2 python-cle))
351
    (propagated-inputs
352
     `(("pyelftools" ,python2-pyelftools)
353
       ("cffi" ,python2-cffi)
354
       ("pefile" ,python2-pefile)
355
       ("pyvex" ,python2-pyvex)))))
356
357
(define-public python2-angr
358
  (package
359
    (name "python2-angr")
360
    (version "6.7.1.31")
361
    (source (origin
362
              (method url-fetch)
363
              (uri (pypi-uri "angr" version))
364
              (sha256
365
               (base32
366
                "19msllsjwc869824sx1qah6vnb03z22s71fph215ykbbb2843p1k"))))
367
    (build-system python-build-system)
368
    (arguments
369
     `(#:python ,python-2))
370
    (propagated-inputs
371
     `(("cle" ,python2-cle)
372
       ("six" ,python2-six)
373
       ("utils" ,python2-utils)
374
       ("mulpyplexer" ,python2-mulpyplexer)
375
       ("rpyc" ,python2-rpyc)
376
       ("networkx" ,python2-networkx)
377
       ("futures" ,python2-futures)
378
       ("progressbar" ,python2-progressbar2)
379
       ("simuvex" ,python2-simuvex)))
380
    (home-page "https://github.com/angr/angr")
381
    (synopsis "Angr is a python framework for analyzing binaries")
382
    (description "angr is a python framework for analyzing binaries.  It
383
focuses on both static and dynamic symbolic (\"concolic\") analysis, making it
384
applicable to a variety of tasks.")
385
    (license license:bsd-2)))
386