Exercise 2: Forensics with dd
For the dollar, there is no better tool for data forensics than dd because it is free. Included with every Linux and Unix distribution, dd is capable of creating perfect copies of any disk, regardless of whether it is IDE or SCSI. In a review of forensic tools by SC Info Security Magazine, dd was the only tool besides Symantec's Ghost to image a disk accurately.
Originally developed to copy data from one device to another or from EBCDIC to ASCII, dd also proves to be a powerful tool for a variety of other tasks. Its capability to correctly move data from one device to another makes it a handy supplement to daily backup routines. From a forensic standpoint, the capability to make image files on different device types is invaluable. dd can create image files on disks, CD-RW drives, files, and tapes.
In conjunction with Unix systems' capability to create MD5 checksums for files, dd provides a powerful, inexpensive tool to verify that the image file has not been changed in any way. This is critical, especially for evidence that might be used in court.
Just because a compromised system is not Unix based, however, is no reason to not use dd. A wide variety of Linux distributions are available that boot off a disk and allow you to use dd to make your forensic copies. Trinux is one example and is available at http://www.trinux.org. This power and flexibility makes dd a vital part of the incident handler's toolkit.
The objective of this exercise is for you to learn how to use dd and MD5 to create, restore, and verify forensically sound disk images.
Intel-based PC running Red Hat Linux 7.2
Floppy disk with data on it (Windows or Linux format)
The following are the steps you will complete in this exercise:
Create an MD5 checksum of the disk.
Create an image file of the disk.
Use MD5 to verify the accuracy of the image file.
Restore the image file to a blank disk.
Use MD5 to verify the accuracy of the duplicate disk.
Test MD5 against an altered image file.
Challenge Procedure Step-by-Step
The following steps show you how to use dd and MD5 to create, restore, and verify forensically sound disk images:
First, we start by creating an MD5 checksum of a disk. To do this, first log in as root, and open a command prompt. Create the MD5 checksom for the disk to be duplicated using the following:
md5sum /dev/fd0 > /tmp/original-md5
Now, create an image file of the disk.
Use dd to create a binary copy of the disk:
dd if=/dev/fd0 of=/tmp/disk.img bs=1k
The if=/dev/fd0 parameter directs dd to use the device /dev/fd0 as the input file. The of=/tmp/disk.img parameter tells dd to output the data to a file named /tmp/disk.img. The bs=1k tells dd to use a block size of 1024 or 1KB.
Next, we'll use MD5 to verify the accuracy of the image file. First, create the MD5 checksum for the image file with the following:
Compare the checksums of the original disk and the image file using the following:
The cat command displays the contents of files that end with md5. Note that the checksums are identical.
Next, you'll restore the image file to a blank disk.
Use dd to copy the image file to the disk:
dd if=/tmp/disk.img of=/dev/fd0 bs= 1k
This command reverses the flow of the data, whereas the command in step 2 created the image file.
Create the checksum for the duplicate disk:
md5sum /dev/fd0 > /tmp/duplicate-md5
Now, use cat to verify the accuracy of the duplicate disk by comparing the checksums of all three versions:
Test MD5 against an altered image file. Do this by first adding a single byte of data to the image file:
echo x >> /tmp/disk.img
Then, create a new checksum for the image file:
md5sum /tmp/disk.img > /tmp/corrupt-md5
Finally, compare the checksums for each step of this exercise:
Note how a difference of only 1 byte causes the MD5 to change drastically. This demonstrates the value of using and checking the MD5 signatures of files when downloading them from the Internet.
Disk Imaging Tool Specification, Version 3.1.3., NIST (National Institute of Standards and Technology), August 26, 2001, http://www.cftt.nist.gov/testdocs.html.
Holley, James. "Computer Forensics." SCInfo Security Magazine. September 2000, http://www.scmagazine.com/scmagazine/2000_09/survey/survey.html #secure.
Mohd,, Madihah. An Overview of Disk Imaging Tool in Computer Forensics. SANS Institute, http://www.sans.org/infosecFAQ/incident/disk_imaging.htm.
Lack of budget is not a reason for not having a good diskimaging tool in your toolbox. Combining powerful, freely available tools, such as dd, MD5sum, and Trinux, and bootable, Linux disks allows you to put together a package that creates forensically valid binary images.
dd provides the capability to move data from one device to another. It works with IDE, SCSI devices, and a variety of media including other hard disks, floppy disks, CD-RW discs, and tapes of any format. MD5sum creates a digital signature for binary images so that you can verify that the duplicate is an accurate copy of the original. Finally, Trinux allows you to put these tools onto a bootable Linux disk that can be used to duplicate Unix and Windows systems.