diff --git a/.gitignore b/.gitignore index 7974a5b..8ca300e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ dump/ *.bin *.a +venv/ reven/ !dump/exynos-usbdl/ diff --git a/documentation/source/BootROM_8890/boot_chain.rst b/documentation/source/BootROM_8890/boot_chain.rst index 2bd5117..f27a052 100644 --- a/documentation/source/BootROM_8890/boot_chain.rst +++ b/documentation/source/BootROM_8890/boot_chain.rst @@ -1,6 +1,8 @@ +.. _boot-chain-label: ======= Booting ======= + After exploitation the goal is to fully boot the device. Current boot chain: @@ -10,6 +12,13 @@ Current boot chain: Boot chain +As done by Frederic, the bootrom can be dumped using his provided scripts, and can the be split into different boots: + +.. code-block:: bash + + ./exynos-usbdl e payloads/Exynos8890_dump_bootrom.bin dumped_sboot.bin + scripts/split-sboot-8890.sh dumped_sboot.bin + debugger ======== Some other information about the debugger and it's current state. @@ -38,6 +47,9 @@ I relocated the debugger to ``0x20c0000`` to prevent overwriting it. bl1 === BL1 needs to be authenticated. +Loads at address ``0x02024000`` and contains some form of header (ramdump). +There seems to be a samsung header format, where the first 4 bytes define the entry point of the binary. +In this case this entry is ``+0x10`` so we jump to ``0x02024010``. .. code-block:: python diff --git a/documentation/source/BootROM_8890/index.rst b/documentation/source/BootROM_8890/index.rst index 143a0fa..9fe7aa4 100644 --- a/documentation/source/BootROM_8890/index.rst +++ b/documentation/source/BootROM_8890/index.rst @@ -15,12 +15,40 @@ Samsung Firmware ---------------- Samsung releases firmware files for their devices. These files contain the bootloader, modem, and other firmware files. To see how the ROM works we are interested in the sboot firmware, which contains multiple stages of the bootloader. + To extract the sboot.bin file from a samsung firmware file: .. code-block:: bash $ unzip -p firmware.zip 'BL_*.tar.md5' | tar -Oxf - 'sboot.bin.lz4' | lz4 -d - sboot.bin +Frederic has also written a payload to extract the sboot.bin file from a connected samsung device (See: :ref:`boot-chain-label`). The extracted boots can be split up in different stages. We're provied with sboot 1-4.bin. Running strings then provides us with some information about each stage. + +.. code-block:: bash + + $ strings -n4 sboot.bin.1.bin + +was + +.. list-table:: bootrom stages + :header-rows: 1 + + * - File + - Strings output + - Likely boot stage? + * - sboot.bin.1.bin + - Exynos BL1 + - BL1 + * - sboot.bin.2.bin + - BL31 %s + - BL31 + * - sboot.bin.3.bin + - Unsure. Contains strings like: TOP_DIV_ACLK_MFC_600 and APOLLO_DIV_APOLLO_RUN_MONITOR + - BL2? + * - sboot.bin.4.bin + - Contains more textual information, and references to post BL2 boot, and android information + - Kernel boot/BL33? + Memory Layout ------------- TODO make memory layout of ROM, IMEM and some devices @JONHE diff --git a/source/exploit/.vscode/launch.json b/source/exploit/.vscode/launch.json index 78a455b..024e36c 100644 --- a/source/exploit/.vscode/launch.json +++ b/source/exploit/.vscode/launch.json @@ -5,7 +5,7 @@ "version": "0.2.0", "configurations": [ { - "name": "Debug exploit", + "name": "Debug usb stack", "type": "debugpy", "request": "launch", "program": "exploit.py", @@ -13,13 +13,21 @@ "args": ["--debug"] }, { - "name": "Run chain", + "name": "Run boot chain", "type": "debugpy", "request": "launch", "program": "exploit.py", "console": "integratedTerminal", "justMyCode": false, "args": [] + }, + { + "name": "Debug current file", + "type": "debugpy", + "request": "launch", + "program": "${file}", + "console": "integratedTerminal", + "justMyCode": false, } ] } \ No newline at end of file diff --git a/source/exploit/exploit.py b/source/exploit/exploit.py index b58725f..3dbbae1 100644 --- a/source/exploit/exploit.py +++ b/source/exploit/exploit.py @@ -1,4 +1,3 @@ -import usb.util, usb.core import struct, sys, usb1, libusb1, ctypes, usb, argparse from keystone import * from capstone import * @@ -6,6 +5,7 @@ from ghidra_assistant.utils.utils import * from ghidra_assistant.concrete_device import * from ghidra_assistant.utils.debugger.debugger_archs.ga_arm64 import GA_arm64_debugger from qiling.const import QL_ARCH +import os, tqdm, datetime def p32(x): return struct.pack("