1{ 2 lib, 3 stdenv, 4 buildPythonPackage, 5 debugger, 6 fetchPypi, 7 capstone, 8 colored-traceback, 9 intervaltree, 10 mako, 11 packaging, 12 paramiko, 13 psutil, 14 pyelftools, 15 pygments, 16 pyserial, 17 pysocks, 18 python-dateutil, 19 requests, 20 ropgadget, 21 rpyc, 22 setuptools, 23 six, 24 sortedcontainers, 25 unicorn, 26 unix-ar, 27 zstandard, 28 installShellFiles, 29}: 30 31let 32 debuggerName = lib.strings.getName debugger; 33in 34buildPythonPackage rec { 35 pname = "pwntools"; 36 version = "4.14.1"; 37 pyproject = true; 38 39 src = fetchPypi { 40 inherit pname version; 41 hash = "sha256-YPBJdtFyISDRi51QVTQIoCRmS1z4iPNvJYr8pL8DXKw="; 42 }; 43 44 postPatch = '' 45 # Upstream hardcoded the check for the command `gdb-multiarch`; 46 # Forcefully use the provided debugger as `gdb`. 47 sed -i 's/gdb-multiarch/${debuggerName}/' pwnlib/gdb.py 48 ''; 49 50 nativeBuildInputs = [ installShellFiles ]; 51 52 build-system = [ setuptools ]; 53 54 pythonRemoveDeps = [ 55 "pip" 56 "unicorn" 57 ]; 58 59 propagatedBuildInputs = [ 60 capstone 61 colored-traceback 62 intervaltree 63 mako 64 packaging 65 paramiko 66 psutil 67 pyelftools 68 pygments 69 pyserial 70 pysocks 71 python-dateutil 72 requests 73 ropgadget 74 rpyc 75 six 76 sortedcontainers 77 unicorn 78 unix-ar 79 zstandard 80 ]; 81 82 doCheck = false; # no setuptools tests for the package 83 84 postInstall = '' 85 installShellCompletion --cmd pwn \ 86 --bash extra/bash_completion.d/pwn \ 87 --zsh extra/zsh_completion/_pwn 88 ''; 89 90 postFixup = lib.optionalString (!stdenv.hostPlatform.isDarwin) '' 91 mkdir -p "$out/bin" 92 makeWrapper "${debugger}/bin/${debuggerName}" "$out/bin/pwntools-gdb" 93 ''; 94 95 pythonImportsCheck = [ "pwn" ]; 96 97 meta = with lib; { 98 description = "CTF framework and exploit development library"; 99 homepage = "https://pwntools.com"; 100 changelog = "https://github.com/Gallopsled/pwntools/releases/tag/${version}"; 101 license = licenses.mit; 102 maintainers = with maintainers; [ 103 bennofs 104 kristoff3r 105 pamplemousse 106 ]; 107 }; 108}