前置准备
00407030 -> 0000e940`70300068
GDT: eq 80b98848 0000e94070300068 IDT: eq 80b98100 0000e500
00480000
知识点
INT 8双重异常
代码实验
完整代码
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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
|
#include <iostream> #include <Windows.h>
struct _KiIoAccessMap { UCHAR DirectionMap[32]; UCHAR IoMap[8196]; };
typedef struct _KTSS { USHORT Backlink; USHORT Reserved0; ULONG Esp0; USHORT Ss0; USHORT Reserved1; ULONG NotUsed1[4]; ULONG CR3; ULONG Eip; ULONG EFlags; ULONG Eax; ULONG Ecx; ULONG Edx; ULONG Ebx; ULONG Esp; ULONG Ebp; ULONG Esi; ULONG Edi; USHORT Es; USHORT Reserved2; USHORT Cs; USHORT Reserved3; USHORT Ss; USHORT Reserved4; USHORT Ds; USHORT Reserved5; USHORT Fs; USHORT Reserved6; USHORT Gs; USHORT Reserved7; USHORT LDT; USHORT Reserved8; USHORT Flags; USHORT IoMapBase; struct _KiIoAccessMap IoMaps[1]; UCHAR IntDirectionMap[32]; }KTSS;
KTSS tss = { 0 }; char bufEsp0[0x2000] = { 0 }; char bufEsp3[0x2000] = { 0 };
void __declspec(naked) test() { __asm { int 3; pushfd; pop eax; or eax, 0x4000; push eax; popfd; iretd; } }
int main() { memset(bufEsp0, 0, 0x2000); memset(bufEsp3, 0, 0x2000); tss.Esp0 = (ULONG)bufEsp0 + 0x1FF0; tss.Esp = (ULONG)bufEsp3 + 0x1FF0; tss.Ss0 = 0x10; tss.Ss = 0x10; tss.Cs = 0x8; tss.Ds = 0x23; tss.Es = 0x23; tss.Fs = 0x30; tss.EFlags = 2; tss.Eip = (ULONG)test; tss.IoMapBase = 0x20ac;
printf("请输入你的CR3: "); DWORD dwCr3 = 0; scanf_s("%x", &dwCr3);
tss.CR3 = dwCr3; printf("%p\r\n", &tss); system("pause");
char bufCode[6] = { 0,0,0,0,0x48,0 };
__asm { int 32; }
return 0; }
|