diff --git a/pkgs/reverse-engineering/ghidra/build.nix b/pkgs/reverse-engineering/ghidra/build.nix index 4407d52..e0aabbb 100644 --- a/pkgs/reverse-engineering/ghidra/build.nix +++ b/pkgs/reverse-engineering/ghidra/build.nix @@ -251,6 +251,23 @@ stdenv.mkDerivation (finalAttrs: { ; withExtensions = callPackage ./with-extensions.nix { ghidra = finalAttrs.finalPackage; }; + + pythonPackages = rec { + ghidratrace = python3Packages.callPackage ./python/ghidratrace.nix { + ghidra = finalAttrs.finalPackage; + }; + ghidragdb = python3Packages.callPackage ./python/ghidragdb.nix { + ghidra = finalAttrs.finalPackage; + inherit ghidratrace; + }; + ghidralldb = python3Packages.callPackage ./python/ghidralldb.nix { + ghidra = finalAttrs.finalPackage; + inherit ghidratrace; + }; + pyghidra = python3Packages.callPackage ./python/pyghidra.nix { + ghidra = finalAttrs.finalPackage; + }; + }; }; meta = with lib; { @@ -269,10 +286,6 @@ stdenv.mkDerivation (finalAttrs: { binaryBytecode # deps ]; license = licenses.asl20; - maintainers = with maintainers; [ - roblabla - vringar - ]; broken = stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isx86_64; }; }) diff --git a/pkgs/reverse-engineering/ghidra/python/ghidragdb.nix b/pkgs/reverse-engineering/ghidra/python/ghidragdb.nix new file mode 100644 index 0000000..19f3d73 --- /dev/null +++ b/pkgs/reverse-engineering/ghidra/python/ghidragdb.nix @@ -0,0 +1,40 @@ +{ + lib, + python, + buildPythonPackage, + + ghidra, + + setuptools, + + psutil, + ghidratrace, +}: buildPythonPackage { + pname = "ghidragdb"; + version = "11.3"; + pyproject = true; + + src = "${ghidra.lib}/lib/ghidra/Ghidra/Debug/Debugger-agent-gdb/pypkg"; + + postPatch = '' + rm -rf dist + ''; + + build-system = [ + setuptools + ]; + + dependencies = [ + ghidratrace + psutil + ]; + + # can't import because gdb is missing + # pythonImportsCheck = [ + # "ghidragdb" + # ]; + + meta = (lib.removeAttrs ghidra.meta ["description" "mainProgram"]) // { + description = "Ghidra's Plugin for gdb"; + }; +} diff --git a/pkgs/reverse-engineering/ghidra/python/ghidralldb.nix b/pkgs/reverse-engineering/ghidra/python/ghidralldb.nix new file mode 100644 index 0000000..d477cb9 --- /dev/null +++ b/pkgs/reverse-engineering/ghidra/python/ghidralldb.nix @@ -0,0 +1,40 @@ +{ + lib, + python, + buildPythonPackage, + + ghidra, + + setuptools, + + psutil, + ghidratrace, +}: buildPythonPackage { + pname = "ghidralldb"; + version = "11.3"; + pyproject = true; + + src = "${ghidra.lib}/lib/ghidra/Ghidra/Debug/Debugger-agent-lldb/pypkg"; + + postPatch = '' + rm -rf dist + ''; + + build-system = [ + setuptools + ]; + + dependencies = [ + ghidratrace + psutil + ]; + + # can't import because lldb is missing + # pythonImportsCheck = [ + # "ghidralldb" + # ]; + + meta = (lib.removeAttrs ghidra.meta ["description" "mainProgram"]) // { + description = "Ghidra's Plugin for lldb"; + }; +} diff --git a/pkgs/reverse-engineering/ghidra/python/ghidratrace.nix b/pkgs/reverse-engineering/ghidra/python/ghidratrace.nix new file mode 100644 index 0000000..77f8436 --- /dev/null +++ b/pkgs/reverse-engineering/ghidra/python/ghidratrace.nix @@ -0,0 +1,46 @@ +{ + lib, + python, + buildPythonPackage, + pythonRelaxDepsHook, + + ghidra, + + setuptools, + + protobuf, +}: buildPythonPackage { + pname = "ghidratrace"; + version = "11.3"; + pyproject = true; + + src = "${ghidra.lib}/lib/ghidra/Ghidra/Debug/Debugger-rmi-trace/pypkg"; + + postPatch = '' + rm -rf dist + ''; + + build-system = [ + setuptools + ]; + + dependencies = [ + protobuf + ]; + + nativeBuildInputs = [ + pythonRelaxDepsHook + ]; + + pythonRelaxDeps = [ + "protobuf" + ]; + + pythonImportsCheck = [ + "ghidratrace" + ]; + + meta = (lib.removeAttrs ghidra.meta ["description" "mainProgram"]) // { + description = "Ghidra's TraceRmi for Python3"; + }; +} diff --git a/pkgs/reverse-engineering/ghidra/python/pyghidra.nix b/pkgs/reverse-engineering/ghidra/python/pyghidra.nix new file mode 100644 index 0000000..4c19dd0 --- /dev/null +++ b/pkgs/reverse-engineering/ghidra/python/pyghidra.nix @@ -0,0 +1,43 @@ +{ + lib, + python, + buildPythonPackage, + + ghidra, + + setuptools, + + jpype1, +}: buildPythonPackage { + pname = "pyghidra"; + version = "2.1.0"; + pyproject = true; + + src = "${ghidra.lib}/lib/ghidra/Ghidra/Features/PyGhidra/pypkg"; + + # TODO: make a more involved wrapper or patch this package to change the launch system + # TODO: support launching a ghidra-with-extensions package + makeWrapperArgs = [ + "--set" "GHIDRA_INSTALL_DIR" "${ghidra.lib}/lib/ghidra" + ]; + + postPatch = '' + rm -rf dist + ''; + + build-system = [ + setuptools + ]; + + dependencies = [ + jpype1 + ]; + + pythonImportsCheck = [ + "pyghidra" + ]; + + meta = (lib.removeAttrs ghidra.meta ["description" "mainProgram"]) // { + description = "Native CPython for Ghidra"; + }; +}