『楼 主』:
堵上DOS漏洞,破除硬盘锁的神话 [转帖]
[已使用 LLM 解释]
发信站: BBS 水木清华站 (Sat Apr 11 19:45:47 1998)
从DOS3.3以上(含3.3版〕版本,增加了硬盘分区功能,但
是可能是编程者的疏忽,在IO.SYS的一个模块中有一个漏洞。由于该
漏洞,使得在某种情况下,会导致计算机从软硬盘启动均会失败。
在一般情况下,这个漏洞也无关紧要。但是由于国内某著名
反病毒软件公司利用这一漏洞进行所谓版权保护,导致一些问题。由于
当软硬盘都不能启动时,危害极大。因此,介绍一种方法,可以堵上
这一漏洞,而保证DOS的其它功能仍正常,换句话说,修改后的DOS可同
正常的DOS一样使用。
鉴于这种方法是通过对DOS内核汇编代码的分析,直接修改
IO.SYS文件,因此对于不同的DOS版本,情况略有不同。以下仅针对两
种典型的DOS版本,给出方案。
1.西文MS-DOS6.22版修改方案: 用nu, debug, pctools,
ultraedit等工具查找 IO.SYS文件中的串(以16进制表示〕:
C2 03 06 E8 0A 00 07 72 03
替换为:C2 03 90 E8 0A 00 72 80 90
实际上只改动了四个字节。(其实该法也适合中文版
MS-DOS6.22〕
2. 西文IBM-DOS3.3版修改方案: 查找文件IBMBIO.SYS中串:
C2 03 E8 2B 00 72 25 E8 2C
替换为:C2 03 E8 2B 00 72 92 E8 2C
实际上只改动了一个字节。
3. 对于其它DOS版本,也可类似处理。
在对DOS作如上的修改之后,则DOS的启动失误被纠正,再也
不会发生那种从软硬盘均不能启动的情况(当然那种软硬盘的硬件本
身出了问题的情况不包括在内〕。
注意:1.本法不同于以前的各种方法。只需对系统盘的DOS作如
上修改,任何其它的修改都是多余的甚至有害的。
2.用以上方法修改过的DOS可正常使用,用完后不用再
改回去。
至于为什么要这样改,这样改又为什么能纠正启动失误,相信
有兴趣且懂汇编的朋友不难明白。
!!!重要声明:介绍本法纯属技术问题,本人并无意与任何
公司过不去,并非针对某种行之有效的保护
版权的措施。若因本法的传播导致某种有效
的保护版权的方法失效,则非本人本意。本
人大力鼓励使用正版尤其是国产软件。
Posted: BBS Tsinghua University Station (Sat Apr 11 19:45:47 1998)
Starting from DOS versions above 3.3 (including version 3.3), the hard disk partitioning function was added. However, due to an oversight by the programmer, there was a vulnerability in a module of IO.SYS. Due to this vulnerability, under certain circumstances, it would cause the computer to fail to boot from both the floppy and hard disks.
In general, this vulnerability is not a big deal. But because a famous domestic anti-virus software company used this vulnerability for so-called copyright protection, it caused some problems. Since it is extremely harmful when neither the floppy nor the hard disk can boot, an approach is introduced to plug this vulnerability while ensuring other functions of DOS still work normally. In other words, the modified DOS can be used the same as normal DOS.
Since this method involves analyzing the DOS kernel assembly code and directly modifying the IO.SYS file, the situation is slightly different for different DOS versions. The following only gives solutions for two typical DOS versions.
1. Modification plan for Western MS-DOS 6.22 version: Use tools like nu, debug, pctools, ultraedit, etc., to find the string (in hexadecimal representation) in the IO.SYS file:
C2 03 06 E8 0A 00 07 72 03
Replace with: C2 03 90 E8 0A 00 72 80 90
Actually, only four bytes are changed. (In fact, this method is also suitable for the Chinese version of MS-DOS 6.22)
2. Modification plan for Western IBM-DOS 3.3 version: Find the string in the file IBMBIO.SYS:
C2 03 E8 2B 00 72 25 E8 2C
Replace with: C2 03 E8 2B 00 72 92 E8 2C
Actually, only one byte is changed.
3. For other DOS versions, similar processing can be done.
After making the above modifications to DOS, the boot failure of DOS is corrected, and the situation where it cannot boot from both the floppy and hard disks will no longer occur (of course, the situation where the hardware of the floppy or hard disk itself is faulty is not included).
Note: 1. This method is different from previous methods. Only the DOS on the system disk needs to be modified as above, and any other modifications are redundant or even harmful.
2. The DOS modified by the above method can be used normally, and there is no need to change it back after use.
As for why this modification is done and why it can correct the boot failure, it is believed that friends who are interested and understand assembly will不难 understand.
!!! Important statement: Introducing this method is purely a technical issue. I have no intention of having any disputes with any company, and it is not aimed at any effective copyright protection measure. If the dissemination of this method leads to the failure of any effective copyright protection method, it is not my intention. I strongly encourage the use of genuine software, especially domestic software.
LLM 解释
这份发布于 1998 年的技术帖(后于 2003 年转贴至 CN-DOS)讨论的是早期 DOS 时代臭名昭著的“硬盘锁”问题及其内核层面的规避方案。
1. 技术背景:什么是“硬盘锁”?
“硬盘锁”并非硬件层面的锁定,而是利用了 MS-DOS 在启动过程中对分区表(Partition Table)链表结构的递归扫描机制。
在 MS-DOS 3.3 及更高版本中,为了支持逻辑分区,系统在初始化阶段会读取主引导记录(MBR)中的分区表。如果存在扩展分区,IO.SYS(或 IBMBIO.SYS)会读取扩展分区的分区表(EBR),并沿着链表查找下一个逻辑驱动器。
漏洞原理:
如果人为构造一个循环指向的分区表(例如:分区 A 的扩展分区表项指向分区 B,而分区 B 又指向分区 A),DOS 在启动时扫描分区表的代码会陷入死循环。由于这种扫描发生在系统加载驱动程序和 CONFIG.SYS 之前,计算机表现为自检通过后,在读取软盘或硬盘系统文件时永久死机。
2. 补丁原理分析
帖子中提供的十六进制修改方案,核心目的在于修改 IO.SYS 中处理磁盘读取错误或分区表解析的逻辑。
-
MS-DOS 6.22 补丁分析:
原始序列:C2 03 06 E8 0A 00 07 72 03
修改序列:C2 03 90 E8 0A 00 72 80 90
在汇编层面,这类修改通常涉及将 JC (Jump if Carry, 72) 或循环指令的目标地址进行偏移,或者使用 NOP (90) 抹除某些检查。通过这种修改,当 IO.SYS 遇到异常的分区表结构(如死循环或非法的磁盘偏移量)时,不再尝试无限递归或因溢出挂起,而是直接跳过该分区或报错返回。
-
局限性:
这种方法虽然能让受感染/被锁的机器通过软盘启动,但它并没有解决“死循环”本身,而是通过硬编码的方式强行中断了 DOS 对分区链表的完整性检查。
3. 历史语境与后续评价
4. 补充说明
针对此类“硬盘锁”的最彻底解决方案并非修改 IO.SYS,而是通过不依赖 DOS 中断(INT 21h/INT 25h/INT 26h)的底层磁盘工具,直接调用 BIOS 中断(INT 13h)写入正确的 MBR。在现代模拟环境(如 DOSBox 或虚拟机)中,由于虚拟化层对磁盘结构的保护,这种漏洞通常不会导致宿主机死机,但在维护真实历史硬件时仍需警惕。
|