From 5d6204efa307db6c5e405f34df06203742def1ac Mon Sep 17 00:00:00 2001 From: Jonathan Herrewijnen Date: Fri, 9 Aug 2024 22:16:13 +0200 Subject: [PATCH] Minor docs update. Trying to dump memory --- .../source/BootROM_8890/boot_chain.rst | 2 + documentation/source/BootROM_8890/index.rst | 28 ++++ source/exploit/.vscode/launch.json | 11 +- source/exploit/exploit.py | 146 ++++++++++-------- 4 files changed, 115 insertions(+), 72 deletions(-) diff --git a/documentation/source/BootROM_8890/boot_chain.rst b/documentation/source/BootROM_8890/boot_chain.rst index 3a1c3d2..4dbced1 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: 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 3bbe32b..024e36c 100644 --- a/source/exploit/.vscode/launch.json +++ b/source/exploit/.vscode/launch.json @@ -10,7 +10,7 @@ "request": "launch", "program": "exploit.py", "console": "integratedTerminal", - "args": ["--usb-debug"] + "args": ["--debug"] }, { "name": "Run boot chain", @@ -19,15 +19,6 @@ "program": "exploit.py", "console": "integratedTerminal", "justMyCode": false, - "args": ["--run-boot-chain"] - }, - { - "name": "Debug on device", - "type": "debugpy", - "request": "launch", - "program": "exploit.py", - "console": "integratedTerminal", - "justMyCode": false, "args": [] }, { diff --git a/source/exploit/exploit.py b/source/exploit/exploit.py index c01aed2..dc7f979 100644 --- a/source/exploit/exploit.py +++ b/source/exploit/exploit.py @@ -5,7 +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 +import os, tqdm, datetime def p32(x): return struct.pack("