I am a huge fan of the webcomic, XKCD, which is a very geeky and amusing comic for those of you who haven’t read it. On Friday, the following comic was posted:
And this of course reminded me of when I first started programming — I started with assembly language in 2000 with an 80286 I got out of the trash. I quickly became interested in low-level system programming, and created a number of MBR-based programs and other random programs in assembly. I haven’t programmed in assembly in a couple years, but this was pretty simple once I started going.
In any case, the comic has inspired me to write a Windows-based program that can write a “love note” to the MBR and display it when the computer starts. And of course, just for fun it shows the “Missing operating system” message as well. Shown is a screenshot:
OBVIOUSLY this can be a very dangerous program, and could very well destroy your computer. In fact, I would assume any antivirus program worth its salt would detect this as a virus (I haven’t formally tested this assumption). So, don’t use it unless you really know what you’re doing. The number of people that would fit that description is around 0.001% of the population of computer programmers.
- Don’t use this program if you do not know how to uninstall this program
manually. For that reason, there is no uninstaller.
- Don’t use this on 64-bit machines or ones with EFI — I really have no idea if it will work on those machines, but I seriously doubt it would. If you don’t know what EFI is, don’t use this program.
- Don’t use this on machines with GRUB, it will kill your system.
- Don’t use this on any system that is important to you or one that you do not own/control, it may kill that system, and you will get in trouble.
- Don’t use this program if you cannot pass the following quiz without any
references. Especially don’t use this program if you have no idea how to
decode the answers to the quiz.
- What is the difference between an MBR and a boot sector?
- What does interrupt 0×19 do?
- What offset does the partition table start at in an MBR, and how many bytes is each entry?
- What offset is the “signature” of the MBR located at, and what is it?
Quiz Answers (encoded in ROT13)
- Obbg frpgbef ner qrsvarq cre cnegvgvba, gurer vf bayl bar (hfrq) ZOE.
- Vg vf gur vagreehcg pnyyrq gb obbg sebz n qvfx.
- 0k1OR, fvkgrra olgrf
- Vg vf ybpngrq ng 0k1sr, naq vf 0k55 sbyybjrq ol 0kNN
How it works
You run love.exe in Windows, and it asks you for a message to put on the MBR. After clicking “destroy”, it does it. It will work in XP as administrator. It actually writes the love note to sector 3, the original MBR to sector 2, and a custom MBR to the MBR that displays the note, waits for a key to be pressed, and then loads the original MBR — at which point the computer will continue booting.
I used NASM to compile the MBR code, and Visual Studio 2005 to compile the Windows
installation program. I’ve never coded with MFC before, and this experience has not
motivated me to do it again anytime in the near future.
If you have any questions/comments/bug reports for this, feel free to contact me.
Download link: http://www.virtualroadside.com/software/
Note: In response to the comment by Criveti Mihai, the binary for the MBR sector actually is in the zip file at src/love/love/mbr.bin .. except if you were to install it via DD, you would need to install a message on sector 3 as well.
Note II: apparently the 4th answer to the quiz was incorrect for the last year or so… heh. Told you it was hard! Anyways, thanks to cm for pointing this out.