public inbox for cryptsetup@lists.linux.dev
 help / color / mirror / Atom feed
From: Milan Broz <gmazyland@gmail.com>
To: Rafal Babinicz <babiniczr@gmail.com>, cryptsetup@lists.linux.dev
Subject: Re: echo "pass" piped to sudo tee cryptsetup luksOpen overwritten LUKS partition
Date: Sat, 30 Nov 2024 17:45:48 +0100	[thread overview]
Message-ID: <65f3cf0c-e421-40d4-affe-e757fa68f6c9@gmail.com> (raw)
In-Reply-To: <CANbVO27bAb9E+Vt6k1J4VGSj18aY950Lq=ZqucBDJbfO4NLThQ@mail.gmail.com>

On 11/30/24 2:36 PM, Rafal Babinicz wrote:
> During disk replacement I rendered my old LUKS encrypted disk unrecognized (my verbatim shell history attached).

You just discovered why LUKS header backup is kind of useful.

> TL:DR can I revert what I did there? Especially that line:
> $ echo "passphrase" | sudo tee cryptsetup luksOpen /dev/sdb3 enc

So this is the tee command what overwritten the header, not cryptsetup.

That said, you perhaps overwrote only 48 bytes.

Try this:

# create a fake container
truncate -s 16M fake.img

# format it with the same cipher you had in your image (password is not important)
echo | cryptsetup luksFormat --type luks1 --cipher aes-xts-plain64 fake.img

# replace these 48 bytes (it contain magic, version and cipher only)
dd if=fake.img of=luksheaderdamage.img bs=48 count=1 conv=notrunc

Now the image is LUKS1 gain, try you password.

The one you provided is not correct, so either you redacted it or something else happened.

BTW with LUKS2 format this would be fixed automatically as there is backup header.

Milan


      parent reply	other threads:[~2024-11-30 16:45 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-30 13:36 echo "pass" piped to sudo tee cryptsetup luksOpen overwritten LUKS partition Rafal Babinicz
2024-11-30 16:23 ` Michael Kjörling
2024-11-30 16:45 ` Milan Broz [this message]

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=65f3cf0c-e421-40d4-affe-e757fa68f6c9@gmail.com \
    --to=gmazyland@gmail.com \
    --cc=babiniczr@gmail.com \
    --cc=cryptsetup@lists.linux.dev \
    /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