Commit b65e0142 by 文周繁

feat: add testghidra

parent a4087e70
### IntelliJ IDEA ###
out/
!**/src/main/**/out/
!**/src/test/**/out/
### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
### VS Code ###
.vscode/
### Mac OS ###
.DS_Store
\ No newline at end of file
import ghidra.app.script.GhidraScript;
import ghidra.program.model.listing.*;
import ghidra.program.model.symbol.Reference;
import ghidra.program.model.symbol.Symbol;
import ghidra.program.model.symbol.SymbolIterator;
import ghidra.program.model.symbol.SymbolTable;
public class FunctionRef extends GhidraScript {
public void run() throws Exception {
printf("Hello World\n"); //格式化输出
println("Hello World"); //打印字符串并换行
printerr("Hello World"); //错误消息打印控制台显示红色
SymbolTable st=currentProgram.getSymbolTable();
SymbolIterator iter=st.getSymbolIterator();
int count=0;
while(iter.hasNext()&& !monitor.isCancelled()){
Symbol sym=iter.next();
if(sym!=null){
printf("%s\n",sym.getName());
count++;
}
}
println(count+" symbols");
// get function reference
FunctionIterator funcIterator=currentProgram.getListing().getFunctions(true);
for(Function function:funcIterator){
if(function.getName().equals("write")){
printf("\t%s @ %s\n",function.getName(),function.getEntryPoint());
Reference[] references=getReferencesTo(function.getEntryPoint());
for(Reference reference: references){
Function referencefunction=getFunctionContaining(reference.getFromAddress());
if(referencefunction!=null && !referencefunction.isThunk())
{
printf("\t\t%s @ %s\n",referencefunction.getName(),
referencefunction.getEntryPoint().toString());
}
}
}
}
}
}
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="GHIDRA_EXT" name="Ghidra">
<configuration>
<option name="installationPath" value="$MODULE_DIR$/../../Tools/Ghidra10.1.5/ghidra" />
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_11" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Ghidra" level="application" />
</component>
</module>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment