Ruby Dragon adds an interactive Java shell to Ghidra for use in script development and running snippets of Java.
This is accomplished using JShell, which is included in Java.
The JShell interactive interpreter runs as a simple Java REPL. The same variables that are available in Ghidra's Java and Python environments are also available in the JShell interpreter as global variables. There are also some extra variables for commonly needed values such as the current function.
currentAddress currentData currentFunction currentHighlight currentInstruction currentLocation currentProgram currentSelectionThere is also an extra variable named currentAPI which provides an instance of FlatProgramAPI created using currentProgram. This provides many (though not all) convenience functions available in a GhidraScript instance.
Copy and paste from within the JShell interpreter should work as expected for your given environment:
- Windows: CTRL+C / CTRL+V
- Linux: CTRL+C / CTRL+V
- OS X: COMMAND+C / COMMAND+V

This command clears the interpreter's display. Its effect is purely visual. It does not affect the state of the interpreter in any way.

This command issues a stop action to the interpreter, which can be used to interrupt long running commands or loops.

This command resets the interpreter, which clears the display and resets all state.
When this option is set to true, a number of Ghidra classes are imported in the JShell interactive interpreter automatically. This is particularly useful when using snippets copied from other sources or scripts, so that import statements are not needed to have access to Ghidra classes.
The list of classes (and their containing packages) is in a data file included in this extension's data folder named auto-import.xml. If you wish to add or remove classes from this list, edit this file and reset the interpeter. Note that changes to this file will affect the classes imported by all Ruby Dragon interpreters, not just JShell.
Provided by: JShellDragon