From: Arno Wagner <arno@wagner.name>
To: dm-crypt@saout.de
Subject: Re: [dm-crypt] Extract master key from running system
Date: Thu, 28 Jul 2011 07:04:28 +0200 [thread overview]
Message-ID: <20110728050428.GA5441@tansi.org> (raw)
In-Reply-To: <6A594D5B-7048-4A81-AA1A-E2F5C895E9F4@gmail.com>
On Wed, Jul 27, 2011 at 08:07:24PM -0700, Brian wrote:
> Hi all -
>
> Sorry to ask such a noob question, but the FAQ states in the section on
> "Why is all my data permanently gone if I overwrite the LUKS header?": "If
> your header does not contain an intact salt, best go directly to the last
> stage ("Acceptance") and think about what to do now. There is one
> exception that I know of: If your LUKS container is still open, then it
> may be possible to extract the master key from the running system. Ask on
> the mailing-list on how to do that and make sure nobody switches off the
> machine."
>
> If anybody can help fill in the blanks there I'd very much appreciate it.
> I'm on the verge of the acceptance stage of grieving myself, but realized
> that I might fall into this category - the external drive was removed, and
> initialized on a new machine - never properly closed the container, and
> the machine is still running. I also still see the dm device. I believe
> the LUKS header is trashed on disk - isLuks gives 234 return, luksDump
> tells me it's not a valid LUKS device. Any way to recover here? Or do I
> accept?
I have to admit that there is no info in the FAQ because when I wrote
that I did not have time to find out. In the mean time I have had
an opportunity to do so, so I should probably update the FAQ. First,
I think trying to dump will not create additional damage. Here is what
works on my machine:
cryptsetup luksDump --dump-master-key
This asks first for a "YES" and then for a valid passphrase.
Result looks like this (test-container via losetup):
LUKS header information for /dev/loop0
Cipher name: aes
Cipher mode: cbc-essiv:sha256
Payload offset: 4096
UUID: 79c87d87-a8c0-4967-b1e4-4c54a11b8b93
MK bits: 256
MK dump: 7d b6 99 d8 3a 09 97 51 92 fa 99 47 b4 bf 33 01
a2 12 0e b3 0d 41 f1 c5 e8 78 e3 78 fe eb 1b d8
If you get this, then you have the real, not protected master
key. The way to use it is to convert the hex digits of the
MK dump into a binary file, e.g. using hexedit.
No idea whether this can be done easier, but this approach
worked in an experiment I did.
Then you can use that file with "luksFormat --master-key-file ..."
and, given all other parameters are the same (not the salt, just
the parameters passed on the old luksFormat call) you should then
be able to open the device again.
Safety precaution 1: Make a backup of the first 100MB of
the disk if something goes wrong.
Safety precaution 2: Do a normal "cryptsetup luksDump <device>"
after you get the master key, just in case some parameters are
not the defaults or this container was created with an
cryptsetup with different defaults.
Note: You may have some filesystem damage on inside the
container, depending on what type of "initialization"
was done.
Arno
--
Arno Wagner, Dr. sc. techn., Dipl. Inform., CISSP -- Email: arno@wagner.name
GnuPG: ID: 1E25338F FP: 0C30 5782 9D93 F785 E79C 0296 797F 6B50 1E25 338F
----
Cuddly UI's are the manifestation of wishful thinking. -- Dylan Evans
If it's in the news, don't worry about it. The very definition of
"news" is "something that hardly ever happens." -- Bruce Schneier
next prev parent reply other threads:[~2011-07-28 5:04 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-28 3:07 [dm-crypt] Extract master key from running system Brian
2011-07-28 5:04 ` Arno Wagner [this message]
2011-07-28 7:14 ` Milan Broz
2011-07-30 18:42 ` Arno Wagner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110728050428.GA5441@tansi.org \
--to=arno@wagner.name \
--cc=dm-crypt@saout.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox