2016年5月11日 星期三

MBR Disk Signature Issue

1. dump disk signature :
dd if=/dev/sda bs=1 skip=440 count=4 2>/dev/null | xxd -p -
=> 12345678

To fit with BCD format:
dd if=/dev/sda bs=1 skip=440 count=4 2>/dev/null | xxd -p -  | sed -e 's/\(..\)\(..\)\(..\)\(..\)/\1,\2,\3,\4/g'
=> 18,2e,07,c3

2. Write new signature into MBR by xxd
echo "1B8:12345678" | xxd  -r - /dev/sda

3. Fix boot configuration record for Windows
package required : libwin-hivex-perl

# random disk sigurature
_RAD_DISK_SIG=$(printf '%02x,%02x,%02x,%02x\n' $[RANDOM%256] $[RANDOM%256] $[RANDOM%256] $[RANDOM%256])
# _RAD_DISK_SIG=63,b7,f8,3a

# export from BCD file
hivexregedit --export BCD '\' > bcd.reg

# replace original disk sigure with new one
sed -e 's|^\("Element"=.*\)c0,72,b3,40\(.*\)|\1$_RAD_DISK_SIG\2|g'  bcd.reg > bcd.reg.fix

# import back to BCD file by bcd.reg.fix
hivexregedit --merge BCD  bcd.reg.fix

Ref:
http://www.multibooters.com/tutorials/view-and-change-disk-signature-in-mbr.html
http://www.howtohaven.com/system/change-disk-signature.shtml
http://unix.stackexchange.com/questions/111414/how-to-change-the-disk-signature-of-a-raw-image

沒有留言:

張貼留言

Ceasar's Photo

www.flickr.com