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