Incorrect MLIL->HLIL lifting due to stack aliasing
維護者通常 2 天內回覆
還沒有人認領這個 Issue。
評估
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 新手友好度
- 48/100
- Issue 類型
- 缺陷
- 描述清晰度
- 基本清楚
- 活躍度
- 活躍
- 技術堆疊
- cpp
研究方向
Start with the attached hlil_counter_copy.zip and reproduce the lifting around 0x400042, comparing LLIL, MLIL, and HLIL for the stack store and later load. Trace the stack aliasing through the shown loops; done means the counter assignment remains represented correctly in HLIL without removing the corresponding value.
由索引模型根據 Issue 內容生成。
描述
This bug is found while emulating HLIL on known crypto oracles.
Given the following code snippet:
typedef unsigned int u32;
typedef unsigned char u8;
static u32 load32le(const u8 *p)
{
return (u32)p[0] | ((u32)p[1] << 8) | ((u32)p[2] << 16) | ((u32)p[3] << 24);
}
void counter_copy(const u8 *key, u32 counter, const u8 *nonce, u32 *out)
{
static const u32 constants[4] = {0x61707865u, 0x3320646eu, 0x79622d32u, 0x6b206574u};
u32 state[16], original[16];
for (int i = 0; i < 4; i++) state[i] = constants[i];
for (int i = 0; i < 8; i++) state[4 + i] = load32le(key + 4*i);
state[12] = counter;
for (int i = 0; i < 3; i++) state[13 + i] = load32le(nonce + 4*i);
for (int i = 0; i < 16; i++) original[i] = state[i];
for (int round = 0; round < 10; round++) {
state[0] += state[4];
state[12] ^= state[0];
state[8] += state[12];
}
for (int i = 0; i < 16; i++) out[i] = state[i] + original[i];
}
Specifically for line state[12] = counter;, the counter store is at 0x400042:
0x400042 mov dword ptr [rbp-0x10], esi
The LLIL and MLIL are both correct:
0x400042 [rbp - 0x10 {var_18}].d = esi
0x400070 edx = [rbp + (rax << 2) - 0x40].d
0x400074 [rbp + (rax << 2) - 0x80].d = edx
0x400042 var_18 = arg2
0x400070 rdx = [&var_48 + (i_3 << 2)].d
0x400074 [&var_88 + (i_3 << 2)].d = rdx
0x400087 rdx_1 = var_18
But it gets removed in HLIL:
00400000 int64_t counter_copy(int64_t arg1, int32_t arg2, int64_t arg3, int64_t arg4)
00400024 int32_t var_48[0x4]
00400024
00400024 for (int64_t i = 0; i != 0x10; i += 4)
00400017 *(&var_48 + i) = *(i + "expand 32-byte k")
00400017
00400040 int32_t var_38[0x4]
00400040
00400040 for (int64_t i_1 = 0; i_1 != 8; i_1 += 1)
00400034 var_38[i_1] = *(arg1 + (i_1 << 2))
00400034
0040005e for (int64_t i_2 = 0; i_2 != 3; i_2 += 1)
00400053 int32_t var_14[0x3]
00400053 var_14[i_2] = *(arg3 + (i_2 << 2))
00400053
0040007f int32_t var_88[0x10]
0040007f
0040007f for (int64_t i_3 = 0; i_3 != 0x10; i_3 += 1)
00400074 var_88[i_3] = var_48[i_3]
00400074
Binaries and source code are attached: hlil_counter_copy.zip
- 主要語言
- C++
- 星號
- 1.3k
- 分支
- 304
- 平均合併
- 2 天 20 小時
- 30 天內合併 PR
- 10
環境準備
這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
Vector35/binaryninja-api 的其他 Issue
-
難度 1/5 1 小時以內 新手友好度 84/100
Vector35/binaryninja-api#8715 ·
維護者通常 2 天內回覆
-
難度 2/5 1-3 小時 新手友好度 78/100
Vector35/binaryninja-api#8714 ·
維護者通常 2 天內回覆
-
難度 1/5 1 小時以內 新手友好度 85/100
Vector35/binaryninja-api#8713 ·
維護者通常 2 天內回覆
-
難度 1/5 1-3 小時 新手友好度 78/100
Vector35/binaryninja-api#8689 ·
維護者通常 2 天內回覆
-
Component: Python API
難度 2/5 1-3 小時 新手友好度 70/100
Vector35/binaryninja-api#8649 ·
維護者通常 2 天內回覆
查看 Vector35/binaryninja-api 的全部 Issue
相似的 Issue
-
Bug Core VIF
難度 2/5 1-3 小時 新手友好度 68/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 80/100
ESPresense/ESPresense#2680 · 2 則留言 ·
維護者通常 1 天內回覆
-
難度 2/5 1 小時以內 新手友好度 75/100
stew675/llama-cpp-rdna-boosts#348 ·
維護者通常 1 天內回覆
-
Documentation: Add comprehensive newcomer onboarding guide, project structure, and local usage to README可能已有人在做 @Ash-Blanc 今天認領。 未關閉area/other status/bot-triaged status/need-triage
難度 2/5 半天 新手友好度 85/100
-
bug
難度 1/5 1 小時以內 新手友好度 85/100
維護者通常 1 天內回覆