Skip to content

Set up VM with Ghidra

Clayton T. Morrison edited this page Oct 31, 2021 · 2 revisions

Creating Ubuntu VM for Ghidra

note: I am not sure if VirtualBox works with the new MacOS cpu (M#) architecture.

Setting up VM with Ghidra and gcc 10.1.0

  1. Download and install virtual box from https://www.virtualbox.org/wiki/Downloads. (Note: You may have to allow virtual box some permissions inside of system preferences during installation.)
  2. Download Ubuntu 20.04.3 LTS 64 bit desktop image (https://releases.ubuntu.com/20.04/).
  3. Launch Virtual Box
  4. Click the "New" button in the menu.
  5. Give it a name like "GhidraUbuntuVM"
  6. Make sure the type and version are Linux and Ubuntu 64-bit.
  7. Select the amount of memory to give it. You should select at least 4gb as that is what is required by Ghidra.
  8. Select "Create a virtual hard drive now" and then choose VDI.
  9. Select a dynamically allocated drive.
  10. Select the size of the initial disk. May be able to get by with 10GB; however, (Clay) running VirtualBox on MacOS found this to run out of space quickly and dynamic allocation does did not automatically resize -- see section on Resizing VM Disk, below.
  11. Your VM should now be created. Select it in the VirtualBox list and click start.
  12. It should now ask for a virtual optical disk file. Click the folder next to the selection box.
  13. You should now be in a window with a list of potential ISOs (this list is probably empty). Click the ADD button on the top menu bar.
  14. Using the folder window, navigate to and select the ubuntu .iso file we downloaded in step 2. Once added, select this from the iso file list and start your VM. At this point, the VM should start and initialize ubuntu.
  15. When your VM loads and is on the installation window, select install ubuntu.
  16. Select normal installation and unselect the "download ubuntu updates" option.
  17. Select erase disk and install ubuntu.
  18. This should take some time to install and then reboot. Then, you should have a VM with ubuntu on it!

If VM desktop does not resize when resizing the VM window

(Clay on MacOS): Found that desktop does not dynamically resize to fit when resizing the window. I first tried:

  1. https://help.cyberstartamerica.org/help/virtualbox-vm-screen-size-is-very-small-even-in-full-screen-mode

The above did not resolve the problem, however I suspect completing step 2 (installing the VirtualBox Extension Pack) might have helped in combination with the following:

  1. https://www.youtube.com/watch?v=Gk0NUAiK1IA

Resizing VM Disk

  1. Follow the instructions here up to 6:42 -- see if your GParted disk representation looks the same; if not, then check out next video: https://www.youtube.com/watch?v=r_UyKufXR3c
  2. If by 6:42 in the video above you find your partition information doesn't look the same (e.g., /dev/sda1 is fat32 and there is no "middle" linux swap partition in the partition plot), then try this video (this worked for Clay on MacOS): https://www.youtube.com/watch?v=rC68xA2u7Yw

Installing and running Ghidra

Prereqs

  1. Open the Ubuntu terminal
  2. Install curl via sudo apt install curl

Installing JDK via sdkman

  1. In the terminal, run curl -s "https://get.sdkman.io" | bash
  2. Then run source "$HOME/.sdkman/bin/sdkman-init.sh"
  3. Finally, install a Java 11 jdk via sdk install java 11.0.11.j9-adpt

Installing Ghidra

  1. Make a directory to install ghidra in (I just made it under ~/ghidra) and cd into it
  2. Download ghidra -- check for latest release. For example, to download 10.0.4 using curl:
curl -L -o ghidra_10.0.4_PUBLIC_20210928.zip https://github.com/NationalSecurityAgency/ghidra/releases/download/Ghidra_10.0.4_build/ghidra_10.0.4_PUBLIC_20210928.zip
  1. Inside of the same directory, run unzip ghidra_9.1.2_PUBLIC_20200212.zip
  2. cd into ghidra_9.1.2_PUBLIC_20200212 and run ./ghidraRun to start ghidra.

Additional VM Setup (gcc 10.1.0, python dev, shared folder)

Installing gcc 10.1.0

Misc dev

sudo apt install git

Installing Python (3.9) and python virtual environment

Install the latest Python 3.9

sudo apt update && sudo apt upgrade
sudo apt install python3.9
sudo apt install python3.9-dev  # needed to get Python.h in the right place, for, e.g., pygraphviz

Install Python venv

sudo apt install python3.9-venv

NOTE: on kraken, I also had to additionally install the following so that pygraphviz could install:

sudo apt install libgraphviz-dev

If you don't already have a place to store your virtual envs

mkdir ~/.python_venv

Create a Python3.9 virtual environment

python3.9 -m venv ~/.python_venv/<my_env>

Activate venv

source ~/.python_venv/<my_env>/bin/activate

Setting up VirtualBox shared folder

Following instructions here: https://gist.github.com/estorgio/1d679f962e8209f8a9232f7593683265

NOTE: Encountered differences in steps (with VirtualBox 6.1):

  1. The Guest Additions CD image was already mounted as: /media/claytonm/VBox_GAs_6.1.26
  2. skipped due to 9
  3. build-essential already installed (when installing gcc-10.1)
  4. Continue with this step, but using different path: sudo /media/claytonm/VBox_GAs_6.1.26/./VBoxLinuxAdditions.run

After this, followed from steps 13 onward

  1. In step 6 I had named by folder VirtualBox_shared_folder, so in this step, the command was: sudo mount -t vboxsf VirtualBox_shared_folder ~/shared

Everything beyond 15., including making the mount folder persistent by editing fstab and modules worked!

Ghidra Plugin notes

TODO

Clone this wiki locally