Skip to content

Commit

Permalink
blog
Browse files Browse the repository at this point in the history
  • Loading branch information
xuanxuan committed Jun 8, 2023
1 parent 422c107 commit 20669d8
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions _posts/2023-05-29-p9lite.md
Original file line number Diff line number Diff line change
Expand Up @@ -793,8 +793,20 @@ TEE_Result TEE_SetOperationKey(TEE_OperationHandle operation, TEE_ObjectHandle k
### 逆向
分析关键变量如下:
- 46行:根据TEE_SetOperationKey函数定义,v20的类型就是TEE_ObjectHandle,其值为栈上地址
- 35行:`v20[67]`上存了v9,即一个堆地址,指向一个12字节的堆块(堆块1)
- 41行:v9也即v17,即堆块1的4字节偏移处,又存了一个堆地址,指向v11大小字节的堆块(堆块2)
- 39行:v11的值为全局变量dword_156758,也即堆块2的大小
- 45行:v12,也即堆块2的地址,拷贝了全局变量dword_156764指向的内容,拷贝大小为dword_156758
因此v20指向的这段栈空间就可以理解为TEE_ObjectHandle指向的结构体,其`67*4`字节的偏移处的位置存放了堆块1的地址,堆块1中又存了堆块2的地址,在堆块2中存放了全局变量dword_156764指向的内容。而v20确实作为TEE_SetOperationKey函数设置密钥的关键变量,所以全局变量dword_156764指向的内容应该就是AES的密钥。那么v20的`67*4`字节偏移,和通过两层堆块保存密钥的结构,应该就是GP标准中设计出来的属性Attribute,在TrustedCore中的具体实现。
![image](https://xuanxuanblingbling.github.io/assets/pic/p9lite/v20.png)
那么接下来我们就通过GP标准和OP-TEE来辅助证明一下这个逆向结果。
### GP标准
在GP标准中定义TEE_ObjectHandle为结构体指针,但找不到目标结构体具体的定义:
Expand Down

0 comments on commit 20669d8

Please sign in to comment.