From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id GxlgMgFM3V6nUgAA0tVLHw (envelope-from ) for ; Sun, 07 Jun 2020 20:20:17 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id ts2rLQFM3V5yIAAA1q6Kng (envelope-from ) for ; Sun, 07 Jun 2020 20:20:17 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 852799409E2 for ; Sun, 7 Jun 2020 20:20:16 +0000 (UTC) Received: from localhost ([::1]:35036 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ji1mB-0006Uu-GW for larch@yhetil.org; Sun, 07 Jun 2020 16:20:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35260) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ji1ly-0006P5-P8 for guix-patches@gnu.org; Sun, 07 Jun 2020 16:20:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:43482) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ji1ly-0002a6-F6 for guix-patches@gnu.org; Sun, 07 Jun 2020 16:20:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ji1ly-000452-B0 for guix-patches@gnu.org; Sun, 07 Jun 2020 16:20:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#40267] [WIP PATCH v2 2/2] gnu: Add python-pwntools. Resent-From: Jakub =?UTF-8?Q?K=C4=85dzio=C5=82ka?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 07 Jun 2020 20:20:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 40267 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 40267@debbugs.gnu.org Cc: leo@famulari.name Received: via spool by 40267-submit@debbugs.gnu.org id=B40267.159156119815661 (code B ref 40267); Sun, 07 Jun 2020 20:20:02 +0000 Received: (at 40267) by debbugs.gnu.org; 7 Jun 2020 20:19:58 +0000 Received: from localhost ([127.0.0.1]:55027 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ji1lq-00044T-45 for submit@debbugs.gnu.org; Sun, 07 Jun 2020 16:19:58 -0400 Received: from pat.zlotemysli.pl ([37.59.186.212]:55152) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ji1lk-000444-8S for 40267@debbugs.gnu.org; Sun, 07 Jun 2020 16:19:52 -0400 Received: (qmail 15314 invoked by uid 1009); 7 Jun 2020 22:19:46 +0200 Received: from 188.123.215.55 (kuba@kadziolka.net@188.123.215.55) by pat.zlotemysli.pl (envelope-from , uid 1002) with qmail-scanner-2.08st (clamdscan: 0.98.6/25835. spamassassin: 3.4.0. perlscan: 2.08st. Clear:RC:1(188.123.215.55):. Processed in 0.067067 secs); 07 Jun 2020 20:19:46 -0000 Received: from unknown (HELO localhost.localdomain) (kuba@kadziolka.net@188.123.215.55) by pat.zlotemysli.pl with AES256-SHA encrypted SMTP; 7 Jun 2020 22:19:46 +0200 From: Jakub =?UTF-8?Q?K=C4=85dzio=C5=82ka?= Date: Sun, 7 Jun 2020 22:19:41 +0200 Message-Id: <20200607201941.5044-2-kuba@kadziolka.net> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200607201941.5044-1-kuba@kadziolka.net> References: <20200607201941.5044-1-kuba@kadziolka.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Qmailux-2.08st: added fake Content-Type header Content-Type: text/plain X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Spam-Score: -1.0 (-) X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Spam-Score: 2.49 X-TUID: vlWxXoBWWCEn * 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