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