2021-12-06 16:07:01 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
2020-04-24 23:36:52 +00:00
|
|
|
, python3
|
|
|
|
, fetchFromGitHub
|
|
|
|
, makeWrapper
|
|
|
|
, gdb
|
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
pythonPath = with python3.pkgs; makePythonPath [
|
2023-01-20 10:41:00 +00:00
|
|
|
capstone
|
2020-04-24 23:36:52 +00:00
|
|
|
future
|
|
|
|
psutil
|
2023-01-20 10:41:00 +00:00
|
|
|
pwntools
|
2020-04-24 23:36:52 +00:00
|
|
|
pycparser
|
|
|
|
pyelftools
|
|
|
|
pygments
|
2023-01-20 10:41:00 +00:00
|
|
|
unicorn
|
|
|
|
rpyc
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
2023-01-20 10:41:00 +00:00
|
|
|
binPath = lib.makeBinPath ([
|
|
|
|
python3.pkgs.pwntools # ref: https://github.com/pwndbg/pwndbg/blob/2022.12.19/pwndbg/wrappers/checksec.py#L8
|
|
|
|
] ++ lib.optionals stdenv.isLinux [
|
|
|
|
python3.pkgs.ropper # ref: https://github.com/pwndbg/pwndbg/blob/2022.12.19/pwndbg/commands/ropper.py#L30
|
|
|
|
python3.pkgs.ropgadget # ref: https://github.com/pwndbg/pwndbg/blob/2022.12.19/pwndbg/commands/rop.py#L32
|
|
|
|
]);
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
in stdenv.mkDerivation rec {
|
|
|
|
pname = "pwndbg";
|
2023-01-20 10:41:00 +00:00
|
|
|
version = "2022.12.19";
|
2020-04-24 23:36:52 +00:00
|
|
|
format = "other";
|
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "pwndbg";
|
|
|
|
repo = "pwndbg";
|
|
|
|
rev = version;
|
2023-01-20 10:41:00 +00:00
|
|
|
sha256 = "sha256-pyY2bMasd6GaJZZjLF48SvkKUBw3XfVa0g3Q0LiEi4k=";
|
|
|
|
fetchSubmodules = true;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
nativeBuildInputs = [ makeWrapper ];
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out/share/pwndbg
|
2023-01-20 10:41:00 +00:00
|
|
|
cp -r *.py pwndbg gdb-pt-dump $out/share/pwndbg
|
2020-04-24 23:36:52 +00:00
|
|
|
chmod +x $out/share/pwndbg/gdbinit.py
|
|
|
|
makeWrapper ${gdb}/bin/gdb $out/bin/pwndbg \
|
|
|
|
--add-flags "-q -x $out/share/pwndbg/gdbinit.py" \
|
2023-01-20 10:41:00 +00:00
|
|
|
--prefix PATH : ${binPath} \
|
2020-04-24 23:36:52 +00:00
|
|
|
--set NIX_PYTHONPATH ${pythonPath}
|
|
|
|
'';
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "Exploit Development and Reverse Engineering with GDB Made Easy";
|
|
|
|
homepage = "https://github.com/pwndbg/pwndbg";
|
|
|
|
license = licenses.mit;
|
2021-03-15 08:37:03 +00:00
|
|
|
platforms = platforms.all;
|
2023-01-20 10:41:00 +00:00
|
|
|
maintainers = with maintainers; [ mic92 patryk4815 ];
|
|
|
|
# not supported on aarch64-darwin see: https://inbox.sourceware.org/gdb/3185c3b8-8a91-4beb-a5d5-9db6afb93713@Spark/
|
2022-12-17 10:02:37 +00:00
|
|
|
broken = stdenv.isDarwin && stdenv.isAarch64;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|