本帖最后由 古月不傲 于 2020-2-27 17:57 编辑
相关资料:
https://blog.csdn.net/weixin_42052102/article/details/83217867
https://blog.csdn.net/qq_38474570/article/details/104273858
https://www.bilibili.com/video/av68700135?p=21
https://blog.csdn.net/q1007729991/article/details/52654402
英特尔® 64 和 IA-32 架构软件开发人员手册合并版:第 1、2A、2B、2C、3A、3B 和 3C 卷
构造TSS描述符
eq 8003f0d8 0000e912`fee40068
0012`fee4 = dwTss地址
[Asm] 纯文本查看 复制代码 kd> dd KeNumberProcessors
80556a60 00000001 00000006 00009e0a a0013fff
80556a70 806ceec0 00000000 00000000 0000005d
80556a80 8003f118 00000000 00000000 00000000
80556a90 00000001 00000000 00000001 00000002
80556aa0 00000000 00000000 00000000 00000000
80556ab0 00000000 00000000 00000000 00000000
80556ac0 00000000 00000000 00000000 00000000
80556ad0 00000000 00000000 00000000 00000000
kd> dd KiProcessorBlock
8055d5a0 ffdff120 00000000 00000000 00000000
8055d5b0 00000000 00000000 00000000 00000000
8055d5c0 00000000 00000000 00000000 00000000
8055d5d0 00000000 00000000 00000000 00000000
8055d5e0 00000000 00000000 00000000 00000000
8055d5f0 00000000 00000000 00000000 00000000
8055d600 00000000 00000000 00000000 00000000
8055d610 00000000 00000000 00000000 00000000
kd> dt _kpcr ffdff120-120
nt!_KPCR
+0x000 NtTib : _NT_TIB
+0x01c SelfPcr : 0xffdff000 _KPCR
+0x020 Prcb : 0xffdff120 _KPRCB
+0x024 Irql : 0 ''
+0x028 IRR : 0
+0x02c IrrActive : 0
+0x030 IDR : 0xffffffff
+0x034 KdVersionBlock : 0x8054e2b8 Void
+0x038 IDT : 0x8003f400 _KIDTENTRY
+0x03c GDT : 0x8003f000 _KGDTENTRY
+0x040 TSS : 0x80042000 _KTSS
+0x044 MajorVersion : 1
+0x046 MinorVersion : 1
+0x048 SetMember : 1
+0x04c StallScaleFactor : 0x8a0
+0x050 DebugActive : 0 ''
+0x051 Number : 0 ''
+0x052 Spare0 : 0 ''
+0x053 SecondLevelCacheAssociativity : 0 ''
+0x054 VdmAlert : 0
+0x058 KernelReserved : [14] 0
+0x090 SecondLevelCacheSize : 0
+0x094 HalReserved : [16] 0
+0x0d4 InterruptMode : 0
+0x0d8 Spare1 : 0 ''
+0x0dc KernelReserved2 : [17] 0
+0x120 PrcbData : _KPRCB
kd> dt _KTSS 0x80042000
nt!_KTSS
+0x000 Backlink : 0x8b24
+0x002 Reserved0 : 0xc45
+0x004 Esp0 : 0x805524f0
+0x008 Ss0 : 0x10
+0x00a Reserved1 : 0x8b08
+0x00c NotUsed1 : [4] 0x758b0855
+0x01c CR3 : 0xac7000
+0x020 Eip : 0xe1750855
+0x024 EFlags : 0x8458b5e
+0x028 Eax : 0x310e8c1
+0x02c Ecx : 0xc25d0845
+0x030 Edx : 0xff8b000c
+0x034 Ebx : 0x8bec8b55
+0x038 Esp : 0xc9330845
+0x03c Ebp : 0xf7104d39
+0x040 Esi : 0x8b1f76d0
+0x044 Edi : 0xb60f0c55
+0x048 Es : 0x1114
+0x04a Reserved2 : 0xd033
+0x04c Cs : 0xe281
+0x04e Reserved3 : 0xff
+0x050 Ss : 0
+0x052 Reserved4 : 0xe8c1
+0x054 Ds : 0x3308
+0x056 Reserved5 : 0x9504
+0x058 Fs : 0x3990
+0x05a Reserved6 : 0x43
+0x05c Gs : 0x3b41
+0x05e Reserved7 : 0x104d
+0x060 LDT : 0
+0x062 Reserved8 : 0xd0f7
+0x064 Flags : 0
+0x066 IoMapBase : 0x20ac
+0x068 IoMaps : [1] _KiIoAccessMap
+0x208c IntDirectionMap : [32] "???"
构造TSS
[C] 纯文本查看 复制代码 #include <iostream>
#include <windows.h>
using namespace std;
DWORD dw = 0;
void __declspec(naked) CallFunc()
{
__asm
{
pushad;
pushfd;
__asm int 3;
mov eax, 0x8003f000;
mov ebx, [eax + 0x10];
mov dw, ebx;
popfd;
popad;
iretd
}
}
int main(void)
{
DWORD dwCr3 = 0;
scanf("%x", &dwCr3);
char uEsp[0x30] = {0};
DWORD dwTss[26] = {
0x00000000, //previous task link
0x00000000,//Esp0
0x00000000, //Ss0
0x00000000, //Esp1
0x00000000, //Ss1
0x00000000, //Esp2
0x00000000, //Ss2
dwCr3,//CR3
0x00401000, //Eip
0x00000000, //EFlags
0x00000001, //Eax
0x00000002, //Ecx
0x00000003, //Edx
0x00000004, //Ebx
(DWORD)uEsp,//Esp
0x00000000, //Ebp
0x00000000, //Esi
0x00000000, //Edi
0x00000023, //Es
0x00000008, //Cs
0x00000000, //Ss
0x00000023, //Ds
0x00000030, //Fs
0x00000000, //Gs
0x00000000, //LDT
0x20ac0000 //IoMaps
};
UCHAR uCall[6] = {0};
*(PDWORD)(&uCall[0]) = 0x12345678;
*(PWORD)(&uCall[4]) = 0xDB;
__asm
{
call fword ptr ds:[uCall];
}
printf("%x\n", dw);
system("pause");
return 0;
} |