Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

initial ghidra-9.0 #56959

Merged
merged 2 commits into from Mar 14, 2019
Merged

initial ghidra-9.0 #56959

merged 2 commits into from Mar 14, 2019

Conversation

ck3d
Copy link
Contributor

@ck3d ck3d commented Mar 6, 2019

I tested basic usage of tool CodeBrowser.
The tool VersionTracking raises an error.

Motivation for this change
Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Assured whether relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@grahamc
Copy link
Member

grahamc commented Mar 7, 2019

I wonder if we should wait for its source to be public?

@Mic92
Copy link
Member

Mic92 commented Mar 13, 2019

@deliciouslytyped sent me this example using autoPatchelfHook: https://bpaste.net/show/1a7ad6fa151e
which is slightly shorter.

@Mic92
Copy link
Member

Mic92 commented Mar 13, 2019

I think we could merge this earlier given that all binaries are unstripped and the whole security community have throw their attention on this tool.

@Mic92 Mic92 mentioned this pull request Mar 13, 2019
@deliciouslytyped
Copy link
Contributor

deliciouslytyped commented Mar 13, 2019

This is just something I threw together but it works.
@Mic92 I think that link will expire so here's the snippet for posterity;

{pkgs ? import (
  builtins.fetchGit { #need jdk11, just the latest nixpkgs at the time
    url = https://github.com/nixos/nixpkgs/;
    rev = "5d3fd3674a66c5b1ada63e2eace140519849c967";
    }
  ) {}}:
with pkgs;
  stdenv.mkDerivation {
    name = "ghidra";
    version = "";

    src = fetchurl {
      url = "https://ghidra-sre.org/ghidra_9.0_PUBLIC_20190228.zip";
      sha256 = "1cnngzy1rpf9bmglff7zarm3lzybggl2zca826xwvpmr4j8d4r9v";
      };

    nativeBuildInputs = [ makeWrapper autoPatchelfHook unzip ];
    propagatedBuildInputs = [ pkgs.jdk11 stdenv.cc.cc.lib linux-pam ];

    installPhase = ''
      mkdir -p $out
      cp -r ./ $out

      wrapProgram "$out"/ghidraRun --prefix PATH : "${jdk}/bin/"
      '';
    }

I ran the coreutils cat binary through the automatic analysis and everything seemed to work with autoPatchelfHook, before that the decompiler was complaining (which is fine given that its an ELF).

@grahamc
Copy link
Member

grahamc commented Mar 13, 2019 via email

@timokau
Copy link
Member

timokau commented Mar 13, 2019

I would still rather wait for a source release or name it ghidra-bin for now. As a user I would be very surprised to learn that I just installed binaries straight from the nsa.

description = "A software reverse engineering (SRE) suite of tools developed by NSA's Research Directorate in support of the Cybersecurity mission";
platforms = [ "x86_64-linux" ];
license = licenses.asl20;
maintainers = [ maintainers.ck3d ];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could also include the homepage.

@deliciouslytyped
Copy link
Contributor

Or ghidra-bin-nsa even? ;)

@jtojnar
Copy link
Contributor

jtojnar commented Mar 13, 2019

Maybe we want to disable the RCE:

https://twitter.com/hackerfantastic/status/1103087869063704576

@deliciouslytyped
Copy link
Contributor

deliciouslytyped commented Mar 13, 2019

I really can't help but start the bikeshed that that's not an RCE, but sure I don't see why we can't make it default to not exposing it over the regular network, but people should ideally have a firewall running anyway?

(edit: wording)

@deliciouslytyped
Copy link
Contributor

deliciouslytyped commented Mar 13, 2019

edit/clarification: this is just the java stuff I think
There actually seem to be source code archives in most libdirectories. I don`t know how much coverage there is.

find . -iname "*-src*"   
./Ghidra/Framework/Generic/lib/Generic-src.zip
./Ghidra/Framework/Help/lib/Help-src.zip
./Ghidra/Framework/Utility/lib/Utility-src.zip
./Ghidra/Framework/Docking/lib/Docking-src.zip
./Ghidra/Framework/FileSystem/lib/FileSystem-src.zip
./Ghidra/Framework/Project/lib/Project-src.zip
./Ghidra/Framework/SoftwareModeling/lib/SoftwareModeling-src.zip
./Ghidra/Framework/Demangler/lib/Demangler-src.zip
./Ghidra/Framework/DB/lib/DB-src.zip
./Ghidra/Framework/Graph/lib/Graph-src.zip
./Ghidra/Processors/Toy/lib/Toy-src.zip
./Ghidra/Processors/PowerPC/lib/PowerPC-src.zip
./Ghidra/Processors/AARCH64/lib/AARCH64-src.zip
./Ghidra/Processors/MIPS/lib/MIPS-src.zip
./Ghidra/Processors/ARM/lib/ARM-src.zip
./Ghidra/Processors/PIC/lib/PIC-src.zip
./Ghidra/Processors/DATA/lib/DATA-src.zip
./Ghidra/Processors/68000/lib/68000-src.zip
./Ghidra/Processors/Atmel/lib/Atmel-src.zip
./Ghidra/Processors/x86/lib/x86-src.zip
./Ghidra/Processors/JVM/lib/JVM-src.zip
./Ghidra/Processors/Sparc/lib/Sparc-src.zip
./Ghidra/Features/MicrosoftDmang/lib/MicrosoftDmang-src.zip
./Ghidra/Features/DecompilerDependent/lib/DecompilerDependent-src.zip
./Ghidra/Features/FileFormats/lib/FileFormats-src.zip
./Ghidra/Features/ByteViewer/lib/ByteViewer-src.zip
./Ghidra/Features/PDB/lib/PDB-src.zip
./Ghidra/Features/Recognizers/lib/Recognizers-src.zip
./Ghidra/Features/ProgramDiff/lib/ProgramDiff-src.zip
./Ghidra/Features/FunctionID/lib/FunctionID-src.zip
./Ghidra/Features/DebugUtils/lib/DebugUtils-src.zip
./Ghidra/Features/MicrosoftCodeAnalyzer/lib/MicrosoftCodeAnalyzer-src.zip
./Ghidra/Features/FunctionGraphDecompilerExtension/lib/FunctionGraphDecompilerExtension-src.zip
./Ghidra/Features/GhidraServer/data/jaas-modules-src-1.0.3.zip
./Ghidra/Features/GhidraServer/lib/GhidraServer-src.zip
./Ghidra/Features/Python/data/python-src
./Ghidra/Features/Python/lib/Python-src.zip
./Ghidra/Features/Base/lib/Base-src.zip
./Ghidra/Features/MicrosoftDemangler/lib/MicrosoftDemangler-src.zip
./Ghidra/Features/GnuDemangler/lib/GnuDemangler-src.zip
./Ghidra/Features/GraphFunctionCalls/lib/GraphFunctionCalls-src.zip
./Ghidra/Features/BytePatterns/lib/BytePatterns-src.zip
./Ghidra/Features/Decompiler/lib/Decompiler-src.zip
./Ghidra/Features/SourceCodeLookup/lib/SourceCodeLookup-src.zip
./Ghidra/Features/FunctionGraph/lib/FunctionGraph-src.zip
./Ghidra/Features/VersionTracking/lib/VersionTracking-src.zip

of course...that by itself isn`t going to get anyone a build.

@timokau
Copy link
Member

timokau commented Mar 13, 2019

As far as I've heard the java source is given but the native code (decompiler) and build system is not.

@deliciouslytyped
Copy link
Contributor

Yeah that seems correct.

@ck3d
Copy link
Contributor Author

ck3d commented Mar 13, 2019

Thanks for the comments, I changed attribute name to ghidra-bin, added homepage and using autoPatchelfHook.

@deliciouslytyped
Copy link
Contributor

I think the proper home page is ghidra-sre.org ?

I tested basic usage of tool CodeBrowser.
The tool VersionTracking raises an error.
@ck3d
Copy link
Contributor Author

ck3d commented Mar 13, 2019

Thanks, I updated homepage

@deliciouslytyped
Copy link
Contributor

So, I haven't looked at this part much, so I don't know how it will interact with nix-y stuff, there's plugin support for eclipse, for the scripting stuff (see the scripting tutorial in the docs folder), is there anything that we should do to get that to work?

@Mic92 Mic92 merged commit 8f9e283 into NixOS:master Mar 14, 2019
@deliciouslytyped
Copy link
Contributor

The ghidraDev plugin works with a sufficiently new eclipse (4.10 I think?), which can be retrieved from a sufficiently new nixpkgs. There is a gdk problem currently causing a lot of segfaults, which is worked around by the unset.

unset GDK_PIXBUF_MODULE_FILE; nix-shell -I "nixpkgs=https://github.com/NixOS/nixpkgs-channels/archive/nixos-unstable.tar.gz" -p eclipses.eclipse-java

This was referenced Mar 26, 2019
@deliciouslytyped
Copy link
Contributor

Ghidra source appears to have been properly released.

@deliciouslytyped
Copy link
Contributor

Which is to say, I don't think I have the spare cycles to work on packaging that now so I'm sticking to the binaries for the moment. @ck3d ?

@deliciouslytyped
Copy link
Contributor

I seem to have successfully made a working plugin system, I should be filing a PR in the coming days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants