x64(学习笔记) - 5(x64保护模式 - 调用门)

x86程序进x64调用门

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33

__declspec(naked) void callCate()
{
//当进去这个函数时已经处于 64位环境
__asm
{
__emit 0x0f;
__emit 0x01;
__emit 0xf8;//swapgs


__emit 0x0f;
__emit 0x01;
__emit 0xf8; //swapgs


__emit 0x48;
__emit 0xcb; //retfq
retfq;
}
}
int main()
{
char buf[6] = {0,0,0,0,0x73,0};

//手动构建 gdt

__asm
{
call fword ptr buf;
}
}

x64程序进x64调用门

20200826204001

  1. 构建GDT
  2. 构建命令
1
2
3
4
5
6
7
8
9
10
11
12
13
14
.code
callCate proc
nop
call fword ptr [rcx]
ret
callCate endp;

exeCallCate proc
swapgs
int 3
swapgs
retfq; retfq 按照8字节返回 retf按照4字节返回
exeCallCate endp;
end

KTSS64

64位下 GDT中xxxx8bxx`xxxxxxx xxxxxxxx`xxxxxxx 是tss

反调试

  1. 从32位下执行64位代码
  2. 从64位下执行32位代码
评论

:D 一言句子获取中...

加载中,最新评论有1分钟缓存...