diff --git a/.github/workflows/integration_test.yml b/.github/workflows/integration_test.yml index 3228eb9..773cce5 100644 --- a/.github/workflows/integration_test.yml +++ b/.github/workflows/integration_test.yml @@ -11,10 +11,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - name: Set up JDK 11 + - name: Set up JDK 17 uses: actions/setup-java@v3 with: - java-version: '11' + java-version: '17' distribution: 'temurin' - uses: actions/cache@v3 id: cache @@ -27,7 +27,7 @@ jobs: uses: er28-0652/setup-ghidra@0.0.6 if: steps.cache.outputs.cache-hit != 'true' with: - version: '10.1.2' + version: '10.4' - name: Download Z3 uses: pavpanchekha/setup-z3@0.2.0 if: steps.cache.outputs.cache-hit != 'true' @@ -39,7 +39,7 @@ jobs: if: steps.cache.outputs.cache-hit == 'true' run: | echo "CPATH=/opt/hostedtoolcache/z3/4.8.15/x64/z3-4.8.15-x64-glibc-2.31/include" >> $GITHUB_ENV - echo "GHIDRA_INSTALL_DIR=/opt/hostedtoolcache/ghidra/10.1.2/x64" >> $GITHUB_ENV + echo "GHIDRA_INSTALL_DIR=/opt/hostedtoolcache/ghidra/10.4/x64" >> $GITHUB_ENV - name: Setup Z3 run: | cp $CPATH/../bin/com.microsoft.z3.jar $GITHUB_WORKSPACE/lib/com.microsoft.z3.jar @@ -52,5 +52,5 @@ jobs: - name: Integration test uses: gradle/gradle-build-action@0d13054264b0bb894ded474f08ebb30921341cee with: - gradle-version: current + gradle-version: 7.4 arguments: integrationTest diff --git a/.github/workflows/unittest.yml b/.github/workflows/unittest.yml index 7867a19..0679b79 100644 --- a/.github/workflows/unittest.yml +++ b/.github/workflows/unittest.yml @@ -11,10 +11,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - name: Set up JDK 11 + - name: Set up JDK 17 uses: actions/setup-java@v3 with: - java-version: '11' + java-version: '17' distribution: 'temurin' - uses: actions/cache@v3 id: cache @@ -27,7 +27,7 @@ jobs: uses: er28-0652/setup-ghidra@0.0.6 if: steps.cache.outputs.cache-hit != 'true' with: - version: '10.1.2' + version: '10.4' - name: Download Z3 uses: pavpanchekha/setup-z3@0.2.0 if: steps.cache.outputs.cache-hit != 'true' @@ -39,7 +39,7 @@ jobs: if: steps.cache.outputs.cache-hit == 'true' run: | echo "CPATH=/opt/hostedtoolcache/z3/4.8.15/x64/z3-4.8.15-x64-glibc-2.31/include" >> $GITHUB_ENV - echo "GHIDRA_INSTALL_DIR=/opt/hostedtoolcache/ghidra/10.1.2/x64" >> $GITHUB_ENV + echo "GHIDRA_INSTALL_DIR=/opt/hostedtoolcache/ghidra/10.4/x64" >> $GITHUB_ENV - name: Setup Z3 run: | cp $CPATH/../bin/com.microsoft.z3.jar $GITHUB_WORKSPACE/lib/com.microsoft.z3.jar @@ -47,5 +47,5 @@ jobs: - name: Unit test uses: gradle/gradle-build-action@0d13054264b0bb894ded474f08ebb30921341cee with: - gradle-version: current + gradle-version: 7.4 arguments: test diff --git a/Dockerfile b/Dockerfile index 6a08af9..2532977 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ ARG UBUNTU_MIRROR=mirrors.tuna.tsinghua.edu.cn -FROM gradle:7-jdk11 +FROM gradle:7-jdk17 ARG UBUNTU_MIRROR # Non-interactive installation requirements @@ -22,9 +22,9 @@ RUN apt-get update -qq && apt-get install -y \ # Ghidra installation -ARG GHIDRA_RELEASE_TAG=Ghidra_10.1.2_build -ARG GHIDRA_VERSION=ghidra_10.1.2_PUBLIC -ARG GHIDRA_BUILD=${GHIDRA_VERSION}_20220125 +ARG GHIDRA_RELEASE_TAG=Ghidra_10.4_build +ARG GHIDRA_VERSION=ghidra_10.4_PUBLIC +ARG GHIDRA_BUILD=${GHIDRA_VERSION}_20230928 RUN wget https://github.com/NationalSecurityAgency/ghidra/releases/download/${GHIDRA_RELEASE_TAG}/${GHIDRA_BUILD}.zip && \ unzip -d ghidra ${GHIDRA_BUILD}.zip && \ diff --git a/ghidra_scripts/BinAbsInspector.java b/ghidra_scripts/BinAbsInspector.java index 9a0ae4a..2a227b5 100644 --- a/ghidra_scripts/BinAbsInspector.java +++ b/ghidra_scripts/BinAbsInspector.java @@ -8,7 +8,6 @@ import com.bai.checkers.CheckerManager; import com.bai.env.funcs.FunctionModelManager; import com.bai.util.Config.HeadlessParser; -import generic.continues.RethrowContinuesFactory; import ghidra.app.util.bin.MemoryByteProvider; import ghidra.app.util.bin.format.elf.ElfException; import ghidra.app.util.bin.format.elf.ElfHeader; diff --git a/src/integration/java/IntegrationTestBase.java b/src/integration/java/IntegrationTestBase.java index 71aa6a6..f896aba 100644 --- a/src/integration/java/IntegrationTestBase.java +++ b/src/integration/java/IntegrationTestBase.java @@ -3,6 +3,7 @@ import ghidra.app.plugin.core.analysis.AutoAnalysisManager; import ghidra.app.util.importer.AutoImporter; import ghidra.app.util.importer.MessageLog; +import ghidra.app.util.opinion.LoadResults; import ghidra.program.flatapi.FlatProgramAPI; import ghidra.program.model.address.Address; import ghidra.program.model.listing.Function; @@ -32,14 +33,15 @@ public static void initEnv() { protected Program prepareProgram(File file) throws Exception { GlobalState.reset(); - Program program = AutoImporter.importByUsingBestGuess(file, null, this, new MessageLog(), + LoadResults loadResults = AutoImporter.importByUsingBestGuess(file, null, null, this, new MessageLog(), TaskMonitorAdapter.DUMMY); + Program program = loadResults.getPrimaryDomainObject(); AutoAnalysisManager analysisManager = AutoAnalysisManager.getAnalysisManager(program); analysisManager.initializeOptions(); final int tid = program.startTransaction("analysis"); GlobalState.currentProgram = program; GlobalState.flatAPI = new FlatProgramAPI(program); - if (!program.getOptions(Program.PROGRAM_INFO).getBoolean(Program.ANALYZED, false)) { + if (!program.getOptions(Program.PROGRAM_INFO).getBoolean(Program.ANALYZED_OPTION_NAME, false)) { GlobalState.flatAPI.analyzeAll(program); } program.endTransaction(tid, true); diff --git a/src/main/java/com/bai/env/funcs/externalfuncs/VarArgsFunctionBase.java b/src/main/java/com/bai/env/funcs/externalfuncs/VarArgsFunctionBase.java index c925bc8..5909a57 100644 --- a/src/main/java/com/bai/env/funcs/externalfuncs/VarArgsFunctionBase.java +++ b/src/main/java/com/bai/env/funcs/externalfuncs/VarArgsFunctionBase.java @@ -12,6 +12,7 @@ import ghidra.program.model.data.DataTypeManager; import ghidra.program.model.data.FunctionDefinition; import ghidra.program.model.data.FunctionDefinitionDataType; +import ghidra.program.model.data.GenericCallingConvention; import ghidra.program.model.data.IntegerDataType; import ghidra.program.model.data.ParameterDefinition; import ghidra.program.model.data.ParameterDefinitionImpl; @@ -67,7 +68,7 @@ private static void writeSignature(Function function, Address callsite, Function ParameterDefinition[] params = sig.getArguments(); FunctionDefinitionDataType fsig = new FunctionDefinitionDataType("tmpname"); - fsig.setGenericCallingConvention(sig.getGenericCallingConvention()); + fsig.setGenericCallingConvention(GenericCallingConvention.getGenericCallingConvention(sig.getCallingConventionName())); fsig.setArguments(params); fsig.setReturnType(sig.getReturnType()); fsig.setVarArgs(sig.hasVarArgs()); diff --git a/src/main/java/com/bai/util/Utils.java b/src/main/java/com/bai/util/Utils.java index d32498d..920f0b1 100644 --- a/src/main/java/com/bai/util/Utils.java +++ b/src/main/java/com/bai/util/Utils.java @@ -8,7 +8,6 @@ import com.bai.env.funcs.FunctionModelManager; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; -import generic.continues.RethrowContinuesFactory; import ghidra.app.cmd.function.ApplyFunctionSignatureCmd; import ghidra.app.util.bin.MemoryByteProvider; import ghidra.app.util.bin.format.elf.ElfException; @@ -350,14 +349,13 @@ public static List getReferences(List symbolNames) { public static Function getEntryFunction() { try { MemoryByteProvider provider = new MemoryByteProvider(GlobalState.currentProgram.getMemory(), - GlobalState.currentProgram.getMinAddress()); - + GlobalState.currentProgram.getMinAddress(), true); Address entryAddress; String executableFormat = GlobalState.currentProgram.getExecutableFormat(); switch (executableFormat) { case ElfLoader.ELF_NAME: { - ElfHeader header = ElfHeader.createElfHeader(RethrowContinuesFactory.INSTANCE, provider); + ElfHeader header = new ElfHeader(provider, null); entryAddress = GlobalState.flatAPI.toAddr(header.e_entry()); if (entryAddress.subtract(GlobalState.currentProgram.getImageBase()) < 0) { // handle PIE ELF with non-zero base address @@ -367,8 +365,7 @@ public static Function getEntryFunction() { break; case PeLoader.PE_NAME: { - PortableExecutable pe = PortableExecutable.createPortableExecutable( - RethrowContinuesFactory.INSTANCE, provider, PortableExecutable.SectionLayout.MEMORY); + PortableExecutable pe = new PortableExecutable(provider, PortableExecutable.SectionLayout.MEMORY); OptionalHeader header = pe.getNTHeader().getOptionalHeader(); entryAddress = GlobalState.flatAPI.toAddr(header.getAddressOfEntryPoint()); entryAddress = entryAddress.add(GlobalState.currentProgram.getImageBase().getOffset());