OSUSecLab / FirmXRay

MIT License
55 stars 8 forks source link

Can't build container image due to compilation error. #5

Open LittleNewton opened 2 months ago

LittleNewton commented 2 months ago

Hi there.

This is my dockerfile:

FROM debian:bookworm

RUN apt-get update && apt-get install -y \
    openjdk-17-jdk \
    zsh \
    make \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /FirmXRay

COPY . .

RUN make

When I invoke it on my Linux machine, error occurred:

 > [5/5] RUN make:                                                                                                                              
0.251 javac -cp "lib/*" -d out @target.txt                                                                                                      
1.275 src/main/Main.java:86: error: constructor SleighLanguageProvider in class SleighLanguageProvider cannot be applied to given types;        
1.275             languageProvider = new SleighLanguageProvider();                                                                              
1.275                                ^                                                                                                          
1.275   required: no arguments
1.275   found:    no arguments
1.275   reason: SleighLanguageProvider() has private access in SleighLanguageProvider
1.286 src/main/Main.java:140: error: cannot find symbol
1.286         GhidraProgramUtilities.setAnalyzedFlag(program, true);
1.286                               ^
1.286   symbol:   method setAnalyzedFlag(Program,boolean)
1.286   location: class GhidraProgramUtilities
1.309 src/core/BaseAddressSolver.java:61: error: constructor SleighLanguageProvider in class SleighLanguageProvider cannot be applied to given types;
1.309             languageProvider = new SleighLanguageProvider();
1.309                                ^
1.309   required: no arguments
1.309   found:    no arguments
1.309   reason: SleighLanguageProvider() has private access in SleighLanguageProvider
1.349 src/util/AddressUtil.java:36: warning: [removal] getAddressMap() in Program has been deprecated and marked for removal
1.349         Address newAdd = program.getAddressMap().getImageBase().getNewAddress(address);
1.349                                 ^
1.375 Note: Some input files use unchecked or unsafe operations.
1.375 Note: Recompile with -Xlint:unchecked for details.
1.376 Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
1.376 3 errors
1.376 1 warning
1.408 make: *** [Makefile:18: build] Error 1
------
Dockerfile:13
--------------------
  11 |     COPY . .
  12 |     
  13 | >>> RUN make
  14 |     
--------------------
ERROR: failed to solve: process "/bin/sh -c make" did not complete successfully: exit code: 2

I have compiled ghidra.jar (v11.1.1) using OpenJDK 17 and copied it to ${FIRMXRAY_DIR}/lib/.

onehouwong commented 2 months ago

Hi. Thanks for the feedback. FirmXRay was previously built on Ghidra v9.2.2. Some APIs may have changed so you may either revert to the previous version or update the source code with the latest API calls.

LittleNewton commented 2 months ago

Great, docker build job is successful after downgrading Ghidra to v9.2.2.

LittleNewton commented 2 months ago

@onehouwong Could you please tell me the exact version of JDK I should use in this project? Thanks!

onehouwong commented 2 months ago

Below is the JDK version that was used to run FirmXRay around 3 years ago:

java 11.0.1 2018-10-16 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.1+13-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.1+13-LTS, mixed mode)

Other JDK versions might work as well as long as they can compile

LittleNewton commented 2 months ago

@onehouwong Thank you so much for your continuous help. The analysis job can run after adjusting JDK and Ghidra to the explicit versions! I wrote a simple Dockerfile and helper manuscript here. :)


Still, there is a simple question, the analysis output of example_nordic.bin is very short:

{
    "Path": 0,
    "Size": 4475,
    "Time": 4541,
    "Vendor": "Nordic",
    "Base": "00000000"
}

It only contains one segment. However, the results of BLE_Ear_s130.bin@cf3737e8a19b21e15cf1854c94349c4b and oad.bin@45c11704740916023e63a09f6a02447b is pretty normal.

onehouwong commented 2 months ago

Thanks for sharing! To debug the issue you mentioned, I will need more information from the internal executions. For example, checking if FirmXRay correctly finds the APIs' addresses would be useful, from https://github.com/OSUSecLab/FirmXRay/blob/master/src/main/Main.java#L167