To prepare the image for the analysis in Ghidra, we first require two files from from the firmware update.
Given a CP_A415FXX*_user_low_ship_MULTI_CERT.tar.md5
file, we need:
md1rom
: The binary ROM image which contains the actual firmware codemd1_dbginfo.csv
: A CSV-based export of the debug infos which are shipped as part of the firmware update
Both of these files are obtained from the the firmware update using the script unpack_mtk_cp_update.py, e.g.:
python3 unpack_mtk_cp_update.py CP_A415FXXU1ATE1_CP15883562_CL18317596_QB31188168_REV00_user_low_ship_MULTI_CERT.tar.md5
The script will create the following directory: CP_A415FXXU1ATE1_CP15883562_CL18317596_QB31188168_REV00_user_low_ship_MULTI_CERT
The directory will contain all files contained within the firmware update, including the two required files md1rom
and md1_dbginfo.csv
.
Given the two files md1rom
and md1_dbginfo.csv
, we can start loading the Mediatek Firmware image into Ghidra.
To achieve this, take the following steps:
- First, import the
md1rom
into Ghidra usingFile->import file...
(hotkey:i
) - As loading options, choose
Format: Raw Binary
,Language: MIPS:LE:32:default:default (MIPS default 32 little default)
- Confirm, and when prompted for the initial auto analysis, decline (make sure the initial analysis is not performed)
- Within the script manager (
Window->Script Manager
), chooseanalyze_mtk_image.py
within theFirmWire
category. - In case you are prompted for a debug file, choose
md1_dbginfo.csv
. - Wait for the analysis to finish. This will take a considerable amount of time (in the order of 60 minutes).
Ghidra is a software reverse engineering (SRE) framework created and maintained by the National Security Agency Research Directorate. This framework includes a suite of full-featured, high-end software analysis tools that enable users to analyze compiled code on a variety of platforms including Windows, macOS, and Linux. Capabilities include disassembly, assembly, decompilation, graphing, and scripting, along with hundreds of other features. Ghidra supports a wide variety of processor instruction sets and executable formats and can be run in both user-interactive and automated modes. Users may also develop their own Ghidra extension components and/or scripts using Java or Python.
In support of NSA's Cybersecurity mission, Ghidra was built to solve scaling and teaming problems on complex SRE efforts, and to provide a customizable and extensible SRE research platform. NSA has applied Ghidra SRE capabilities to a variety of problems that involve analyzing malicious code and generating deep insights for SRE analysts who seek a better understanding of potential vulnerabilities in networks and systems.
If you are a U.S. citizen interested in projects like this, to develop Ghidra and other cybersecurity tools for NSA to help protect our nation and its allies, consider applying for a career with us.
WARNING: There are known security vulnerabilities within certain versions of Ghidra. Before proceeding, please read through Ghidra's Security Advisories for a better understanding of how you might be impacted.
To install an official pre-built multi-platform Ghidra release:
- Install JDK 11 64-bit
- Download a Ghidra release file
- Extract the Ghidra release file
- Launch Ghidra:
./ghidraRun
(orghidraRun.bat
for Windows)
For additional information and troubleshooting tips about installing and running a Ghidra release,
please refer to docs/InstallationGuide.html
which can be found in your extracted Ghidra release
directory.
To create the latest development build for your platform from this source repository:
- JDK 11 64-bit
- Gradle 6.8+ or 7.x
- make, gcc, and g++ (Linux/macOS-only)
- Microsoft Visual Studio (Windows-only)
$ unzip ghidra-master
$ cd ghidra-master
NOTE: Instead of downloading the compressed source, you may instead want to clone the GitHub
repository: git clone https://github.com/NationalSecurityAgency/ghidra.git
$ gradle -I gradle/support/fetchDependencies.gradle init
$ gradle buildGhidra
The compressed development build will be located at build/dist/
.
For more detailed information on building Ghidra, please read the Developer Guide.
Ghidra installations support users writing custom scripts and extensions via the GhidraDev plugin
for Eclipse. The plugin and its corresponding instructions can be found within a Ghidra release at
Extensions/Eclipse/GhidraDev/
.
To develop the Ghidra tool itself, it is highly recommended to use Eclipse, which the Ghidra development process has been highly customized for.
- Follow the above build instructions so the build completes without errors
- Install Eclipse IDE for Java Developers
$ gradle prepdev eclipse buildNatives
- File -> Import...
- General | Existing Projects into Workspace
- Select root directory to be your downloaded or cloned ghidra source repository
- Check Search for nested projects
- Click Finish
When Eclipse finishes building the projects, Ghidra can be launched and debugged with the provided Ghidra Eclipse run configuration.
For more detailed information on developing Ghidra, please read the Developer Guide.
If you would like to contribute bug fixes, improvements, and new features back to Ghidra, please take a look at our Contributor Guide to see how you can participate in this open source project.