Skip to content

Commit

Permalink
blog
Browse files Browse the repository at this point in the history
  • Loading branch information
xuanxuan committed Jun 6, 2023
1 parent 3a9d565 commit 1964933
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions _posts/2023-05-29-p9lite.md
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ hex(0x18 + 0x9c + 0x100) == 0x1b4
![image](https://xuanxuanblingbling.github.io/assets/pic/p9lite/aes256.png)
elf_decry调用TEE_AllocateOperation的第二个参数为0x10000110,通过TEE_AllocateOperation定义
elf_decry调用TEE_AllocateOperation的第二个参数为0x10000110,通过TEE_AllocateOperation函数的定义
```c
TEE_Result TEE_AllocateOperation(
Expand All @@ -671,7 +671,7 @@ uint32_t mode,
uint32_t maxKeySize );
```

可以识别出其使用的加密算法为AES CBC:
可以识别出其使用的加密算法为AES CBC (0x10000110)

> [optee_os/lib/libutee/include/tee_api_defines.h](https://github.com/OP-TEE/optee_os/blob/f12b4ead24cdaf3080636ab4f4d63d7df67d88cc/lib/libutee/include/tee_api_defines.h#LL225C1-L225C59)
Expand Down Expand Up @@ -720,8 +720,6 @@ b'\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00'

## 完整解密脚本

完整的解密脚本如下:

```python
from Crypto.Util.number import bytes_to_long
from Crypto.Util.number import long_to_bytes
Expand Down Expand Up @@ -778,11 +776,11 @@ open('868ccafb-794b-46c6-b5c4-9f1462de4e02.elf','wb').write(msg)
868ccafb-794b-46c6-b5c4-9f1462de4e02.elf: ELF 32-bit LSB relocatable, ARM, EABI5 version 1 (SYSV), not stripped
```

使用IDA逆向此TA可以发现确实有符号,但这个TA居然是可以调用外部函数的,例如slog。这和OP-TEE的TA不同,OP-TEE的TA相当于静态链接,所有的函数都在静态链接到TA中,TA ELF 外部的功能只有通过svc系统调用进TEE OS完成:
使用IDA逆向此TA可以发现确实有符号,但这个TA居然是可以调用外部函数的,例如SLog。这和OP-TEE的TA不同,OP-TEE的TA相当于静态链接,所有的函数都在静态链接到TA中,TA ELF 外部的功能只有通过svc系统调用进TEE OS完成:

![image](https://xuanxuanblingbling.github.io/assets/pic/p9lite/TA.png)

回到华为 Trust Core 方案中的TA,找到slog函数的本体实现在globaltask中,所以此方案中globaltask和TA运行时应该在同一个内存环境下:
回到华为 Trust Core 方案中的TA,找到SLog函数的本体实现在globaltask中,所以此方案中globaltask和TA运行时应该在同一个内存环境下:

![image](https://xuanxuanblingbling.github.io/assets/pic/p9lite/slog.png)

Expand All @@ -792,7 +790,7 @@ open('868ccafb-794b-46c6-b5c4-9f1462de4e02.elf','wb').write(msg)
![image](https://xuanxuanblingbling.github.io/assets/pic/p9lite/geekpwn.png)

P9 Lite是在国外上市的手机,不过闲鱼上也可以买到,我买了一个,但是系统版本在2020年,尝试使用以上的私钥无法解密其中的TA:
P9 Lite是在国外上市的手机,不过闲鱼上也可以买到,我买了一个,但是系统版本在2020年,尝试使用以上的私钥无法解密其中的TA。应该可以刷低版本复现2016年极棒的漏洞,之后有缘再玩


其他相关:
Expand All @@ -801,6 +799,4 @@ P9 Lite是在国外上市的手机,不过闲鱼上也可以买到,我买了
- [On the Security of ARM TrustZone-Based Trusted Execution Environments](https://opus4.kobv.de/opus4-fau/files/16008/diss-mbusch.pdf)
- [Finding 1-Day Vulnerabilities in Trusted Applications using Selective Symbolic Execution](https://www.ndss-symposium.org/wp-content/uploads/2020/04/bar2020-23014.pdf)
- [SoK: Understanding the Prevailing Security Vulnerabilities in TrustZone-assisted TEE Systems](https://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=9152801)
- [SoK: Understanding the Prevailing Security Vulnerabilities in TrustZone-assisted TEE Systems 论文笔记](https://blog.csdn.net/qq_40119224/article/details/114445912)


- [SoK: Understanding the Prevailing Security Vulnerabilities in TrustZone-assisted TEE Systems 论文笔记](https://blog.csdn.net/qq_40119224/article/details/114445912)

0 comments on commit 1964933

Please sign in to comment.