**Malware Analysis [#3**]— Disk Writer
A Windows malware sample opens a handle to the physical hard drive, reads the Master Boot Record, overwrites it with its own boot code, and stores an XOR-obfuscated copy of the original MBR in the third sector. An attacker running it could render the machine unbootable and lock the user out behind a fake password prompt.
In this article I tried to analyze this malware sample that I took from Malware Bazaar with Linux machine, but eventually I needed to use windows machine for debugging and disk analysis, so let’s begin.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the malware simply opens the raw physical drive with write access and overwrites the boot sector, which is possible because the process runs with enough privileges to access the disk device directly.
Impact
The machine fails to boot and shows a fake password prompt that rejects every password, effectively locking the user out until the MBR is restored manually.
What the attacker needed
Malware executed with disk write access; Windows machine
The fix
The original MBR should be recovered by XORing the obfuscated copy in the third sector with the same value, then written back over the first sector.
How it was found
- Open a handle to the physical drive with read and write sharing.
- Move the file pointer to the start of the drive and read 512 bytes, the MBR.
- Compare the read MBR with a copy embedded in the malware's data section.
- If they differ, write the embedded MBR over the first sector.
- XOR the original MBR with a fixed value and write it to the third sector as a backup.
- Close the handle and print success messages.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
The Master Boot Record is the very first chunk of data on a disk, and the computer reads it at startup to know how to load the operating system. This program replaces that chunk with its own code, so the machine no longer starts normally and instead shows a fake password screen. It also saves a scrambled copy of the original so the damage can be undone by hand.