Advertisement
xe1phix

Xe1phix-Linux-Forensics-[MBR-Tricks]-Cheatsheet.sh

Oct 6th, 2022
1,084
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.60 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. ## ----------------------------------------------------------------------------------- ##
  4. ##     [?] The MBR contains the boot loader and the partition table  (512 bytes)
  5. ##     [?] The first 446 are for the boot loader,
  6. ##     [?] Bytes 446 to 512 are for the partition table.
  7. ## ----------------------------------------------------------------------------------- ##
  8.  
  9.  
  10. ## ------------------------------------------------------------------------------------------------------------------------------- ##
  11.         dd if=/dev/sda of=/mbr_sda.bak bs=512 count=1                       ## Backup the full MBR
  12. ## ------------------------------------------------------------------------------------------------------------------------------- ##
  13.         dd if=/dev/zero of=/dev/sda bs=512 count=1                          ## Delete MBR and partition table
  14. ## ------------------------------------------------------------------------------------------------------------------------------- ##
  15.         dd if=/mbr_sda.bak of=/dev/sda bs=512 count=1                       ## Restore the full MBR
  16. ## ------------------------------------------------------------------------------------------------------------------------------- ##
  17.         dd if=/mbr_sda.bak of=/dev/sda bs=446 count=1                       ## Restore only the boot loader
  18. ## ------------------------------------------------------------------------------------------------------------------------------- ##
  19.         dd if=/mbr_sda.bak of=/dev/sda bs=1 count=64 skip=446               ## Restore partition table
  20. ## ------------------------------------------------------------------------------------------------------------------------------- ##
  21.  
  22.  
  23.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement