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

cleanup some ghidra scripts #7521

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
//@__params_start
//@category Examples
//@toolbar world.png
//@menupath Tools.Scripts Manager.Add Comment To Program Script
//@__params_end

import ghidra.app.script.GhidraScript;
import ghidra.program.model.address.Address;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@
*/
//With cursor on switch's "add pc, .." command, this script will add references on the switch offset table to corresponding code.
//Make sure your table consists of defined data (db,dw,etc).
//@__params_start
//@category ARM
//@toolbar world.png
//@menupath Tools.Scripts Manager.Add References In Switch Table
//@__params_end

/*
* This script has 2 preconditions:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@
*/
//With a user-input base address, this script will add a reference on the current switch table entry to corresponding code
//Make sure your table entry is defined data (db,dw,etc).
//@__params_start
//@category ARM
//@toolbar world.png
//@menupath Tools.Scripts Manager.Add Single Reference In Switch Table
//@__params_end

import ghidra.app.script.GhidraScript;
import ghidra.program.model.address.Address;
Expand Down
5 changes: 5 additions & 0 deletions Ghidra/Features/Base/ghidra_scripts/AddSourceFileScript.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@
* limitations under the License.
*/
// Adds a SourceFile with a user-defined path and name to the program.
//@__params_start
//@category SourceMapping
//@toolbar world.png
//@menupath Tools.Scripts Manager.Add Source File Script
//@__params_end

import java.util.HexFormat;

import org.apache.commons.lang3.StringUtils;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@
// Add a source map entry for the current selection.
// The current selection must consist of a single address range.
// If there is no selection, a length 0 entry will be added at the current address.
//@__params_start
//@category SourceMapping
//@toolbar world.png
//@menupath Tools.Scripts Manager.Add Source Map Entry Script
//@__params_end

import java.util.*;

import ghidra.app.script.GhidraScript;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@
//this script will create data structures
//representing the AppleSingleDouble header and
//the containing entry descriptors.
//@__params_start
//@category Binary
//@toolbar world.png
//@menupath Tools.Scripts Manager.Apple Single Double Script
//@__params_end

import ghidra.app.cmd.formats.AppleSingleDoubleBinaryAnalysisCommand;
import ghidra.app.script.GhidraScript;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@
* limitations under the License.
*/
//Makes functions out of a run of selected ARM or Thumb function pointers
//@category ARM

//@__params_start
//@category ARM
//@toolbar world.png
//@menupath Tools.Scripts Manager.Arm Thumb Function Table Script
//@__params_end

import ghidra.app.plugin.core.clear.ClearFlowAndRepairCmd;
import ghidra.app.script.GhidraScript;
Expand Down
4 changes: 4 additions & 0 deletions Ghidra/Features/Base/ghidra_scripts/AsciiToBinaryScript.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@
* limitations under the License.
*/
//Converts an ascii hex file into binary file. Works for files with spaces and without. Assumes hex bytes are zero padded so all values are two bytes long.
//@__params_start
//@category Conversion
//@toolbar world.png
//@menupath Tools.Scripts Manager.Ascii To Binary Script
//@__params_end

import ghidra.app.script.GhidraScript;

Expand Down
4 changes: 4 additions & 0 deletions Ghidra/Features/Base/ghidra_scripts/AskScript.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@
//An example of asking for user input.
//Note the ability to pre-populate values for some of these variables when AskScript.properties file exists.
//Also notice how the previous input is saved.
//@__params_start
//@category Examples
//@toolbar world.png
//@menupath Tools.Scripts Manager.Ask Script
//@__params_end

import java.io.File;
import java.util.Arrays;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@
* limitations under the License.
*/
// Example script for showing how to use the "AskValues" script method for inputting multiple values
// @category Examples
//@__params_start
//@category Examples
//@toolbar world.png
//@menupath Tools.Scripts Manager.Ask Values Example Script
//@__params_end

import ghidra.app.script.GhidraScript;
import ghidra.features.base.values.GhidraValuesMap;
import ghidra.program.model.listing.Program;
Expand Down
4 changes: 4 additions & 0 deletions Ghidra/Features/Base/ghidra_scripts/AssembleBlockScript.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@
* limitations under the License.
*/
//Assemble hard-coded block of instructions.
//@__params_start
//@category Assembly
//@toolbar world.png
//@menupath Tools.Scripts Manager.Assemble Block Script
//@__params_end

import ghidra.app.plugin.assembler.Assembler;
import ghidra.app.plugin.assembler.Assemblers;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@
* limitations under the License.
*/
//Test assembly of the instruction under the cursor.
//@__params_start
//@category Assembly
//@keybinding CTRL-H
//@toolbar world.png
//@menupath Tools.Scripts Manager.Assemble Check Dev Script
//@__params_end

import ghidra.app.plugin.assembler.Assembler;
import ghidra.app.plugin.assembler.Assemblers;
Expand Down
4 changes: 4 additions & 0 deletions Ghidra/Features/Base/ghidra_scripts/AssembleScript.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@
* limitations under the License.
*/
//Assemble a single instruction, overwriting the one at the cursor.
//@__params_start
//@category Assembly
//@toolbar world.png
//@menupath Tools.Scripts Manager.Assemble Script
//@__params_end

import ghidra.app.plugin.assembler.Assembler;
import ghidra.app.plugin.assembler.Assemblers;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@
*/
//Thoroughly test the assembler by attempting to assemble and match EVERY instruction code unit.
//NOTE: I do not de-duplicate, since the address of the instruction may affect the output.
//@__params_start
//@category Assembly
//@toolbar world.png
//@menupath Tools.Scripts Manager.Assembly Thrasher Dev Script
//@__params_end

import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@
// script only works on Windows PE programs. The script will only work if the libraries have already
// been imported to the project. If it finds more than one match, it will notify the user and use
// the first found match.
//@__params_start
//@toolbar world.png
//@menupath Tools.Scripts Manager.Associate External P E Libraries Script
//@__params_end

import java.util.*;

import ghidra.app.script.GhidraScript;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@
*/
//Renames default labels in a selected region, using
//a user-defined stub and a one-up naming convention.
//@__params_start
//@category Symbol
//@toolbar world.png
//@menupath Tools.Scripts Manager.Auto Rename Labels Script
//@__params_end

import ghidra.app.cmd.label.RenameLabelCmd;
import ghidra.app.script.GhidraScript;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,12 @@
//USER_DEFINED or IMPORTED).
//
//Feel free to add any other rules!
//
//
//@__params_start
//@category Symbol
//@toolbar world.png
//@menupath Tools.Scripts Manager.Auto Rename Simple Labels
//@__params_end

import ghidra.app.script.GhidraScript;
import ghidra.program.model.address.Address;
Expand Down
5 changes: 4 additions & 1 deletion Ghidra/Features/Base/ghidra_scripts/BatchRename.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@
* limitations under the License.
*/
//Recursively finds a folder that matches a string and renames it to a new name.
//@__params_start
//@category Project
//@menupath
//@toolbar world.png
//@menupath Tools.Scripts Manager.Batch Rename
//@__params_end

import ghidra.app.script.GhidraScript;
import ghidra.framework.model.DomainFolder;
Expand Down
7 changes: 5 additions & 2 deletions Ghidra/Features/Base/ghidra_scripts/BatchSegregate64bit.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
//Separates co-mingled n-bit and 64-bit binaries into two folder trees.
//Separates co-mingled n-bit and 64-bit binaries into two folder trees.
//@__params_start
//@category Project
//@menupath
//@toolbar world.png
//@menupath Tools.Scripts Manager.Batch Segregate64bit
//@__params_end

import java.io.IOException;
import java.util.Map;
Expand Down
4 changes: 4 additions & 0 deletions Ghidra/Features/Base/ghidra_scripts/BinaryToAsciiScript.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@
* limitations under the License.
*/
//Converts a binary file into an ascii hex file.
//@__params_start
//@category Conversion
//@toolbar world.png
//@menupath Tools.Scripts Manager.Binary To Ascii Script
//@__params_end

import ghidra.app.script.GhidraScript;
import ghidra.util.Conv;
Expand Down
4 changes: 4 additions & 0 deletions Ghidra/Features/Base/ghidra_scripts/BuildGhidraJarScript.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@
* limitations under the License.
*/
//An example of building a single minimal Ghidra jar file.
//@__params_start
//@category Examples
//@toolbar world.png
//@menupath Tools.Scripts Manager.Build Ghidra Jar Script
//@__params_end

import java.io.File;
import java.util.List;
Expand Down
6 changes: 5 additions & 1 deletion Ghidra/Features/Base/ghidra_scripts/COFF_ArchiveScript.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,16 @@
* limitations under the License.
*/
//Given a raw binary COFFArchive image
//(specifically a .lib file),
//(specifically a .lib file),
//this script will create data structures
//representing the archive header. Including,
//but not limited to, the archive member header,
//the first linker member, etc.
//@__params_start
//@category Binary
//@toolbar world.png
//@menupath Tools.Scripts Manager.C O F F_ Archive Script
//@__params_end

import ghidra.app.cmd.formats.CoffArchiveBinaryAnalysisCommand;
import ghidra.app.script.GhidraScript;
Expand Down
4 changes: 4 additions & 0 deletions Ghidra/Features/Base/ghidra_scripts/COFF_Script.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@
//representing the COFF header. Including,
//but not limited to, the file header,
//section headers, optional header, etc.
//@__params_start
//@category Binary
//@toolbar world.png
//@menupath Tools.Scripts Manager.C O F F_ Script
//@__params_end

import ghidra.app.cmd.formats.CoffBinaryAnalysisCommand;
import ghidra.app.script.GhidraScript;
Expand Down
4 changes: 4 additions & 0 deletions Ghidra/Features/Base/ghidra_scripts/CallAnotherScript.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@
* limitations under the License.
*/
//Example of a script calling another script.
//@__params_start
//@category Examples.Demo
//@toolbar world.png
//@menupath Tools.Scripts Manager.Call Another Script
//@__params_end

import ghidra.app.script.GhidraScript;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@
*/
// Shows how to run a script on all of the programs within the current project.
// NOTE: Script will only process unversioned and checked-out files.
//@__params_start
//@category Examples
//@toolbar world.png
//@menupath Tools.Scripts Manager.Call Another Script For All Programs
//@__params_end

import java.io.IOException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,13 @@
* limitations under the License.
*/
// Produces a list of instructions whose pcode contains a CALLOTHER pcode op. The list is
// sorted by number of occurrences of an instruction. When run headlessly, the list is displayed
// sorted by number of occurrences of an instruction. When run headlessly, the list is displayed
// each time a program is processed and the counts are cumulative.
//@__params_start
// @category sleigh
//@toolbar world.png
//@menupath Tools.Scripts Manager.Callother Census Script
//@__params_end

import java.util.HashMap;
import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@
*/
//Changes the dsiplay settings of the current data
//from hex to decimal.
//@__params_start
//@category Examples
//@toolbar world.png
//@menupath Tools.Scripts Manager.Change Data Settings Script
//@__params_end

import ghidra.app.script.GhidraScript;
import ghidra.docking.settings.FormatSettingsDefinition;
Expand Down
4 changes: 4 additions & 0 deletions Ghidra/Features/Base/ghidra_scripts/ChooseDataTypeScript.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@
* limitations under the License.
*/
//Example of a script prompting the user for a data type.
//@__params_start
//@category Examples.Demo
//@toolbar world.png
//@menupath Tools.Scripts Manager.Choose Data Type Script
//@__params_end

import ghidra.app.script.GhidraScript;
import ghidra.app.util.datatype.DataTypeSelectionDialog;
Expand Down
4 changes: 4 additions & 0 deletions Ghidra/Features/Base/ghidra_scripts/ClearOrphanFunctions.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@
* limitations under the License.
*/
//Clears any functions that are not xref'd
//@__params_start
//@category Symbol
//@toolbar world.png
//@menupath Tools.Scripts Manager.Clear Orphan Functions
//@__params_end

import ghidra.app.script.GhidraScript;
import ghidra.program.model.listing.Function;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@
* limitations under the License.
*/
//Script to compare analysis between current and chosen program.
//@__params_start
//@category Analysis
//@toolbar world.png
//@menupath Tools.Scripts Manager.Compare Analysis Script
//@__params_end

import java.util.Iterator;

Expand Down
4 changes: 4 additions & 0 deletions Ghidra/Features/Base/ghidra_scripts/CompareGDTs.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@
// Also indicate where the same named data type has a different type. This doesn't indicate
// where the internal contents of the same named data types differ.
//
//@__params_start
//@category Data Types
//@toolbar world.png
//@menupath Tools.Scripts Manager.Compare G D Ts
//@__params_end

import java.io.File;
import java.io.PrintWriter;
Expand Down
Loading