From 631faad148e516973554b78158cdded0976f574b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6gler?= Date: Wed, 6 Mar 2019 13:00:07 +0100 Subject: [PATCH 1/2] initial ghidra-9.0 I tested basic usage of tool CodeBrowser. The tool VersionTracking raises an error. --- pkgs/tools/security/ghidra/default.nix | 54 ++++++++++++++++++++++++++ pkgs/top-level/all-packages.nix | 2 + 2 files changed, 56 insertions(+) create mode 100644 pkgs/tools/security/ghidra/default.nix diff --git a/pkgs/tools/security/ghidra/default.nix b/pkgs/tools/security/ghidra/default.nix new file mode 100644 index 000000000000..1b62741f2a5d --- /dev/null +++ b/pkgs/tools/security/ghidra/default.nix @@ -0,0 +1,54 @@ +{ stdenv, fetchurl, unzip, lib, makeWrapper, patchelf +, openjdk11, pam +}: let + + pkg_path = "$out/lib/ghidra"; + +in stdenv.mkDerivation { + + name = "ghidra-9.0"; + + src = fetchurl { + url = https://ghidra-sre.org/ghidra_9.0_PUBLIC_20190228.zip; + sha256 = "3b65d29024b9decdbb1148b12fe87bcb7f3a6a56ff38475f5dc9dd1cfc7fd6b2"; + }; + + nativeBuildInputs = [ + makeWrapper + patchelf + unzip + ]; + + dontStrip = true; + + postPatch = '' + for f in Ghidra/Features/Decompiler/os/linux64/* GPL/DemanglerGnu/os/linux64/*; do + patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \ + --set-rpath "${stdenv.cc.libc}/lib:${stdenv.cc.cc.lib}/lib" "$f" + done + + for f in Ghidra/Features/GhidraServer/os/linux64/*; do + patchelf --set-rpath "${stdenv.cc.libc}/lib:${pam}/lib" "$f" + done + ''; + + installPhase = '' + mkdir -p "${pkg_path}" + cp -a * "${pkg_path}" + ''; + + postFixup = '' + mkdir -p "$out/bin" + makeWrapper "${pkg_path}/ghidraRun" "$out/bin/ghidra" \ + --prefix PATH : ${lib.makeBinPath [ openjdk11 ]} + ''; + + meta = with lib; { + description = "A software reverse engineering (SRE) suite of tools developed by NSA's Research Directorate in support of the Cybersecurity mission"; + homepage = "https://ghidra-sre.org/"; + platforms = [ "x86_64-linux" ]; + license = licenses.asl20; + maintainers = [ maintainers.ck3d ]; + }; + +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 696bc52e4dee..4d029b659a14 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -1447,6 +1447,8 @@ in gh-ost = callPackage ../tools/misc/gh-ost { }; + ghidra-bin = callPackage ../tools/security/ghidra { }; + gif-for-cli = callPackage ../tools/misc/gif-for-cli { }; gist = callPackage ../tools/text/gist { }; From 2385d153bab79e1919e4c3040b3263961cf3a042 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6gler?= Date: Wed, 13 Mar 2019 22:03:40 +0100 Subject: [PATCH 2/2] ghidra: use autoPatchelfHook --- pkgs/tools/security/ghidra/default.nix | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/pkgs/tools/security/ghidra/default.nix b/pkgs/tools/security/ghidra/default.nix index 1b62741f2a5d..71cda94d5f8a 100644 --- a/pkgs/tools/security/ghidra/default.nix +++ b/pkgs/tools/security/ghidra/default.nix @@ -1,4 +1,4 @@ -{ stdenv, fetchurl, unzip, lib, makeWrapper, patchelf +{ stdenv, fetchurl, unzip, lib, makeWrapper, autoPatchelfHook , openjdk11, pam }: let @@ -15,23 +15,17 @@ in stdenv.mkDerivation { nativeBuildInputs = [ makeWrapper - patchelf + autoPatchelfHook unzip ]; + buildInputs = [ + stdenv.cc.cc.lib + pam + ]; + dontStrip = true; - postPatch = '' - for f in Ghidra/Features/Decompiler/os/linux64/* GPL/DemanglerGnu/os/linux64/*; do - patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \ - --set-rpath "${stdenv.cc.libc}/lib:${stdenv.cc.cc.lib}/lib" "$f" - done - - for f in Ghidra/Features/GhidraServer/os/linux64/*; do - patchelf --set-rpath "${stdenv.cc.libc}/lib:${pam}/lib" "$f" - done - ''; - installPhase = '' mkdir -p "${pkg_path}" cp -a * "${pkg_path}"