when using DD how is bs=1 count=512 different than bs=512 count=1
The skip=
option operates on the block size specified by bs=
, so when you specify bs=512 count=1 skip=206848
, you're skipping 512 * 206848 (or 105,906,176) bytes of the disk, whereas when you specify bs=1 count=512 skip=206848
, you're skipping 1 * 206848 (or 206,848) bytes of the disk.
Related videos on Youtube
parsecpython
Updated on September 18, 2022Comments
-
parsecpython almost 2 years
I was taking a forensics exam. I used dd to image the device:
/dev/sdb
the command I used is:
# dd if=/dev/sdb of=SDB.IMG
I continued on to extract the MBR
# dd if=SDB.IMG bs=1 count=512 of=SDB.MBR
To look at the partition table i used:
# dd if=SDB.IMG bs=1 count=66 skip=446 | xxd -cols 16
which provides the following information:
0000000: 0020 2100 06df 130c 0008 0000 0020 0300 . !.......... .. 0000010: 00df 140c 0561 277a 0028 0300 00d8 1a00 .....a'z.(...... 0000020: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 0000030: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 0000040: 55aa
as expected
Noting bit 4 of partition 2 is 05, extended. bits 8,9,10,11 should tell me where the next MBR is when properly converted to decimal
00 28 03 00
becomes
00 03 28 00and then converted to decimal is:
206848WELL when I type the following:
dd if=SDB.IMG bs=512 count=1 skip=206848 |xxd
I get the following output:
1+0 records in 1+0 records out 512 bytes (512 B) copied, 0.000124768 s, 4.1 MB/s 0000000: eb58 906d 6b64 6f73 6673 0000 0208 2000 .X.mkdosfs.... . 0000010: 0200 0000 00f8 0000 3e00 1f00 0000 0000 ........>....... 0000020: 00d8 1a00 b806 0000 0000 0000 0200 0000 ................ 0000030: 0100 0600 0000 0000 0000 0000 0000 0000 ................ 0000040: 0000 29f5 5ccb 6120 2020 2020 2020 2020 ..).\.a 0000050: 2020 4641 5433 3220 2020 0e1f be77 7cac FAT32 ...w|. 0000060: 22c0 740b 56b4 0ebb 0700 cd10 5eeb f032 ".t.V.......^..2 0000070: e4cd 16cd 19eb fe54 6869 7320 6973 206e .......This is n 0000080: 6f74 2061 2062 6f6f 7461 626c 6520 6469 ot a bootable di 0000090: 736b 2e20 2050 6c65 6173 6520 696e 7365 sk. Please inse 00000a0: 7274 2061 2062 6f6f 7461 626c 6520 666c rt a bootable fl 00000b0: 6f70 7079 2061 6e64 0d0a 7072 6573 7320 oppy and..press 00000c0: 616e 7920 6b65 7920 746f 2074 7279 2061 any key to try a 00000d0: 6761 696e 202e 2e2e 200d 0a00 0000 0000 gain ... ....... 00000e0: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 00000f0: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 0000100: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 0000110: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 0000120: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 0000130: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 0000140: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 0000150: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 0000160: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 0000170: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 0000180: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 0000190: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 00001a0: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 00001b0: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 00001c0: 340d 0b61 277a 0008 0000 00d0 1a00 0000 4..a'z.......... 00001d0: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 00001e0: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 00001f0: 0000 0000 0000 0000 0000 0000 0000 55aa ..............U.
AS expected. BUT, when i look for the same data using the following command, i get very different results:
dd if=SDB.IMG bs=1 count=512 skip=206848 |xxd 512+0 records in 512+0 records out 512 bytes (512 B) copied, 0.00159998 s, 320 kB/s 0000000: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 0000010: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 0000020: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 0000030: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 0000040: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 0000050: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 0000060: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 0000070: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 0000080: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 0000090: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 00000a0: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 00000b0: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 00000c0: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 00000d0: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 00000e0: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 00000f0: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 0000100: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 0000110: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 0000120: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 0000130: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 0000140: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 0000150: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 0000160: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 0000170: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 0000180: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 0000190: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 00001a0: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 00001b0: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 00001c0: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 00001d0: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 00001e0: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 00001f0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
this doesn't make any sense.
both times i'm pulling 512b
using a bs of 1 works fine when i used it before.
Again:# dd if=SDB.IMG bs=1 count=66 skip=446 | xxd -cols 16
which provides the following information:
0000000: 0020 2100 06df 130c 0008 0000 0020 0300 . !.......... .. 0000010: 00df 140c 0561 277a 0028 0300 00d8 1a00 .....a'z.(...... 0000020: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 0000030: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 0000040: 55aa
-
Huckle over 10 yearsIn addition, using a block size of 1 makes no sense since your hard drive is not capable of fetching a single byte. In the best case
dd
will just reuse the returned 512-byte block 512 times. In the worst case, it will ask the drive for the same 512-byte block 512 times.