-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFilterRustSymbols.java
More file actions
52 lines (41 loc) · 1.6 KB
/
FilterRustSymbols.java
File metadata and controls
52 lines (41 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//Demangle Rust Packages using the _ZN package name structure.
//@author
//@category Demangler
//@keybinding
//@menupath
//@toolbar
// Import Ghidra classes
import ghidra.app.script.GhidraScript;
import ghidra.program.model.symbol.Symbol;
import ghidra.program.model.symbol.SymbolTable;
import ghidra.program.model.symbol.SymbolIterator;
import java.util.HashSet;
import java.util.Set;
/**
* Script to find all symbol names in a Rust binary and filter out those starting with _ZN.
*/
public class FilterRustSymbols extends GhidraScript {
protected void run() throws Exception {
// Get the Symbol Table from the current program
SymbolTable symbolTable = currentProgram.getSymbolTable();
// Get all symbols using SymbolIterator
SymbolIterator symbolIterator = symbolTable.getAllSymbols(true);
// A set to keep track of unique filtered symbol names
Set<String> filteredSymbols = new HashSet<>();
// Iterate through all symbols
while (symbolIterator.hasNext()) {
Symbol symbol = symbolIterator.next();
// Get the name of the symbol
String symbolName = symbol.getName();
// Check if the symbol name starts with "_ZN"
if (symbolName.startsWith("_ZN")) {
filteredSymbols.add(symbolName);
}
}
// Output the filtered symbol names to the Ghidra console
println("Filtered symbols starting with _ZN:");
for (String name : filteredSymbols) {
println(name);
}
}
}