FDISK and Master Boot RecordArticle 27821 of comp.virus
From: Nick FitzGerald <n.fitzgerald@csc.canterbury.ac.nz>
Date: 3 Jan 1997 23:20:18 -0000
X-Digest: Volume 10 : Issue 2
Achim Trosien <71124.2716@CompuServe.COM> wrote:
--Jan 2. Ken van Wyk (I think so) wrote:
'twas me actually\ldots I've been moderator for the last 50.5 weeks ...
-- -- [Moderator's note: All due respects to Ian, but
-- -- {\bf DO NOT EVER} use FDISK/MBR unless you
-- -- {\bf really} know what you are doing.]
--
-- I have never heard of "fdisk /mbr" causing any damage,
-- why should it !?! I have tried it out on various computers
-- with various equip. without any probs!!
-- JUST CURIOUS ...
It may be best to answer this question by ensuring we understand what the command does, then work through the possible situations where it will ``fail'' ...
To understand what it does, first we have to get some terminology clear. The Master Boot Record (MBR) of a PC's hard drive is the very first physical sector on the disk (0,0,1 in head, cylinder, sector terms). There are some special things about the MBR. It contains (at a minimum) some executable code to start the bootstrap of the OS, a 64 byte data area known as the partition table and a two byte signature (that some BIOSes reputedly do not check for).
Assuming that the basic BIOS hardware integrity tests pass and the BIOS config is set to allow booting from a hard drive, at power-up the MBR will be copied from the disk and execution passes to the beginning of the MBR. Standard DOS MBRs (they have slightly different code for different DOS versions and other OSes) then analyze the partition table to find a primary, active DOS partition, and if found (there are other conditions depending on the DOS version and\ldots) the first sector of that logical partition (OS boot sector) is loaded into memory and execution passes to it (and that traditionally bootstraps the OS proper). This may seem to be getting away from the MBR, but you also need to understand something about the typical disk layout of these structures.
Since DOS 3.0 (Padgett?) the OS boot sector has conventionally started at the first sector of a track (often 1,0,1, but never count on it). This has meant that all of the first physical track except the MBR (first sector) is ``wasted space'' ... .
On to what FDISK/MBR does\ldots. Normally it overwrites what would be the DOS pre-bootstrap code part of the MBR, leaving the partition table and signature mentioned earlier. I have not tested this, but people who wouldn't lie to me about such things have told me that if the partition table is completely blank (full of zeroes) and/or the signature bytes are the wrong values (I can't remember exactly what I was told and haven't tested for myself) then FDSK/MBR may be a bit more ruthless\ldots.
Generally though, it sounds fairly harmless, right?? ``Generally'' it is, and that explains why on many, many machines thousands of people have ignorantly done no damage to their drives\ldots.
The problem is, there are an awful lot of machines where my earlier description of the MBR contents and the layout of things on the first track of the hard drive do not match what FDISK is programmed to assume, and, as an IT professional, I cannot consciencably recommend something that can trash someone's disk without giving them a clear understanding of the possibility of making matters worse. This is why I refuse to post submissions that basically just say ``Try FDISK/MBR'' in response to ``"How do I clean <some boot virus>?'' questions.
Examples of things that can have gone ``wrong'':
I could have named examples of 1-5, though the risk in doing that is people who do not know better will think they are the *only* possibilities, rule them out and blunder on\ldots
Just in case it is not clear at this point, all of these things replace (part of) the ``normal'' bootstrap code in the MBR with their own code and/or data and in some way critically modify the function of the bootstrap process.
So, what ``threat'' does running FDISK/MBR present in each of the above cases?
Now, ask yourself how many of these things (that many of you were previously unaware of) can you 100\% accurately diagnose via Email or through Usenet News postings?
Now you understand why FDISK/MBR is DANGEROUS?
As Bruce Burrell has been saying for a looooong time:
\hspace{0.5in} Just say ``No'' to FDISK/<mumble>
But why did it become so popular, and why is knowledge of it so widespread? Well, way back when about the ``worst'' virus you could expect to see on a realworld PC was Michaelangelo, it was relatively safe. There were no (ITW) viruses that didn't preserve the partition table (though the Empire and Monkey families soon changed that), there were no ``load from the MBR bootstrap'' large disk drivers and encryption, security and integrity systems that loaded from the MBR bootstrap were not at all common (not that they are now, either, but I'd hazard much less common than they are now\ldots). DOS v5 was quite readily available and it was discovered that, in keeping with ``tradition'' MS had built in several ``neat'' but undocumented options for various standard utilities. One of these was the /MBR option for FDISK, though this was a standard, documented feature of some earlier OEM DOSes (Toshiba, Compaq, Zenith and others actually licensed the code from MS and were able to make machine/system-specific modifications--from memory at least one of the sub-versions of Compaq DOS v3.31 documented the /MBR option). As with such things, these ``cool secrets'' were spread around by word of mouth, Email, Usenet and BBS postings, etc, etc, as knowing such secrets imparts some special status in a geekoid techie community\ldots.
Unfortunately, about the time responsible IT professionals wanted to kill the notion that FDISK/MBR was a general-purpose AV measure for MBR infectors, knowledge of it had reached critical mass\ldots. (Spaf's comments about Uenet and elephants come to mind!)
Lastly, I am considering removing mention of it from the FAQ for this list/group (at a minimum, I'll be changing our current coverage of it to strengthen the ``only do this if you can afford to make things much worse'' warning).
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Nick FitzGerald, PC Applications Consultant, CSC, Uni of Canterbury, N.Z.
n.fitzgerald@csc.canterbury.ac.nz TEL:+64 3 364 2337, FAX:+64 3 364 2332
Virus-L/comp.virus moderator and FAQ maintainer
PGP fingerprint = 2E 7D E9 0C DE 26 24 4F 1F 43 91 B9 C4 05 C9 83
Article 27829 of comp.virus
From: "James R. Bunch" <jbunch@primenet.com>
Date: 6 Jan 1997 08:11:48 -0000
X-Digest: Volume 10 : Issue 3
Nick -- I'd like to add one more circumstance to your list:
On any system that uses a dual-boot capability (OS/2 comes to mind), fdisk /mbr can ``replace'' the non-DOS bootstrap code with DOS code. Obviously not a Good Thing! It should be recoverable without too much effort if you know how the specific OS implements dual-boot. Otherwise it's a real pain in the \dots.
- ---------------------------- James R. Bunch "A Byte is a terrible thing to waste ... jbunch@primenet.com ... a MByte 1048576 times worse" PGP Key available via finger PGP Key fingerprint = B5 31 10 77 BF B0 FD B2 10 54 CB E6 13 7C 26 58 - -----------------------------
Article 27869 of comp.virus
From: W.R.Dickson@soton.ac.uk
Date: 7 Jan 1997 07:02:37 -0000
X-Digest: Volume 10 : Issue 4
Another case where fdisk /mbr is a bad idea (or at least must be used with some caution) is where an older PC with a non-translating BIOS is configured to use a large EIDE hard disk via a driver such as ``EZ-Drive''. This patches itself into the boot code (AFAIK) and if this driver is not loaded then the partition becomes unreadable (and, I imagine, susceptible to damage if any attempt to write to it is made - the ``partition table'' read by the old BIOS does not reflect the actual drive and so is effectively corrupt.) fdisk /mbr will overwrite the driver code.
Hmmm... so would even a ``harmless'' MBR virus cause damage to such a system if it loaded before the driver?
Regards
Will Dickson.