Search Overview
Ghidra provides powerful search capabilities to locate code patterns, data values, text strings, and program elements.The
SearchTextPlugin provides comprehensive search functionality for program text, while specialized plugins handle memory, instructions, and other search types.Search Types
- Program Text
- Memory
- Instructions
- Scalars
Search displayed text in listing:
- Searches rendered fields
- Comments, labels, mnemonics
- Regular expression support
- Database search or display match
Program Text Search
Basic Text Search
Open Search Dialog
Access text search:
Search>Program Text- Press
Ctrl + Shift + E - Implemented by
SearchTextPlugin
Enter Search String
Configure search:
- Type search text
- Choose search fields
- Set options (case sensitive, regex)
Search Options
- Search Fields
- Search Modes
- Regular Expressions
- Case Sensitivity
Select fields to search:
- Instruction Mnemonics: Assembly instructions
- Instruction Operands: Instruction arguments
- Data Mnemonics: Data type names
- Data Operands: Data values
- Comments: All comment types
- Labels: Symbol names
- Functions: Function names
Search Scope
Set Search Range
Define where to search:
- All Blocks: Entire program
- Selection: Current selection only
- Current Block: Active memory block
- Custom Range: Specify addresses
Search Results
View Results Table
Results displayed in table:
- Uses
ProgramDatabaseSearchTableModel - Columns: Location, Preview, Type
- Sortable and filterable
Navigate Results
Use the results:
- Double-click to jump to location
- Select multiple for bulk operations
- Export results to file
Memory Search
Byte Pattern Search
Enter Pattern
Define byte pattern:
- Hexadecimal bytes (e.g.,
48 8B 45 F8) - Wildcards:
?for nibble,..for byte - Example:
48 8B ?? ??matches MOV with any operands
Advanced Memory Search
- String Search
- Value Search
- Regex Memory Search
Find string values:
- Enter text string
- Specify encoding (ASCII, Unicode)
- Automatically converted to bytes
- Null terminator optional
Memory search is case-sensitive for byte patterns. Use appropriate byte values for ASCII text searches.
Instruction Search
Instruction Pattern Search
Open Instruction Search
Access instruction search:
- Implemented by
InstructionSearchPlugin Search>Instruction Patterns- Opens
InstructionSearchDialog
Build Pattern
Create instruction pattern:
- Add instruction criteria
- Specify mnemonics
- Define operand constraints
- Set sequence requirements
Mnemonic Search Scripts
Script-based mnemonic searches:- Mnemonics Only
- Mnemonics with Operands
- Mnemonics with Constants
SearchMnemonicsNoOpsNoConstScript.java:- Search instruction mnemonics only
- No operand matching
- Fast basic search
YARA Integration
YARA rule-based searching:- Use
InstructionSearchApi_Yara.java - Define YARA rules
- Apply to instruction patterns
- Advanced malware analysis
Scalar Search
Finding Scalar Values
Image Base Offsets
Search for relocated addresses:- Use
SearchForImageBaseOffsetsScript.java - Finds values that are image base + offset
- Identifies potential addresses
- Helps with position-independent code
Label and Symbol Search
Finding Labels
Search by Address
Specialized Searches
Function Search
- Function Window
- Function Selection
Search all functions:
Window>Functions- Filter by name, size, location
- Sort by various criteria
- Export function lists
Data Type Search
Search Data Type Manager
Find types:
- Open Data Type Manager
- Use search field
- Filter by name or category
Equate Search
Find equate usage:- Use
ShowEquatesInSelectionScript.java - Displays all equates in range
- Helps understand constants
Search Performance
Optimizing Searches
- Database vs Display
- Narrow Scope
- Progressive Search
Choose appropriate mode:
- Database: Fast, limited fields
- Display: Slow, comprehensive
- Use database when possible
Search Integration
Combining Searches
Multiple Criteria
Layer search results:
- Perform first search
- Create selection from results
- Search within selection
- Iteratively narrow results
Search and Replace
Bulk modifications:ReplaceInComments.javascript- Text replacement in comments
- Batch symbol renaming
- Careful with irreversible changes
Search Results Management
Working with Results
Create Selection
Convert to selection:
- Select results in table
- Create program selection
- Apply operations to matches
Search results are dynamic - program changes may invalidate results. Re-run searches after modifications.
Advanced Search Techniques
GUI Search Tools
Custom search interfaces:SearchGuiSingle.java: Single pattern GUISearchGuiMulti.java: Multiple pattern search- Custom search dialogs for specific needs
Quick Search
Rapid searching:- Quick searcher in search text plugin
- Located in
quicksearcherpackage - Fast incremental search
- Real-time results
