1
This commit is contained in:
Huoji's
2022-04-16 02:27:07 +08:00
parent 025c544ebb
commit 83ed6c77d7
3 changed files with 61 additions and 2 deletions

View File

@@ -1,2 +1,21 @@
# cpu_duck ### AMD CPU与INTEL CPU指令解析问题
about 66 e8 ... 假设一个情况:
```cpp
66 e8 00 00 00 00
```
在x86指令集中
66会作为e8的prefix,覆盖code segment size
假设当前大小为16bit 新大小会为32bit.反之一样.
code segment size由 GDT/LDT 决定.实模式一般是16 bit("unreal"模式除外)
在x64中,我发现了一个很有意思的地方:
66 E8作为指令前缀时,AMD和INTEL呈现了完全不同的特性,即amd会遵循规则,将e8的code segment size设置为16bit 而intel则直接忽略.
这个问题已经被发现了有一段时间了,capstone在2016年,记录了这个问题.
https://github.com/capstone-engine/capstone/issues/776
这是一个概念性代码,不用CPUID判断出是INTEL还是AMD的cpu.
### 简单的思考:
能否用于混淆?

20
cpuDuck.cpp Normal file
View File

@@ -0,0 +1,20 @@
#include <iostream>
extern "C" void asm_fake_jmp();
extern "C" void fake_jmp_end();
void fake_jmp_end() {
printf("you are intel cpu \n");
}
int main()
{
__try
{
asm_fake_jmp();
}
__except (1)
{
printf("you are amd cpu \n");
}
system("pause");
}

20
duck.asm Normal file
View File

@@ -0,0 +1,20 @@
.code
extern fake_jmp_end:proc
asm_fake_jmp proc
;int 3;
db 66h
db 0E9h
db 00h
db 00h
db 00h
db 00h
db 90h
db 90h
db 90h
jmp fake_jmp_end
ret
;jmp fake_jmp_end
asm_fake_jmp endp
end