<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Some stuff &#187; recovery</title>
	<atom:link href="http://blog.yhuang.org/?feed=rss2&#038;tag=recovery" rel="self" type="application/rss+xml" />
	<link>https://blog.yhuang.org</link>
	<description>here.</description>
	<lastBuildDate>Wed, 27 Aug 2025 08:50:58 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.1</generator>
		<item>
		<title>Useful information (Appendix)</title>
		<link>https://blog.yhuang.org/?p=47</link>
		<comments>https://blog.yhuang.org/?p=47#comments</comments>
		<pubDate>Mon, 08 Jan 2007 03:24:04 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Appendix]]></category>
		<category><![CDATA[ddrescue]]></category>
		<category><![CDATA[disk]]></category>
		<category><![CDATA[ext]]></category>
		<category><![CDATA[ext2 file system]]></category>
		<category><![CDATA[ext2 partition]]></category>
		<category><![CDATA[ext2 partitions]]></category>
		<category><![CDATA[external usb drive]]></category>
		<category><![CDATA[hard disk recovery]]></category>
		<category><![CDATA[recovery]]></category>

		<guid isPermaLink="false">http://scripts.mit.edu/~zong/wpress/?p=47</guid>
		<description><![CDATA[This is part of the hard disk recovery documentation. Appendix. Here are all the tools that made an arguably irreplaceable contribution in the recovery: Knoppix CD ddrescue DiskProbe fsstat (part of Knoppix) ext2 Installable File System (use with caution, as it may crap on your ext2 partition) Mount Image Pro vdk nfi chkdsk (part of [...]]]></description>
			<content:encoded><![CDATA[<p>This is part of the hard disk recovery documentation.</p>
<p>Appendix.</p>
<p>Here are all the tools that made an arguably irreplaceable contribution in the recovery:</p>
<ul>
<li><a href="http://www.knoppix.org/">Knoppix CD</a></li>
<li><a href="http://ftp.gnu.org/gnu/ddrescue/">ddrescue</a></li>
<li><a href="http://www.microsoft.com/downloads/details.aspx?familyid=49AE8576-9BB9-4126-9761-BA8011FABF38&#038;displaylang=en">DiskProbe</a></li>
<li>fsstat (part of Knoppix)</li>
<li><a href="http://www.fs-driver.org/download.html">ext2 Installable File System</a> (use with caution, as it may crap on your ext2 partition)</li>
<li><a href="http://www.mountimage.com/download-computer-forensics-software.php">Mount Image Pro</a></li>
<li><a href="http://chitchat.at.infoseek.co.jp/vmware/vdk.html">vdk</a></li>
<li><a href="http://support.microsoft.com/kb/253066">nfi</a></li>
<li>chkdsk (part of Windows XP)</li>
<li>ntbackup (part of Windows XP)</li>
<li><a href="http://www.elcomsoft.com/aefsdr.html">Advanced EFS Data Recovery</a></li>
</ul>
<p><span id="more-47"></span><br />
Here are some additional links that I looked at, with more information:</p>
<ul>
<li><a href="http://geeksaresexy.blogspot.com/2005/12/hard-drive-recovery-utilities-when-you.html">Hard disk recovery utilities</a></li>
<li><a href="http://www.ngine.de/index.jsp?pageid=4176">Installing XP on external USB drive</a></li>
<li><a href="http://www.pcinspector.de/file_recovery/uk/faq.htm">&#8220;PC Inspector&#8221; recovery software</a></li>
<li><a href="http://www.stellarinfo.com/">&#8220;Stellar&#8221; recovery software</a></li>
<li><a href="http://geschonneck.com/security/forensics/">Forensics tools</a></li>
<li><a href="http://freshmeat.net/projects/addrescue/?branch_id=52446&#038;release_id=243389">ddrescue documentation</a> and <a href="http://serverfault.com/questions/4906/using-dd-for-disk-cloning">discussion</a></li>
<li><a href="http://www.kernel.org/pub/dist/knoppix-dvd/knoppix-cheatcodes.txt">Knoppix boot options</a></li>
<li><a href="http://www.linuxquestions.org/questions/showthread.php?t=485322">Tips on NTFS recovery from ddrescue image and log</a></li>
<li><a href="http://www.ntfs.com/ntfs.htm">NTFS file system description</a></li>
<li><a href="http://www.linux-ntfs.org/content/view/104/43/">More technical information about NTFS</a></li>
<li><a href="http://www.science.unitn.it/~fiorella/guidelinux/tlk/node95.html">Ext2 file system description</a> (I only found the section entitled &#8220;The ext2 Group Descriptor&#8221; to be helpful. I put little trust in the correctness of the rest.)</li>
<li><a href="http://oss.oracle.com/projects/ocfs2/dist/documentation/disklayout.pdf">Disk layout of ext2 and ocfs2</a> (The data structures and the example of what the Group Descriptor Table were useful. The rest like the &#8220;first data block&#8221; value is different from what is observed &#8212; although the examples use a block size of 1KB, which may make a difference.)</li>
</ul>
<p>For the record, here are the two external disks I have with their ext2 partitions&#8217; Superblocks shown:</p>
<p>100GB disk, just one ext2 partition, starts at sector 63.<br />
<img src="wp-content/uploads/images/sector1.png"/></p>
<p>160GB disk, there is a 20GB FAT32 partition, and the second ext2 partition starts at sector 41945715. This is the partition whose backup superblocks are all off by +1KB (but are otherwise correct), and hence has an illegal formatting.<br />
<img src="wp-content/uploads/images/sector2.png"/></p>
<p>And here are the ddrescue log files, from the <a href="wp-content/uploads/rescue1.log">first run</a> and the <a href="wp-content/uploads/rescue2.log">second run</a>.</p>
<p>Back to <a href="http://scripts.mit.edu/~zong/wpress/?p=35">the beginning</a>.</p>
]]></content:encoded>
			<wfw:commentRss>https://blog.yhuang.org/?feed=rss2&#038;p=47</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Today I can go no farther (part 6)</title>
		<link>https://blog.yhuang.org/?p=46</link>
		<comments>https://blog.yhuang.org/?p=46#comments</comments>
		<pubDate>Sun, 31 Dec 2006 03:53:21 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[certificate store]]></category>
		<category><![CDATA[ddrescue]]></category>
		<category><![CDATA[disk]]></category>
		<category><![CDATA[external storage device]]></category>
		<category><![CDATA[hard disk recovery]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[logical conclusion]]></category>
		<category><![CDATA[recovery]]></category>
		<category><![CDATA[Seagate]]></category>
		<category><![CDATA[seagate drive]]></category>

		<guid isPermaLink="false">http://scripts.mit.edu/~zong/wpress/?p=46</guid>
		<description><![CDATA[This is part of the hard disk recovery documentation. Part 6. Today I can go no farther (so I stopped) The last days of this project are spent on two tiring tasks that do not gain me very much, but must be done to carry this project to its logical conclusion. One of these is [...]]]></description>
			<content:encoded><![CDATA[<p>This is part of the hard disk recovery documentation.</p>
<p>Part 6.</p>
<p><font color="#770033"><br />
Today I can go no farther (so I stopped)</p>
<p>The last days of this project are spent on two tiring tasks that do not gain me very much, but must be done to carry this project to its logical conclusion. One of these is to decrypt a few very small, but important NTFS-encrypted files. The other is to wring the last readable bits out of the broken Seagate drive by splitting all the error regions to isolate the unreadable regions as much as possible. These can proceed in parallel.</font><br />
<span id="more-46"></span><br />
<font color="#770033">I set Knoppix to slave away on the broken Seagate drive using ddrescue again. This ended up taking more than one day constantly running and made the disk really hot. I had to manually intervene from time to time just so this will get somewhere. This is where I wished ddrescue was smarter about skipping around unreadable regions.</p>
<p>The other task was more interesting from a learning perspective. When a file is to be encrypted by NTFS, it generates a file-specific symmetric &#8220;file encryption key&#8221; and stores the key with the file. Of course the key isn&#8217;t stored in plaintext but is encrypted using the user&#8217;s public key and is only decodeable by the user&#8217;s private key. Normally the user should export the private key into a .pfx certificate file and store it on a smart card or USB pen drive or something, and more importantly, remove it from the certificate store on Windows. I did make a copy of the private key off the computer. I could just re-import the certificate, and then decrypting the data would be trivial. But the external storage device that holds the private key isn&#8217;t with me during the break, unfortunately. On the other hand, I didn&#8217;t bother to remove the private key from the computer either, because I wasn&#8217;t really serious about this particular piece of data, just toying around with the NTFS encryption feature, mostly.</p>
<p>That made the encrypted file potentially recoverable without delay. Windows doesn&#8217;t store the user&#8217;s private key in plaintext either, of course. From what I understand, the user&#8217;s private key is encrypted somehow with user&#8217;s password hash, then maybe it is encrypted again with a master key belonging to the system. Somehow, the system&#8217;s master key is the weak link. I think it is stored in the SAM database of the system registry, which is in %SYSTEMROOT%\system32\config, though I may be mistaken on this point. The user&#8217;s various keys are stored in %USERPROFILE%\Application Data\Microsoft\Protect and %USERPROFILE%\Application Data\Microsoft\Crypto. Here is <a href="http://www.beginningtoseethelight.org/efsrecovery/index.php">another explanation</a> of this.</p>
<p>To make a long story short, if all of these files are available, and the user&#8217;s password is known, then it is possible to recover the encrypted files directly from the drive without an explicitly exported private key (hence encryption with these files around is ultimately pointless).</p>
<p>I ended up using the <a href="http://www.elcomsoft.com/aefsdr.html">Elcomsoft Advanced EFS Data Recovery</a> tool (AEFSDR). They have a trial version, too. Unfortunately it&#8217;s crippleware, unlike Mount Image Pro. All I can say is, if you really want to decrypt files, you find a way around the &#8220;cripple&#8221; in crippleware. Enough said.</p>
<p>For the record, AEFSDR is pretty good and fast. However, I am also not completely satisfied by it. I haven&#8217;t found any bugs, but the problem with it is its incompleteness. I don&#8217;t know what file system access method it uses, but it cannot see any removable drives, including removable USB drives or any mounted virtual disks (e.g. by Mount Image Pro). This is severely limiting, because encrypted files are not easily copied (Windows says Permission Denied), and I basically ran into a wall because of this. Please, AEFSDR, go work on this some more. You are selling a <b>recovery</b> tool, so your users are most likely in desperate straits with limited resources&#8230; they don&#8217;t want to deal with your programming kludges.</p>
<p>The way around it is to use NTBACKUP (part of Windows), which can archive encrypted files to a backup image, and then you can restore these files onto a permanent physical disk. After also copying the security related files from Windows to a permanent physical disk, AEFSDR decrypts all files successfully.</p>
<p>RELOADING THE DDRESCUE IMAGE</p>
<p>After I got as much as I am ever going to get out of the Seagate disk using ddrescue (I got another few tens of megabytes out of the disk), I retraced the steps on the new image. This time, the image loads as a valid NTFS partition and Windows will read it (apparently the last few bits recovered was pretty important). However, the Windows directory is still not readable, although almost all other directories are directly readable. NFI also works on the image &#8212; this is very good, as it means I can finally profile what I lost down to the last sector. I also ran chkdsk on it again &#8212; fewer errors to correct this time, but hopefully fewer zero-filled data issues to deal with at the end of the day. This chkdsk&#8217;d image is now the gold recovery image. I backed it up immediately.</p>
<p>That is the end of it. The story has a happy ending, but what a giant waste of time. Back up your data.</font></p>
<p>Lessons today:</p>
<ul>
<li>AEFSDR is nice. But I wouldn&#8217;t buy it, either.</li>
<li>Remove your private keys from the computer.</li>
<li>Near total data recovery is very possible from an apparently dead drive, but a delicate procedure needs to be followed.</li>
<li>The right tools are very important, and a complete disk recovery toolchain simply does not exist &#8212; you are left to find your own pieces.</li>
</ul>
<p>On to <a href="http://scripts.mit.edu/~zong/wpress/?p=47">the Appendix</a>.</p>
]]></content:encoded>
			<wfw:commentRss>https://blog.yhuang.org/?feed=rss2&#038;p=46</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>I rammed my head against the wall, and all was clear (part 4)</title>
		<link>https://blog.yhuang.org/?p=44</link>
		<comments>https://blog.yhuang.org/?p=44#comments</comments>
		<pubDate>Wed, 27 Dec 2006 21:23:44 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[block]]></category>
		<category><![CDATA[contiguous blocks]]></category>
		<category><![CDATA[contiguous groups]]></category>
		<category><![CDATA[disk]]></category>
		<category><![CDATA[ext2 filesystem]]></category>
		<category><![CDATA[hard disk recovery]]></category>
		<category><![CDATA[recovery]]></category>
		<category><![CDATA[Superblock]]></category>
		<category><![CDATA[system parameters]]></category>
		<category><![CDATA[Table]]></category>

		<guid isPermaLink="false">http://scripts.mit.edu/~zong/wpress/?p=44</guid>
		<description><![CDATA[This is part of the hard disk recovery documentation. Part 4. I rammed my head against the wall (of absurdity that is ext2), and all was clear The obvious need to fork off another hard disk recovery project from a hard disk recovery project was just too pathetic to think about so I kicked this [...]]]></description>
			<content:encoded><![CDATA[<p>This is part of the hard disk recovery documentation.</p>
<p>Part 4.</p>
<p><font color="#770033"><br />
I rammed my head against the wall (of absurdity that is ext2), and all was clear</p>
<p>The obvious need to fork off <b>another</b> hard disk recovery project from a hard disk recovery project was just too pathetic to think about so I kicked this aside for a day. Today I started back from the beginning, this time researching the ext2 filesystem. The documentation (that is within reach of Google) for this file system is just poor. Whoever is responsible for documenting this part of Linux should be flogged, or at least made to go home and do it over. Yeah, I can go look at the source code (which I did), but I&#8217;m sorry, that does not constitute proper documentation.<br />
</font><br />
<span id="more-44"></span><br />
<font color="#770033"><br />
What I gathered:</p>
<p>The ext2 physical structure consists of a basic unit called a block, whose size in bytes can be set at formatting time. Contiguous blocks are organized into groups, and contiguous groups make up the partition. The groups are of equal size, each containing by default 32768 blocks (on my partition a block is 4KB, so I guess a group is 128MB). </p>
<p>The next part is where I depart from the random <b>wrong</b> stuff strewn around the internet. I know they are wrong because I actually looked at the disk, but it caused me a lot of headache. The first group (Group 0) contains a 1KB filler, which some people like to call the &#8220;boot block&#8221; for unknown reasons (so far as I can tell, it doesn&#8217;t boot anything and it isn&#8217;t a block in size), followed by the 1KB Superblock (also not a block in size), which is like a filesystem header.  It carries a bunch of file system parameters, and an identifying two-byte sequence called the &#8220;magic number.&#8221;  At 4KB (for my block size) into Group 0 begins the Group Descriptor Table, which is also a filesystem header.  The Group Descriptor Table contains 32-byte entries, one entry for each group on the disk, and each entry telling the location of the block bitmap (i.e. allocation table for blocks) and the inode bitmap (i.e. allocation table for inodes) belonging to that group.</p>
<p>The subsequent groups all have the same Group Descriptor Table at the same position in the group as in Group 0, and <b>some</b> of the groups also have a copy of the 1KB Superblock at its front (not at the 1KB position). The last part is important. The first two Superblocks are <b>not</b> 32768 blocks apart.</p>
<p>That is the gist of it. I didn&#8217;t bother with the block and inode allocation strategies because those aren&#8217;t important to me.</p>
<p>So when Knoppix said the Group Descriptor Table was corrupt, it means one or more of entries are pointing to the wrong places. Also when it says could not find the Superblock due to a &#8220;bad magic number,&#8221; it most likely means the Superblock copies in other groups are all overwritten, or, not where they are expected to be found, so they or the Group Descriptor Tables can&#8217;t be used to correct the Group 0 ones.</p>
<p>To find out what happened exactly, a disk editor was needed. I used to know a pretty good one for DOS, but I lost it. However, <a href="http://www.microsoft.com/downloads/details.aspx?familyid=49AE8576-9BB9-4126-9761-BA8011FABF38&#038;displaylang=en">Windows Support Tools for Advanced Users</a> has a Windows tool (used to be in the NT resource kit) called DiskProbe (dskprobe.exe) that does the trick. It&#8217;s a bit annoying that disk positions must be counted in units of sectors (512 B), but oh well. Also the Linux tool called fsstat was used, which dumps information read from the Superblock and Group Descriptor Table out one group at a time, whatever they contain (corrupt or not).</p>
<p>What I found, from fsstat, and from comparing with another disk formatted similarly with ext2, is all the Superblock copies in the groups that should have them are there, but offset by 1KB. How this happened I do not know. Seems like a bug of mkfs to me (it has to be mkfs because where the Superblock is supposed to be resides prior data). As for the source of the problem, the Group Descriptor Table stored in Group 0 has one entry in which 4 bytes were overwritten with 0x7FFFFFFF. How <b>that</b> happened I also do not know for sure, but it is almost certainly the fault of ext2ifs, since that is the only thing to touch the partition between it working and not working. But as 4 bytes appears to be the extent of the corruption, and the backup Group Descriptor Tables are perfectly good (they just can&#8217;t be found by silly Knoppix), I just copied four bytes by hand in DiskProbe, and bam, the ext2 file system was mountable again by Knoppix.</p>
<p>The absurdity is that not only did a presumably illegal ext2 file system get written onto the disk, but also none of the ext2 fs check tools were able to find where the correct Superblocks were, even though they were just 1KB away, and furthermore, gpart, the Linux program that is supposed to guess what partitions are on the disk, could not even identify this partition as ext2, despite the Group 0 Superblock being intact and all the other structures being obviously ext2. Whoever wrote these parts of Linux should be flogged, or at least made to go home and write documentation instead.</font></p>
<p>Lessons today:</p>
<ul>
<li>The backup littering &#8220;strategy&#8221; of ext2 is only better than nothing&#8230; it is way too simple-minded and needs way too much hand-holding.</li>
<li>Not one piece of software can be trusted to do the right thing.</li>
</ul>
<p>On to <a href="http://scripts.mit.edu/~zong/wpress/?p=45">Part 5</a>.</p>
]]></content:encoded>
			<wfw:commentRss>https://blog.yhuang.org/?feed=rss2&#038;p=44</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
