1{ lib 2, stdenv 3, buildPythonPackage 4, debugger 5, fetchPypi 6, Mako 7, packaging 8, pysocks 9, pygments 10, ropgadget 11, capstone 12, colored-traceback 13, paramiko 14, pip 15, psutil 16, pyelftools 17, pyserial 18, python-dateutil 19, requests 20, rpyc 21, tox 22, unicorn 23, intervaltree 24, installShellFiles 25}: 26 27let 28 debuggerName = lib.strings.getName debugger; 29in 30buildPythonPackage rec { 31 version = "4.8.0"; 32 pname = "pwntools"; 33 34 src = fetchPypi { 35 inherit pname version; 36 sha256 = "sha256-QgUuLYg3EOTh2gQekWdabXGftOXvLdJFyyhT2hEmkpA="; 37 }; 38 39 postPatch = '' 40 # Upstream has set an upper bound on unicorn because of https://github.com/Gallopsled/pwntools/issues/1538, 41 # but since that is a niche use case and it requires extra work to get unicorn 1.0.2rc3 to work we relax 42 # the bound here. Check if this is still necessary when updating! 43 sed -i 's/unicorn>=1.0.2rc1,<1.0.2rc4/unicorn>=1.0.2rc1/' setup.py 44 45 # Upstream hardcoded the check for the command `gdb-multiarch`; 46 # Forcefully use the provided debugger, as `gdb` (hence `pwndbg`) is built with multiarch in `nixpkgs`. 47 sed -i 's/gdb-multiarch/${debuggerName}/' pwnlib/gdb.py 48 ''; 49 50 nativeBuildInputs = [ 51 installShellFiles 52 ]; 53 54 propagatedBuildInputs = [ 55 Mako 56 packaging 57 pysocks 58 pygments 59 ropgadget 60 capstone 61 colored-traceback 62 paramiko 63 pip 64 psutil 65 pyelftools 66 pyserial 67 python-dateutil 68 requests 69 rpyc 70 tox 71 unicorn 72 intervaltree 73 ]; 74 75 doCheck = false; # no setuptools tests for the package 76 77 postInstall = '' 78 installShellCompletion --bash extra/bash_completion.d/shellcraft 79 ''; 80 81 postFixup = lib.optionalString (!stdenv.isDarwin) '' 82 mkdir -p "$out/bin" 83 makeWrapper "${debugger}/bin/${debuggerName}" "$out/bin/pwntools-gdb" 84 ''; 85 86 meta = with lib; { 87 homepage = "https://pwntools.com"; 88 description = "CTF framework and exploit development library"; 89 license = licenses.mit; 90 maintainers = with maintainers; [ bennofs kristoff3r pamplemousse ]; 91 }; 92}