unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: "Jakub Kądziołka" <kuba@kadziolka.net>
To: 40267@debbugs.gnu.org
Cc: leo@famulari.name
Subject: [bug#40267] [WIP PATCH v2 2/2] gnu: Add python-pwntools.
Date: Sun,  7 Jun 2020 22:19:41 +0200	[thread overview]
Message-ID: <20200607201941.5044-2-kuba@kadziolka.net> (raw)
In-Reply-To: <20200607201941.5044-1-kuba@kadziolka.net>

* gnu/packages/cybersecurity.scm (python-pwntools): New variable.
---

Changes from v1: added a patch to fix the installed commands' behavior
when wrapped by Guix - exec doesn't fool Python's sys.argv[0]. Resolved
the optional dependency on binutils for various architectures. Some
unresolved questions here mentioned in the comments.

I tried moving python-intervaltree out of bioinformatics.scm, but I
couldn't find a good place for intervaltree (the C library) to go with
it. python-xyz.scm feels wrong, since it's not in Python, and leaving it
in bioinformatics.scm creates a cycle.

 gnu/local.mk                                  |  1 +
 gnu/packages/cybersecurity.scm                | 83 ++++++++++++++++++-
 .../python-pwntools-guix-wrappers.patch       | 14 ++++
 3 files changed, 97 insertions(+), 1 deletion(-)
 create mode 100644 gnu/packages/patches/python-pwntools-guix-wrappers.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index ae8a2275f7..4384ad952d 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1431,6 +1431,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/python-packaging-test-arch.patch		\
   %D%/packages/patches/python2-parameterized-docstring-test.patch	\
   %D%/packages/patches/python-paste-remove-timing-test.patch	\
+  %D%/packages/patches/python-pwntools-guix-wrappers.patch	\
   %D%/packages/patches/python-pycrypto-CVE-2013-7459.patch	\
   %D%/packages/patches/python-pycrypto-time-clock.patch		\
   %D%/packages/patches/python2-pygobject-2-gi-info-type-error-domain.patch \
diff --git a/gnu/packages/cybersecurity.scm b/gnu/packages/cybersecurity.scm
index 8ded081c50..d45618e617 100644
--- a/gnu/packages/cybersecurity.scm
+++ b/gnu/packages/cybersecurity.scm
@@ -18,10 +18,20 @@
 
 (define-module (gnu packages cybersecurity)
   #:use-module (guix download)
+  #:use-module (guix git-download)
   #:use-module (guix packages)
   #:use-module ((guix licenses) #:prefix license:)
   #:use-module (guix build-system python)
-  #:use-module (gnu packages engineering))
+  #:use-module (gnu packages)
+  #:use-module (gnu packages avr)
+  #:use-module (gnu packages bioinformatics)
+  #:use-module (gnu packages cross-base)
+  #:use-module (gnu packages emulators)
+  #:use-module (gnu packages engineering)
+  #:use-module (gnu packages python-crypto)
+  #:use-module (gnu packages python-web)
+  #:use-module (gnu packages python-xyz)
+  #:use-module (gnu packages time))
 
 (define-public ropgadget
   (package
@@ -43,3 +53,74 @@
 gadgets in binaries.  Some facilities are included for automatically generating
 chains of gadgets to execute system calls.")
     (license license:bsd-3)))
+
+(define-public python-pwntools
+  (package
+    (name "python-pwntools")
+    (version "4.1.1")
+    (source
+      (origin
+        (method git-fetch)
+        (uri (git-reference
+               (url "https://github.com/Gallopsled/pwntools")
+               (commit version)))
+        (file-name (git-file-name name version))
+        (sha256
+         (base32
+          "101whqdfj415h0f4b9hz2jrwny44b0jdd9jmbh6rzz5w1yp41d5v"))
+        (patches (search-patches "python-pwntools-guix-wrappers.patch"))))
+    (build-system python-build-system)
+    (arguments
+     `(#:tests? #f)) ; Tests require networking and custom sshd configuration
+    (propagated-inputs
+     `(("paramiko" ,python-paramiko)
+       ("mako" ,python-mako)
+       ("pyelftools" ,python-pyelftools)
+       ("capstone" ,python-capstone)
+       ("ropgadget" ,ropgadget)
+       ("pyserial" ,python-pyserial)
+       ("requests" ,python-requests)
+       ("pygments" ,python-pygments)
+       ("pysocks" ,python-pysocks)
+       ("dateutil" ,python-dateutil)
+       ("packaging" ,python-packaging)
+       ("psutil" ,python-psutil)
+       ("intervaltree" ,python-intervaltree)
+       ("sortedcontainers" ,python-sortedcontainers)
+       ("unicorn" ,unicorn "python")
+
+       ;; See https://docs.pwntools.com/en/stable/install/binutils.html
+       ;; All architectures recognized by pwntools are included.
+       ("binutils:aarch64" ,(cross-binutils "aarch64-linux-gnu"))
+       ("binutils:alpha" ,(cross-binutils "alpha-linux-gnu"))
+       ("binutils:arm" ,(cross-binutils "arm-linux-gnueabihf"))
+       ;; TODO: AVR binutils aren't detected,
+       ;; see https://github.com/Gallopsled/pwntools/pull/1536
+       ("binutils:avr" ,avr-binutils)
+       ("binutils:cris" ,(cross-binutils "cris-linux-gnu"))
+       ("binutils:i686" ,(cross-binutils "i686-linux-gnu"))
+       ("binutils:ia64" ,(cross-binutils "ia64-linux-gnu"))
+       ("binutils:m68k" ,(cross-binutils "m68k-linux-gnu"))
+       ("binutils:mips" ,(cross-binutils "mipsel-linux-gnu"))
+       ("binutils:mips64" ,(cross-binutils "mips64el-linux-gnu"))
+       ;; TODO: MSP430 doesn't work for the same reason as AVR.
+       ("binutils:msp430" ,(cross-binutils "msp430"))
+       ("binutils:powerpc" ,(cross-binutils "powerpc-linux-gnu"))
+       ("binutils:powerpc64" ,(cross-binutils "powerpc64-linux-gnu"))
+       ;; TODO: Attempting to assemble code for arch='s390' complains
+       ;; about bfdname
+       ("binutils:s390" ,(cross-binutils "s390-linux-gnu"))
+       ("binutils:sparc" ,(cross-binutils "sparc-linux-gnu"))
+       ("binutils:sparc64" ,(cross-binutils "sparc64-linux-gnu"))
+       ;; TODO: Should VAX use a -linux-gnu target, or just "vax"?
+       ("binutils:vax" ,(cross-binutils "vax-linux-gnu"))
+       ("binutils:x86_64" ,(cross-binutils "x86_64-linux-gnu"))))
+    (native-inputs
+     `(("tox" ,python-tox)))
+    (home-page "https://github.com/Gallopsled/pwntools")
+    (synopsis "CTF framework and exploit development library")
+    (description "Pwntools is a CTF framework and exploit development library.
+Written in Python, it is designed for rapid prototyping and development, and
+intended to make exploit writing as simple as possible.")
+    ;; See LICENSE-pwntools.txt in the source distribution.
+    (license (list license:expat license:bsd-2 license:gpl2+))))
diff --git a/gnu/packages/patches/python-pwntools-guix-wrappers.patch b/gnu/packages/patches/python-pwntools-guix-wrappers.patch
new file mode 100644
index 0000000000..b79a22320d
--- /dev/null
+++ b/gnu/packages/patches/python-pwntools-guix-wrappers.patch
@@ -0,0 +1,14 @@
+Parse argv properly when the programs are wrapped by Guix.
+========================================================================
+diff --git a/pwnlib/commandline/common.py b/pwnlib/commandline/common.py
+index 75edfdcb..5249b6e6 100644
+--- a/pwnlib/commandline/common.py
++++ b/pwnlib/commandline/common.py
+@@ -28,5 +28,7 @@ parser_commands = parser.add_subparsers(dest='command')
+ def main(file=sys.argv[0]):
+     import pwnlib.commandline.main
+     name = os.path.splitext(os.path.basename(file))[0]
++    if name.startswith('.') and name.endswith('-real'):
++        name = name[1:-5]
+     sys.argv.insert(1, name)
+     pwnlib.commandline.main.main()
-- 
2.26.2





      reply	other threads:[~2020-06-07 20:20 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-28  0:50 [bug#40267] [PATCH 1/2] gnu: Add unicorn Jakub Kądziołka
2020-03-28  0:53 ` [bug#40267] [PATCH 2/2] gnu: Add python-pwntools Jakub Kądziołka
2020-03-29  2:56   ` Leo Famulari
2020-03-29 15:32     ` Jakub Kądziołka
2020-03-29  3:48 ` [bug#40267] [PATCH 1/2] gnu: Add unicorn Leo Famulari
2020-03-29 12:43   ` Jakub Kądziołka
2020-06-07 20:19 ` [bug#40267] [PATCH v2 " Jakub Kądziołka
2020-06-07 20:19   ` Jakub Kądziołka [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200607201941.5044-2-kuba@kadziolka.net \
    --to=kuba@kadziolka.net \
    --cc=40267@debbugs.gnu.org \
    --cc=leo@famulari.name \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).