Windows内核实验:中断提权(Interrupt Privilege Escalation)

Windows内核实验:中断提权(Interrupt Privilege Escalation)

双机调试环境搭建

从32位的xp开始,慢慢上64位

Windows XP Home Edition with Service Pack 2 (Simplified Chinese)

ed2k://|file|sc_winxp_home_with_sp2.iso|61135872    0|B80F4CCF312420015FFD5740057085B0|/

Home Edition with Service Pack 2 xp激活码

8QKF3-VDWXY-CT6TM-7TGG6-GKR9G

Windows XP Professional with Service Pack 2 (Simplified Chinese激活码

BB96V-433XK-GM9WR-KXCDJ-4HTQW

zh-hans_windows_xp_professional_with_service_pack_3_x86_cd

MRX3F-47B9T-2487J-KWKMF-RPWBY
DP7CM-PD6MC-6BKXT-M8JJ6-RPXGJ

烦人 只有sp3支持windbg远程服务器符号比较全

激活

1)点击“开始”——运行——输入regedit ——回车 。此时进入注册表编辑器。
2)找到主键 Hkey_Local_Machine\Software\Microsoft\WindowsNT\CurrentVersion\WPAEvents\
3)删除子键 lastWPAEventLoged (右击,删除)
4)(右击,“修改”)修改子键 OOBETimer 键值为:ff d5 71 d6 8b 6a 8d 6f d5 33 93 fd
5)右击注册表中的“WPAEvents”→“权限”→“高级”→“所有者”→你的用户名→→“确定”
6)回到“安全”→“高级”→选择列表中的“system”→“编辑” ,把“拒绝”列下的方框全部打勾即可 (勾“完全控制”即可),确定,退出。

给虚拟机开个串行端口,用管道来通信,名字com_2

com_1的名字有打印机的话,会被打印机占去

\\.\pipe\com_2

image-20230526010718133

boot.ini文件里添加下面一句

COM1是因为给虚拟机开个串行端口时就是端口1(端口2的话会显示串行端口2)

image-20230526140611903

multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Microsoft Windows XP Home Edition DEBUG" /noexecute=optin /fastdetect /debugport=COM1 /baudrate=115200

可以运行 msconfig 验证一下

image-20230526140205585

windbg配置

这里的\.\pipe\com_2就是配置的管道名字

"D:\Windows Kits\10\Debuggers\x64\windbg.exe" -b -k com:pipe,port=\\.\pipe\com_2,baud=115200,resets=0 -y SRV*E:\WindbgSybols*https://msdl.microsoft.com/download/symbols

**GRMWDK_EN_7600_1.ISO**windbg7600 (新版调试xp总是出现各种bug)

1.https://www.microsoft.com/en-us/download/confirmation.aspx?id=11800
2.https://download.microsoft.com/download/4/A/2/4A25C7D5-EFBE-4182-B6A9-AE6850409A78/GRMWDK_EN_7600_1.ISO

xuetr工具

http://www.xuetr.com/

vs2022安装个xp的单个组件,后改运行库,改基址固定(后面提权要固定基址)

image-20230526200219936

vs2022

c/c++代码生成里image-20230531145420975

中断提权

前置知识ia32保护模式,中断和异常等

https://grxer.github.io/2023/04/08/32bit-x86-protected-mode/

https://grxer.github.io/2023/04/22/IA32-Interrupt-Exception/

往未使用的中断向量表里塞入我们自己的函数然后手动中断到我们的代码就可以获得0环执行权限

image-20230526222003641

windbg调试

kd> r idtr
idtr=8003f400
kd> dq 8003f400
8003f400 80548e00`00082190 80548e00`0008230c
8003f410 00008500`0058112e 8054ee00`00082720
8003f420 8054ee00`000828a0 80548e00`00082a00
8003f430 80548e00`00082b74 80548e00`000831ec
8003f440 00008500`00501188 80548e00`000835f0
8003f450 80548e00`00083710 80548e00`00083850

dbg里 r idtr只显示了高32位的基址

r idtl可以显示界限

回顾下中断门描述符

image-20230526221657750

由0号除0中断为例 他的中断处理程序地址是怎么来的

8003f400地址处80548e00 00082190高48-64位8054 + 低0-15位2190 = 0x80542190

20号中断是未使用的,我们就选取20号中断hook

#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
DWORD g_tmp;
void __declspec(naked) IdtEntry() {//裸函数不会帮我们生成栈帧,单纯一个call
__asm {
push eax
mov eax,dword ptr ds:[0x8003f500]
mov g_tmp,eax
pop eax
iretd
}
}
void interrupt() {
__asm {
int 0x20
}
}
int main() {
if (0x401040 != IdtEntry) {
printf("IdtRntry address wrong");
system("pause");
exit(-1);
}
interrupt();
printf("%x",g_tmp);
system("pause");
}
  1. 接下来去在dbg里修改中断向量表
eq 8003f500  0040ee00`00081040

这里要注意的是DPL位,DPL位必须是个三环标志(11),确保三环程序可以触发这个中断

0环的话我们3环程序去int 20中断的话,会产生越权访问的异常,这也是防止恶意程序随意调用系统调用的方式之一

  1. ce居然也可以改(之前还看到他可以加速百度网盘 。。。)

    把下面在设置 其他里勾上,就可以改内核内存了

    image-20230527002007814

访问成功,IdtEntry内指令获得0环权限