首页
社区
课程
招聘
[原创]如何使用OpeniBoot
2015-4-5 00:09 16498

[原创]如何使用OpeniBoot

2015-4-5 00:09
16498
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 https://github.com/iDroid-Project/OpeniBoot-toolchain
编译命令:
./build-toolchain.sh make
Note:
观察编译进度
tail -f /tmp/ipl-toolchain/build.log
IPL代表的是什么含义呢?
Initial Program Load or Initial Program Loader

编译脚本会从gun的网站上下载代码包,例如:
http://ftp.gnu.org/gnu/binutils/binutils-2.17.tar.bz2
保存在/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 https://github.com/iDroid-Project/openiBoot
编译命令:
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 https://github.com/iDroid-Project/OiBC
安装依赖库:
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 https://github.com/Chronic-Dev/syringe
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值参考:
http://theiphonewiki.com/wiki/Sundance_10A403_%28iPod4,1%29

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!

阿里云助力开发者!2核2G 3M带宽不限流量!6.18限时价,开 发者可享99元/年,续费同价!

上传的附件:
  • 0.PNG (425.87kb,10次下载)
  • 1.PNG (385.01kb,7次下载)
收藏
点赞1
打赏
分享
最新回复 (3)
雪    币: 219
活跃值: (738)
能力值: (RANK:290 )
在线值:
发帖
回帖
粉丝
viphack 4 2015-4-5 11:21
2
0
android
雪    币: 242
活跃值: (418)
能力值: ( LV11,RANK:188 )
在线值:
发帖
回帖
粉丝
XPoy 3 2016-8-5 16:18
3
0
学习,最近在学习IOS系统的知识,LZ好强,可以加个好友交流吗?
雪    币: 101
活跃值: (48)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
schroep 2017-10-4 00:38
4
0
Mac编译不成功哇
游客
登录 | 注册 方可回帖
返回