This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
haas:spring2016:unix:projects:udr1 [2016/03/14 22:10] – removed wedge | haas:spring2016:unix:projects:udr1 [2016/03/15 13:37] (current) – [Partition Layout] wedge | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | <WRAP centeralign round box> | ||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | ~~TOC~~ | ||
+ | |||
+ | ======Project: | ||
+ | |||
+ | =====Errata===== | ||
+ | Typos and bug fixes: | ||
+ | |||
+ | * < | ||
+ | |||
+ | =====Objective===== | ||
+ | Use your UNIX skills and tools at hand to enable you to solve a problem in the realm of raw data management and data recovery, this time involving hard drives and partition tables. | ||
+ | |||
+ | =====Backstory===== | ||
+ | It always starts the same way: you torrent a cracked version of a newly released game you've been pining for, neglecting to check for embedded malware. This time it was the pinnacle of human programming achievement- the Mudkip Simulator (move over goat simulator!) Oh, and you were sneaking internet access on the chief meme archivist' | ||
+ | |||
+ | Turns out this one had a few tricks up its sleeve. Of particular note: partition scrambling. Oh no! All the memes! | ||
+ | |||
+ | After downing two Mr. Pibbs, a Mars bar, and a pack of Necco Wafers (saving the purple ones for last), you sit down to correct your most grievous of oversights. Chiptunes blazing, gaming flash drive at the ready, and extra monitors displaying terminals covering nearly every square decimeter of desk space, you have a hard drive partition map to restore. | ||
+ | |||
+ | Turns out there was at least **some** redundancy... a backup of the partition table/ | ||
+ | |||
+ | You need to recover the partition table, restore the disk to its accessible state, and copy pertinent files onto one of its partitions. Basic file management never seemed so enthralling. | ||
+ | |||
+ | Time to dust off that hexadecimal, | ||
+ | |||
+ | =====Background===== | ||
+ | Your data, as we experience it today, is organized in units of files (regular files, directory files, special files). Turns out, that is further organized into things called inodes and superblocks, | ||
+ | |||
+ | Below that, we have the notion of sectors (units of transactions), | ||
+ | |||
+ | So here, below the file system, in fact, what helps establish boundaries for the filesystem that we conveniently use everyday, is another organizational scheme, one that sets boundaries for where our data can reside on media. We call these partitions. And the partitions are laid out in a partition table. | ||
+ | |||
+ | =====Obtain the file===== | ||
+ | This week's project is located in the **udr1/** subdirectory of the UNIX Public Directory. | ||
+ | |||
+ | You need to go there and run a program called **prep**, by providing it the absolute path to the directory you've made to store your files for the **udr1** project. | ||
+ | |||
+ | For example, if you've made a **src/ | ||
+ | |||
+ | <cli> | ||
+ | lab46:/ | ||
+ | Processing disk.image ......................................... | ||
+ | MBR backup is at offset 0xXXXXXX | ||
+ | Process complete. Your file is in '/ | ||
+ | lab46:/ | ||
+ | </ | ||
+ | |||
+ | A couple of things to note: | ||
+ | |||
+ | * the file you need, **disk.image** will be copied into the directory of your choosing. The **directory** must exist before you instruct **prep** to place it there (otherwise you'll get an error). | ||
+ | * You'll get an offset for the "**MBR backup**" | ||
+ | |||
+ | =====Process===== | ||
+ | In order to gain access to the drive (in the form of the file called **disk.image**, | ||
+ | |||
+ | There is a backup stored on the drive... you were informed of its location when you successfully ran **prep**. Obtain and unravel it. | ||
+ | |||
+ | Once you have it, you'll want to restore it onto the drive; it needs to occupy the first sector on the drive. | ||
+ | |||
+ | Once you have that in place, we can use a hex editor to study the partition table and determine the starting sectors and overall sizes of each partition. | ||
+ | |||
+ | You'll want to extract each partition individually from the disk image so you can better interact with it. You'll need to determine the partition type and ensure a viable filesystem is in place (think back to the puzzle boxes). Ultimately you'll want to be able to view and copy data to/from the various partitions. | ||
+ | |||
+ | To facilitate your efforts, please name each extracted partition files as follows: | ||
+ | |||
+ | * partition #1: **udr1.part1.img** | ||
+ | * if there' | ||
+ | * if there' | ||
+ | * if there' | ||
+ | |||
+ | As this is a disk image of the chief meme archivist' | ||
+ | |||
+ | Finally, reintegrating the changed fourth partition over the old one, so that you can submit the whole restored image, along with a list of command-lines you performed (and other information gathered) to accomplish this task. | ||
+ | |||
+ | =====Useful tools===== | ||
+ | You may want to become familiar with the manual pages of the following tools (in addition to tools you've already encountered): | ||
+ | |||
+ | * **dd**(1) -- especially the **conv=notrunc** option | ||
+ | * **bc**(1) | ||
+ | * **mtools**(1) | ||
+ | * **hexedit**(1) | ||
+ | |||
+ | The aim is for this entire project to be performed on lab46. No external resources/ | ||
+ | |||
+ | Be sure to ask questions! There are bound to be many. | ||
+ | |||
+ | =====Partition Access===== | ||
+ | The partitions are defined in the partition table, located near the end of the first sector of the drive. | ||
+ | |||
+ | Of particular note, you're interested in groups of 16 bytes starting at offset **0x1BE**. | ||
+ | |||
+ | |||
+ | You may want to consult a reference of the binary layout of the MBR/ | ||
+ | |||
+ | * http:// | ||
+ | |||
+ | ====Partition Layout==== | ||
+ | A partition is defined in 16 bytes (the classic PC layout allows for four primary partitions). The byte layout is as follows: | ||
+ | |||
+ | ^ Byte ^ Description | ||
+ | | 0 | Boot Indicator (0x80 indicates it is set bootable) | ||
+ | | 1 | Starting CHS values (you can ignore for this project) | ||
+ | | 2 | ::: | | ||
+ | | 3 | ::: | | ||
+ | | 4 | Partition Type ID | | ||
+ | | 5 | Ending CHS values (you can ignore for this project) | ||
+ | | 6 | ::: | | ||
+ | | 7 | ::: | | ||
+ | | 8 | Starting Sector (little endian format) | ||
+ | | 9 | ::: | | ||
+ | | 10 | ::: | | ||
+ | | 11 | ::: | | ||
+ | | 12 | Partition Size (in Sectors) | ||
+ | | 13 | ::: | | ||
+ | | 14 | ::: | | ||
+ | | 15 | ::: | | ||
+ | |||
+ | ====Partition Types==== | ||
+ | < | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | 10 OPUS 55 EZ-Drive | ||
+ | 11 Hidden FAT12 56 Golden Bow a8 Darwin UFS f1 SpeedStor | ||
+ | 12 Compaq diagnost 5c Priam Edisk | ||
+ | 14 Hidden FAT16 <3 61 SpeedStor | ||
+ | 16 Hidden FAT16 63 GNU HURD or Sys af HFS / HFS+ fb VMware VMFS | ||
+ | 17 Hidden HPFS/NTF 64 Novell Netware | ||
+ | 18 AST SmartSleep | ||
+ | 1b Hidden W95 FAT3 70 DiskSecure Mult bb Boot Wizard hid fe LANstep | ||
+ | 1c Hidden W95 FAT3 75 PC/IX | ||
+ | 1e Hidden W95 FAT1 80 Old Minix | ||
+ | </ | ||
+ | |||
+ | =====Submission===== | ||
+ | Successful completion will result in the following criteria being met: | ||
+ | |||
+ | * When all is said and done, you will submit 2 files to me: | ||
+ | * The final, modified **disk.image** file, which: | ||
+ | * has the backup MBR restored to the proper place | ||
+ | * has the mudkip/ | ||
+ | * **steps.txt**, | ||
+ | * a list of command-lines used to accomplish every step of this project from start to finish (excluding the successful run of **prep** and the successful **submit**). | ||
+ | * explanations of the commands, as well as how you derived any numbers used. | ||
+ | * type ID (in hex as well as descriptive text) of each partition | ||
+ | * which partition is marked as bootable? | ||
+ | * total size (in bytes and sectors) of the MBR/ | ||
+ | * total size of each partition (as defined in the partition table) | ||
+ | * total formatted size of each filesystem | ||
+ | * amount of space used in each filesystem (when all is said and done) | ||
+ | * amount of space free in each filesystem (when all is said and done) | ||
+ | * the disk label of each partition/ | ||
+ | * what file(s) are present in the fourth partition upon copying all mudkip/ | ||
+ | * what file(s) are left out? | ||
+ | |||
+ | ====Submit==== | ||
+ | Please submit as follows: | ||
+ | |||
+ | <cli> | ||
+ | lab46: | ||
+ | Submitting unix project " | ||
+ | -> disk.image(OK) | ||
+ | -> steps.txt(OK) | ||
+ | |||
+ | SUCCESSFULLY SUBMITTED | ||
+ | lab46: | ||
+ | </ |