[原创]如何使用OpeniBoot
发表于:
2015-4-5 00:09
17594
HOST测试环境Ubuntu 12.04.2 LTS
# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 12.04.2 LTS
Release: 12.04
Codename: precise
编译OpeniBoot-toolchain(构建官方交叉编译器)
获取编译脚本:
git clone 9cfK9s2c8@1M7s2y4Q4x3@1q4Q4x3V1k6Q4x3V1k6Y4K9i4c8Z5N6h3u0Q4x3X3g2U0L8$3#2Q4x3V1k6A6c8s2u0G2K9h3c8Q4x3X3c8b7M7X3!0B7k6h3y4@1i4K6u0r3e0%4m8W2L8X3W2n7L8$3!0@1i4K6u0V1N6r3!0G2L8r3y4Z5j5h3W2F1
编译命令:
./build-toolchain.sh make
Note:
观察编译进度
tail -f /tmp/ipl-toolchain/build.log
IPL代表的是什么含义呢?
Initial Program Load or Initial Program Loader
编译脚本会从gun的网站上下载代码包,例如:
0b6K9s2c8@1M7q4)9K6b7g2)9J5c8W2)9J5c8X3k6@1M7q4)9J5k6h3N6F1N6g2)9J5k6h3!0J5k6#2)9J5c8X3N6F1N6g2)9J5c8X3u0A6L8Y4g2@1K9h3I4K6i4K6u0r3j5X3W2F1N6i4c8A6L8s2y4Q4x3X3b7J5i4K6u0W2x3e0N6Q4x3X3g2@1j5i4u0Q4x3X3g2T1P5U0t1`.
保存在/tmp/ipl-toolchain/src目录下:
root@Compiler:~# ls -l /tmp/ipl-toolchain/src/
total 59560
-rw-r--r-- 1 root root 13831069 Aug 31 2011 binutils-2.17.tar.bz2
-rw-r--r-- 1 root root 39172003 May 25 2006 gcc-4.1.1.tar.bz2
-rw-r--r-- 1 root root 7981432 Apr 3 23:23 newlib-1.14.0.tar.gz
解压、patch、编译、安装
输出的结果保存在
/usr/local下,例如交叉编译器/usr/local/bin/arm-elf-
整个流程:
root@Compiler:/home/jerry/itouch4g/OpeniBoot-toolchain# ./build-toolchain.sh make
./build-toolchain.sh: line 83: /tmp/ipl-toolchain/build.log: No such file or directory
=======================================
- Creating default directories
- /tmp/ipl-toolchain/binutils-build
- /tmp/ipl-toolchain/gcc-build
- /tmp/ipl-toolchain/newlib-build
- /tmp/ipl-toolchain/src
- Downloading packages
- Downloading binutils-2.17.tar.bz2
- binutils-2.17.tar.bz2 download complete
- Downloading gcc-4.1.1.tar.bz2
- gcc-4.1.1.tar.bz2 download complete
- Downloading newlib-1.14.0.tar.gz
- newlib-1.14.0.tar.gz download complete
Starting Binutils
- Extracting binutils
- Configuring binutils
- Building binutils
- Installing binutils
Completed Binutils
Starting GCC Part 1
- Extracting GCC
- Extracting Newlib dependency for gcc
- Patching GCC for t-arm-elf
- Configuring GCC
- Building GCC part 1
- Installing GCC part 1
Completed GCC Part 1
Starting Newlib
- Patching Newlib for makeinfo
- Configuring Newlib
- Making arm-elf-cc symlink
- Building Newlib
- Installing NewLib
Completed NewLib
Starting GCC Part 2
- Building GCC part 2
- Installing GCC part 2
Completed GCC Part 2
Toolchain install successful
=======================================
注意:
需要安装:sudo apt-get install texinfo
否则因为`makeinfo' is missing on your system导致Failed to build newlib (stage: newlib_build)
编译openiboot
获取代码:
git clone 145K9s2c8@1M7s2y4Q4x3@1q4Q4x3V1k6Q4x3V1k6Y4K9i4c8Z5N6h3u0Q4x3X3g2U0L8$3#2Q4x3V1k6A6c8s2u0G2K9h3c8Q4x3X3c8b7M7X3!0B7k6h3y4@1i4K6u0r3L8%4m8W2L8X3W2n7L8$3!0@1
编译命令:
# export PATH=/usr/local/bin:$PATH
# scons iPodTouch4G
输出结果:
ELF格式文件:ipt_4g_openiboot
# file ipt_4g_openiboot
ipt_4g_openiboot: ELF 32-bit LSB executable, ARM, version 1, statically linked, not stripped
转换后的bin格式文件(mk8900image/mk8900image ipt_4g_openiboot ipt_4g_openiboot.bin):
ipt_4g_openiboot.bin
Note:
scons iPodTouch4G -c 相当于make clean
编译loadibec、oibc
loadibec用于通过bootrom漏洞装载ipt_4g_openiboot.bin
oibc用于usb console(iRecovery)的命令交互
获取代码:
# git clone e3aK9s2c8@1M7s2y4Q4x3@1q4Q4x3V1k6Q4x3V1k6Y4K9i4c8Z5N6h3u0Q4x3X3g2U0L8$3#2Q4x3V1k6A6c8s2u0G2K9h3c8Q4x3X3c8b7M7X3!0B7k6h3y4@1i4K6u0r3e0$3W2n7b7H3`.`.
安装依赖库:
# apt-get install libreadline-dev
编译命令:
# make loadibec && make
输出结果:
root@Compiler:/home/jerry/itouch4g/OiBC# ls -l
total 76
-rwxr-xr-x 1 root root 13670 Apr 4 00:07 loadibec
-rwxr-xr-x 1 root root 19530 Apr 4 00:07 oibc
Install:
# cp loadibec oibc /usr/local/bin/
测试:
Itouch4g工作在DFU模式
# lsusb
Bus 001 Device 009: ID 05ac:1227 Apple, Inc. Mobile Device (DFU Mode)
问题:loadibec无法识别出DFU模式下的itouch4g
# loadibec ./ipt_4g_openiboot.bin
open_device: unable to connect to device.
your device must be in recovery mode.
下面代码说明,需要工作在USB_RECOVERY模式:
handle = open_device(USB_RECOVERY);
从这个loadibec代码里看,并没有利用漏洞,而是直接上传文件,然后用iRecovery的go命令执行ipt_4g_openiboot.bin,觉得不太靠谱,还是安装新版本的loadibec
# git clone 163K9s2c8@1M7s2y4Q4x3@1q4Q4x3V1k6Q4x3V1k6Y4K9i4c8Z5N6h3u0Q4x3X3g2U0L8$3#2Q4x3V1k6o6K9s2u0G2L8X3W2U0i4K6u0V1c8r3g2$3i4K6u0r3M7%4W2J5K9h3&6Y4k6b7`.`.
# cd ./syringe && make
# cp utilities/loadibec /usr/local/bin # loadibec ./ipt_4g_openiboot.bin
Loadibec 2.00.
Connecting to iDevice...
linera1n compatible device detected, injecting limera1n.
Initializing libpois0n
opening device 05ac:1227...
Checking if device is compatible with this jailbreak
Checking the device type
Identified device as iPod4,1
Preparing to upload limera1n exploit
Resetting device counters
Sending chunk headers
Sending exploit payload
Sending fake data
Exploit sent
Reconnecting to device
Waiting 2 seconds for the device to pop up...
opening device 05ac:1227...
limera1ned, reconnecting...
Waiting 10 seconds for the device to pop up...
opening device 05ac:1227...
uploading ibss...
Checking if iBSS.n81ap already exists
Preparing to fetch DFU image from Apple's servers
Fetching Firmware/dfu/iBSS.n81ap.RELEASE.dfu...
[==================================================] 100.0%
Uploading iBSS.n81ap to device
[==================================================] 100.0%
Waiting 10 seconds for the device to pop up...
opening device 05ac:1281...
Setting to configuration 1
Setting to interface 0:0
Loaded payload for iBSS on n81ap
Resetting device counters
Uploading iBSS payload
[==================================================] 100.0%
iBSS loaded...
Waiting 10 seconds for the device to pop up...
opening device 05ac:1281...
Setting to configuration 1
Setting to interface 0:0
Starting transfer of './ipt_4g_openiboot.bin'.
[==================================================] 100.0%
Uploaded Successfully.
虽然openiboot PANIC了,但他不是也跑起来了…
检查代码是下面这个模块导致了PANIC:
MODULE_INIT(h2fmi_init)
关闭之。
再次使用loadibec加载编译出来的ipt_4g_openiboot.bin出现下面界面。
Note:loadibec加载过程中,UART串口(参考内核调试的那个线缆)也是有调试信息输出的。
这时oibc也可以进行iRecovery命令交互了,例如使用这个aes命令:
// openiboot/plat-a4/aes.c
// COMMAND("aes", "use the hardware crypto engine", cmd_aes);
顺便再次验证:
当可以访问硬件AES引擎(GIDKey)时,求证6.0版本itouch4g内核文件的密钥为:
<key>IV</key><string>c856cb32d49cf677b1031582560c07f6</string>
<key>Key</key><string>53503a0603a5e4192df5985ac5817eb1001abaa23e9fc6735dee392a4c063934</string>
Key值参考:
96cK9s2c8@1M7q4)9K6b7g2)9J5c8W2)9J5c8Y4c8Z5k6h3W2H3K9r3!0F1k6i4N6A6K9$3W2Q4x3X3g2U0L8$3#2Q4x3V1k6%4K9h3E0A6i4K6u0r3f1%4g2F1k6r3q4F1j5$3g2Q4y4h3j5I4x3p5p5@1x3o6y4Q4y4h3k6Q4x3U0f1J5z5r3W2b7L8$3b7@1i4K6u0o6x3g2)9J5y4e0t1&6 # oibc
OiB client connected:
!<filename>[@<address>] to send a file, ~<filename>[@<address>]:<len> to receive a file
---------------------------------------------------------------------------------------------------------
tasks: Initialized bootstrap.
tasks: Initialized irq.
tasks: Initialized uart reader.
clocks: Reconfigured clock 14 to 51300000. (0xa0000014)
clocks: Reconfigured clock 36 to 51300000. (0xb0000001)
clcd: Clock configured at 51300000.
pinot_init()
tasks: Last thread cannot sleep!
mipi_dsim_init()
clcd: p=2, m=57, s=1
tasks: Last thread cannot sleep!
tasks: Last thread cannot sleep!
pinot_init(): pinot_panel_id: 0xb2a40b88
pinot_init(): pinot_default_color: 0x00ffffff
pinot_init(): pinot_backlight_cal: 0x00000000
tasks: Last thread cannot sleep!
tasks: Last thread cannot sleep!
tasks: Last thread cannot sleep!
Found Gamma table 0x00a40b08 / 0x00ffff7f
init: Initializing boot modules.
init: Initializing modules.
tasks: Initialized ACM.
USB: Hardware Configuration
HWCFG1 = 0x00000264
HWCFG2 = 0x228f60d0
HWCFG3 = 0x07e800e8
HWCFG4 = 0xdbf08030
___ _ ____ _
/ _ \ _ __ ___ _ __ (_) __ ) ___ ___ | |_
| | | | '_ \ / _ \ '_ \| | _ \ / _ \ / _ \| __|
| |_| | |_) | __/ | | | | |_) | (_) | (_) | |_
\___/| .__/ \___|_| |_|_|____/ \___/ \___/ \__|
|_|
version: openiboot 0.3 commit 7aeb344 for iPod Touch 4G
ACM: Ready.
aes
ACM: Starting aes
Usage: aes <enc/dec> <gid/uid/key> [data] [iv]
ACM: Done: aes. Error: Invalid parameter (0x80000001).
aes dec gid b87fe769173d1cccc739aa5905a510be8171fc33928fa3989ac2540b12017576aea8693bf776fcba000ee678c66582f0
ACM: Starting aes dec gid b87fe769173d1cccc739aa5905a510be8171fc33928fa3989ac2540b12017576aea8693bf776fcba000ee678c66582f0
c856cb32d49cf677b1031582560c07f653503a0603a5e4192df5985ac5817eb1001abaa23e9fc6735dee392a4c063934
ACM: Done: aes dec gid b87fe769173d1cccc739aa5905a510be8171fc33928fa3989ac2540b12017576aea8693bf776fcba000ee678c66582f0.
Have Fun!
[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课
上传的附件: