You are not logged in.

#1 2018-03-11 17:40:12

archicon
Member
Registered: 2016-05-29
Posts: 2

Can't decrypt Luks container

Hello guys,

I think I'm in trouble: I have messed up with a luks container running 'fsck' before opening it...

sudo e2fsck /dev/mapper/vault-backup 
e2fsck 1.42.11 (09-Jul-2014)
ext2fs_open2: Numéro magique invalide dans le super-bloc
e2fsck : Superbloc invalide, tentons d'utiliser les blocs de sauvetage...
le superbloc a un journal invalide (i-noeud 8).
Effacer<o>? oui
*** ext3 journal has been deleted - filesystem is now ext2 only ***

L'i-noeud de changement de taille n'est pas valide. Recréer<o>? oui
e2fsck : Bloc triplement indirect illégal repéré lors de la lecture de l'i-noeud des blocs défectueux
Cela ne semble pas être bien, mais on va quand même essayer...
Passe 1 : vérification des i-noeuds, des blocs et des tailles
L'i-noeud des blocs défectueux a l'air invalide. Effacer<o>? oui
l'i-noeud racine n'est pas un répertoire. Effacer<o>? oui
L'i-noeud de quota n'est pas utilisé mais contient des données. Effacer<o>? oui
L'i-noeud de quota n'est pas utilisé mais contient des données. Effacer<o>? oui
l'i-noeud 5 a le drapeau de compression qui est initialisé sur un système de fichiers sans support de compression. Effacer<o>? 
Recréer le journal<o>? annulé !
/dev/mapper/vault-backup : e2fsck a été annulé.

Since that terrible mistake, cryptsetup claimed that there is no key related to my passphrase and I can't access my data no more.

sudo cryptsetup luksOpen /dev/vault/backup backup
Enter passphrase for /dev/vault/backup: 
No key available with this passphrase.
sudo lvdisplay /dev/vault/backup 
  --- Logical volume ---
  LV Path                /dev/vault/backup
  LV Name                backup
  VG Name                vault
  LV UUID                YEtSCj-5o59-ENwX-wj5C-meGb-n82y-A3SAY0
  LV Write Access        read/write
  LV Creation host, time , 
  LV Status              available
  # open                 0
  LV Size                500,00 GiB
  Current LE             128000
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           254:1

Do you guys think there is a solution?

Thanks in advance.

Last edited by archicon (2018-03-11 18:15:39)

Offline

#2 2018-03-11 17:58:59

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,426
Website

Re: Can't decrypt Luks container


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#3 2018-03-11 18:07:08

loqs
Member
Registered: 2014-03-06
Posts: 19,113

Re: Can't decrypt Luks container

@jasonwryan that would entail running fsck on the luks container again which on its first run appears to have corrupted the luks header.
Edit:
@archicon unless you have a backup of the luks header from `cryptsetup luksHeaderBackup`  if either your key or the masterkey has been altered the data should be unrecoverable.

Last edited by loqs (2018-03-11 18:09:49)

Offline

#4 2018-03-11 18:15:16

frostschutz
Member
Registered: 2013-11-15
Posts: 1,658

Re: Can't decrypt Luks container

It's gone completely. With LUKS headers, if you change a single bit, it stops working. fsck, if you answer yes like you did, it zaps almost the entire LUKS header.

Check it out with hexdump, a valid LUKS header looks like this:

# hexdump -C -n $((2*1024*1024)) /dev/luksthing
00000000  4c 55 4b 53 ba be 00 01  61 65 73 00 00 00 00 00  |LUKS....aes.....|
00000010  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000020  00 00 00 00 00 00 00 00  78 74 73 2d 70 6c 61 69  |........xts-plai|
00000030  6e 36 34 00 00 00 00 00  00 00 00 00 00 00 00 00  |n64.............|
00000040  00 00 00 00 00 00 00 00  73 68 61 32 35 36 00 00  |........sha256..|
00000050  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000060  00 00 00 00 00 00 00 00  00 00 10 00 00 00 00 20  |............... |
00000070  9b aa ba 0e a8 9c 29 9f  59 5f a2 6e 23 86 19 cf  |......).Y_.n#...|
00000080  69 66 84 0a a1 93 46 0d  39 41 f3 ef ea 51 d8 c0  |if....F.9A...Q..|
00000090  94 93 29 bd 58 18 63 5f  77 b2 a7 4c 6a e0 83 2b  |..).X.c_w..Lj..+|
000000a0  01 a3 40 27 00 03 3f 2b  38 61 33 61 32 62 66 61  |..@'..?+8a3a2bfa|
000000b0  2d 30 38 63 33 2d 34 65  36 66 2d 39 30 64 31 2d  |-08c3-4e6f-90d1-|
000000c0  63 61 38 65 34 66 64 33  62 35 39 65 00 00 00 00  |ca8e4fd3b59e....|
000000d0  00 ac 71 f3 00 33 f2 b2  d3 d8 6e d5 73 ee f7 0f  |..q..3....n.s...|
000000e0  57 10 b8 10 9d b3 ef 8d  8f 2b d7 2a e8 22 7b b4  |W........+.*."{.|
000000f0  0e a4 24 5b 8c 1e 78 af  00 00 00 08 00 00 0f a0  |..$[..x.........|
00000100  00 00 de ad 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000110  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000120  00 00 00 00 00 00 00 00  00 00 01 08 00 00 0f a0  |................|
00000130  00 00 de ad 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000140  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000150  00 00 00 00 00 00 00 00  00 00 02 08 00 00 0f a0  |................|
00000160  00 00 de ad 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000170  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000180  00 00 00 00 00 00 00 00  00 00 03 08 00 00 0f a0  |................|
00000190  00 00 de ad 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000001a0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000001b0  00 00 00 00 00 00 00 00  00 00 04 08 00 00 0f a0  |................|
000001c0  00 00 de ad 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000001d0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000001e0  00 00 00 00 00 00 00 00  00 00 05 08 00 00 0f a0  |................|
000001f0  00 00 de ad 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000200  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000210  00 00 00 00 00 00 00 00  00 00 06 08 00 00 0f a0  |................|
00000220  00 00 de ad 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000230  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000240  00 00 00 00 00 00 00 00  00 00 07 08 00 00 0f a0  |................|
00000250  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00001000  d4 29 5c 21 b9 c0 3d ad  f5 07 68 1a 33 5a d5 e9  |.)\!..=...h.3Z..|
00001010  4d 15 76 c2 27 d7 86 8a  ba d6 e8 e2 c6 69 ba 6d  |M.v.'........i.m|
00001020  7a 10 fe 04 5e 2b 5c 66  c9 88 c4 10 17 53 06 14  |z...^+\f.....S..|
### ... 128K of random key material per used key slot ... ###
000203d0  2e c8 96 22 6a e9 c5 94  12 1d 21 f5 54 0a f0 7b  |..."j.....!.T..{|
000203e0  55 53 1a e8 43 35 2f e7  bb 5d f1 83 d5 3a 6e 9c  |US..C5/..]...:n.|
000203f0  23 6a 15 37 ef 6e bd 26  9d 26 63 de 04 6f 35 81  |#j.7.n.&.&c..o5.|

After fsck:

00000000  4c 55 4b 53 ba be 00 01  61 65 73 00 00 00 00 00  |LUKS....aes.....|
00000010  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000020  00 00 00 00 00 00 00 00  78 74 73 2d 70 6c 61 69  |........xts-plai|
00000030  6e 36 34 00 00 00 00 00  00 00 00 00 00 00 00 00  |n64.............|
00000040  00 00 00 00 00 00 00 00  73 68 61 32 35 36 00 00  |........sha256..|
00000050  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000060  00 00 00 00 00 00 00 00  00 00 10 00 00 00 00 20  |............... |
00000070  9b aa ba 0e a8 9c 29 9f  59 5f a2 6e 23 86 19 cf  |......).Y_.n#...|
00000080  69 66 84 0a a1 93 46 0d  39 41 f3 ef ea 51 d8 c0  |if....F.9A...Q..|
00000090  94 93 29 bd 58 18 63 5f  77 b2 a7 4c 6a e0 83 2b  |..).X.c_w..Lj..+|
000000a0  01 a3 40 27 00 03 3f 2b  38 61 33 61 32 62 66 61  |..@'..?+8a3a2bfa|
000000b0  2d 30 38 63 33 2d 34 65  36 66 2d 39 30 64 31 2d  |-08c3-4e6f-90d1-|
000000c0  63 61 38 65 34 66 64 33  62 35 39 65 00 00 00 00  |ca8e4fd3b59e....|
000000d0  00 ac 71 f3 00 33 f2 b2  d3 d8 6e d5 73 ee f7 0f  |..q..3....n.s...|
000000e0  57 10 b8 10 9d b3 ef 8d  8f 2b d7 2a e8 22 7b b4  |W........+.*."{.|
000000f0  0e a4 24 5b 8c 1e 78 af  00 00 00 08 00 00 0f a0  |..$[..x.........|
00000100  00 00 de ad 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000110  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000120  00 00 00 00 00 00 00 00  00 00 01 08 00 00 0f a0  |................|
00000130  00 00 de ad 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000140  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000150  00 00 00 00 00 00 00 00  00 00 02 08 00 00 0f a0  |................|
00000160  00 00 de ad 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000170  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000180  00 00 00 00 00 00 00 00  00 00 03 08 00 00 0f a0  |................|
00000190  00 00 de ad 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000001a0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000001b0  00 00 00 00 00 00 00 00  00 00 04 08 00 00 0f a0  |................|
000001c0  00 00 de ad 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000001d0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000001e0  00 00 00 00 00 00 00 00  00 00 05 08 00 00 0f a0  |................|
000001f0  00 00 de ad 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000200  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000210  00 00 00 00 00 00 00 00  00 00 06 08 00 00 0f a0  |................|
00000220  00 00 de ad 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000230  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000240  00 00 00 00 00 00 00 00  00 00 07 08 00 00 0f a0  |................|

first sector is still okay but afterwards it's all gone

00001000  04 20 00 00 04 60 00 00  04 a0 00 00 04 e0 00 00  |. ...`..........|
00001010  04 20 01 00 00 00 00 00  00 00 00 00 00 00 00 00  |. ..............|
00001020  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00001400  05 20 00 00 05 60 00 00  05 a0 00 00 05 e0 00 00  |. ...`..........|
00001410  05 20 01 00 00 00 00 00  00 00 00 00 00 00 00 00  |. ..............|
00001420  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00001800  06 20 00 00 06 60 00 00  06 a0 00 00 06 e0 00 00  |. ...`..........|
00001810  06 20 01 00 00 00 00 00  00 00 00 00 00 00 00 00  |. ..............|
00001820  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00001c00  07 20 00 00 07 60 00 00  07 a0 00 00 07 e0 00 00  |. ...`..........|
00001c10  07 20 01 00 00 00 00 00  00 00 00 00 00 00 00 00  |. ..............|
00001c20  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00002000  08 20 00 00 08 60 00 00  08 a0 00 00 08 e0 00 00  |. ...`..........|
00002010  08 20 01 00 00 00 00 00  00 00 00 00 00 00 00 00  |. ..............|
00002020  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00002400  09 20 00 00 09 60 00 00  09 a0 00 00 09 e0 00 00  |. ...`..........|
00002410  09 20 01 00 00 00 00 00  00 00 00 00 00 00 00 00  |. ..............|
00002420  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00002800  0a 20 00 00 0a 60 00 00  0a a0 00 00 0a e0 00 00  |. ...`..........|
00002810  0a 20 01 00 00 00 00 00  00 00 00 00 00 00 00 00  |. ..............|
00002820  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00002c00  0b 20 00 00 0b 60 00 00  0b a0 00 00 0b e0 00 00  |. ...`..........|
00002c10  0b 20 01 00 00 00 00 00  00 00 00 00 00 00 00 00  |. ..............|
00002c20  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00003000  0c 20 00 00 0c 60 00 00  0c a0 00 00 0c e0 00 00  |. ...`..........|
00003010  0c 20 01 00 00 00 00 00  00 00 00 00 00 00 00 00  |. ..............|
00003020  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*

if the container was still open, you could get the masterkey with `dmsetup table --showkeys`

if you had a backup of the LUKS header as a whole (not just luksDump) you could also recover something

otherwise game over

Last edited by frostschutz (2018-03-11 18:17:41)

Offline

#5 2018-03-11 18:19:58

archicon
Member
Registered: 2016-05-29
Posts: 2

Re: Can't decrypt Luks container

That's what I thought...

Will do backup next time.

Thank you for demonstration.

Offline

Board footer

Powered by FluxBB