LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 01-19-2020, 03:56 AM   #1
z0gnadal
LQ Newbie
 
Registered: Jan 2020
Posts: 8

Rep: Reputation: Disabled
Can't unlock encrypted disk


I use Debian default encryption disk encryption. Only /boot it's not encrypted. When I boot I need to type my password, and then I will be logged in. But now I can't login. It always says that I typed the wrong password, but I typed the correct password.

I tried to boot in live-CD and try unlock volume from there. But It always says wrong password.
Before that I had an achieve that had a 90GB file in it and I tried to underachieve it, but it gave me error not enough space. I get notification that I'm out of space 600mb left, but when type df -h I saw I have same amount of space as before I start to unarchieving file. Looks like file was autodeleted by Debian system.
I have no BADs on disk. Sometimes I have some issues with RAM module and I my PC stucks but I always can unlock the disk. In that case I need to clean RAM module and PC is not stucking anymore. I tried remove RAM modules and boot with only one of them, but still can't unlock disk. I have 2 HDDs with Debian and only one of them is not unlocking. Other one is working fine.
https://i.postimg.cc/gYjmdvw5/1.jpg

When I try to boot like this
https://i.postimg.cc/k4ZDcchY/2.jpg
I get this
https://i.postimg.cc/CxVmhys7/3.jpg
When I boot like this
https://i.postimg.cc/YSCN0tG6/4.jpg
I get
https://i.postimg.cc/wT5Dk1D5/5.jpg
https://i.postimg.cc/d0fC0rKF/6.jpg
 
Old 01-20-2020, 12:39 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,804

Rep: Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306
I would say this is a problem with the disk, you need to find the first error. In picture 3 there is an nvidia related error too.
Or probably something else, but we have no information to say more.
 
1 members found this post helpful.
Old 01-20-2020, 01:41 AM   #3
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
Quote:
Originally Posted by z0gnadal View Post
It always says wrong password.
If the password is correct and the LUKS header is corrupted, you can recreate the header from a header backup. See point 4.2 of the cryptsetup FAQ. The answer also suggests a way to guess whether the keyslot is corrupted.

If the header is OK but the password is not correct, this is a case for cryptsetup luksAddKey. A LUKS header has room for 8 pass phrases, as the luksDump command shows. Too late in your case, but perhaps next time?
You could also try a password cracker, but that would take time and powerful computers.

Also, if the encrypted data is useful, back it up (i.e. not only a LUKS header backup).

I am afraid these would be the only options to get your data back.

Last edited by berndbausch; 01-20-2020 at 01:43 AM. Reason: wording
 
2 members found this post helpful.
Old 01-20-2020, 11:03 AM   #4
z0gnadal
LQ Newbie
 
Registered: Jan 2020
Posts: 8

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by pan64 View Post
I would say this is a problem with the disk, you need to find the first error. In picture 3 there is an nvidia related error too.
Or probably something else, but we have no information to say more.
I checked disk and there was no Bad sectors. Nvidia related error was always from start. Just say what information and I will provide it.

Quote:
Originally Posted by berndbausch View Post
If the password is correct and the LUKS header is corrupted, you can recreate the header from a header backup. See point 4.2 of the cryptsetup FAQ. The answer also suggests a way to guess whether the keyslot is corrupted.

If the header is OK but the password is not correct, this is a case for cryptsetup luksAddKey. A LUKS header has room for 8 pass phrases, as the luksDump command shows. Too late in your case, but perhaps next time?
You could also try a password cracker, but that would take time and powerful computers.

Also, if the encrypted data is useful, back it up (i.e. not only a LUKS header backup).

I am afraid these would be the only options to get your data back.
I think screenshots show header is not corrupted, but I'm not sure I'm not expert in Linux.
Yes too late now, now I can't cryptsetup luksAddKey. I didn't even think that header/encryption... can get corrupted without reason. I was using PC just like always.
If I can't recover data and it's lost forever. Is there a way I find the reason why this happen ?
 
Old 01-20-2020, 01:06 PM   #5
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
Quote:
Originally Posted by z0gnadal View Post
I didn't even think that header/encryption... can get corrupted without reason. I was using PC just like always.
A cosmic ray turning a single bit is enough. The header doesn't have a checksum; just by looking at the output you can't judge if it's corrupted.
Quote:
If I can't recover data and it's lost forever. Is there a way I find the reason why this happen ?
I doubt it. Best guess is checking the system log.
 
1 members found this post helpful.
Old 01-20-2020, 02:05 PM   #6
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,776

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
For people using something other than the default "US English" keyboard mapping, LUKS keyslot problems are often traced to mapping issues. Is there any chance that this is the problem?

The only tool that attempts to check for corrupted keyslot data is the chk_luks_keyslots program that is referenced in FAQ section 4.2. That tool evaluates the "randomness" of the keyslot data, and any block with a low randomness score is an indication that the block may have been overwritten. That tool must be compiled from the misc/ directory in the cryptsetup source. There is no other test for corruption of the keyslot data.

The LUKS header is deliberately designed so that any corruption makes the key unrecoverable. The only protection against that is having a backup of the LUKS header.
 
2 members found this post helpful.
Old 01-20-2020, 10:34 PM   #7
z0gnadal
LQ Newbie
 
Registered: Jan 2020
Posts: 8

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by berndbausch View Post
A cosmic ray turning a single bit is enough. The header doesn't have a checksum; just by looking at the output you can't judge if it's corrupted.

I doubt it. Best guess is checking the system log.
Seems I can't because I can't login. Is there any other way to check system logs ?

Quote:
Originally Posted by rknichols View Post
For people using something other than the default "US English" keyboard mapping, LUKS keyslot problems are often traced to mapping issues. Is there any chance that this is the problem?

The only tool that attempts to check for corrupted keyslot data is the chk_luks_keyslots program that is referenced in FAQ section 4.2. That tool evaluates the "randomness" of the keyslot data, and any block with a low randomness score is an indication that the block may have been overwritten. That tool must be compiled from the misc/ directory in the cryptsetup source. There is no other test for corruption of the keyslot data.

The LUKS header is deliberately designed so that any corruption makes the key unrecoverable. The only protection against that is having a backup of the LUKS header.
I'm not sure, but I boot in initramfs and checked. Text look like English text. I'm using English but not sure US or other one.
Can I chk_luks_keyslots from live cd ? I just need to repeat all actions from README and just replace /dev/loop0 with /dev/sda6 in my case?
 
Old 01-20-2020, 11:19 PM   #8
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
Quote:
Originally Posted by z0gnadal View Post
Seems I can't because I can't login. Is there any other way to check system logs ?
If they are encrypted, no. I realize that my suggestion was not very useful.

Quote:
I'm not sure, but I boot in initramfs and checked. Text look like English text. I'm using English but not sure US or other one.
Can I chk_luks_keyslots from live cd ? I just need to repeat all actions from README and just replace /dev/loop0 with /dev/sda6 in my case?
Personally I have never done that, but I don't see a reason why it shouldn't work from a live CD.
 
1 members found this post helpful.
Old 01-21-2020, 08:32 AM   #9
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,776

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
Quote:
Originally Posted by z0gnadal View Post
Can I chk_luks_keyslots from live cd ?
Quote:
Originally Posted by berndbausch View Post
Personally I have never done that, but I don't see a reason why it shouldn't work from a live CD.
I don't know of any live CD that includes that program. A compiled chk_luks_keyslots isn't typically distributed as part of the cryptsetup package. You have to download the source on a Linux system with development tools installed and compile it yourself. I have no idea why that tool is buried that way.
 
2 members found this post helpful.
Old 01-21-2020, 10:41 AM   #10
z0gnadal
LQ Newbie
 
Registered: Jan 2020
Posts: 8

Original Poster
Rep: Reputation: Disabled
Thank you
I duplicate this:
I just need to repeat all actions from README and just replace /dev/loop0 with /dev/sda6 in my case?
Sorry for flood, but just want to be sure that I don't destroy/damage anything on that disk or other disk
 
Old 01-21-2020, 12:19 PM   #11
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,776

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
Quote:
Originally Posted by z0gnadal View Post
I just need to repeat all actions from README and just replace /dev/loop0 with /dev/sda6 in my case?
Sorry for flood, but just want to be sure that I don't destroy/damage anything on that disk or other disk
Yes. The chk_luks_keyslots program does not write anything to the device it is checking. It's only output is messages to the terminal.
 
Old 01-22-2020, 09:46 AM   #12
slac-in-the-box
Member
 
Registered: Mar 2010
Location: oregon
Distribution: slackware64-15.0 / slarm64-current
Posts: 779
Blog Entries: 1

Rep: Reputation: 432Reputation: 432Reputation: 432Reputation: 432Reputation: 432
Quote:
Originally Posted by rknichols View Post
The only protection against that is having a backup of the LUKS header.
Thanks. This has prompted me to back up the LUKS headers on the multiple encrypted drives around our home... I knew that, and have even lost a TB of family media to this exact problem in the past, and still sometimes forget on a fresh install to backup the headers. I am going to suggest to the maintainer of my favorite distro that he includes this step in his README_CRYPT, the file with LUKS instructions for slackware.

Code:
cryptsetup luksHeaderBackup /dev/sda# --header-backup-file ~/luksheaderbak
scp ~/luksheaderbak rem.ote.ip:~/
(pointless to have a header backup in the encrypted volume, so I copied it to another device.)

Question: Is the key contained in the header? If an attacker had this header's backup, would they be able to retrieve a key from it, with this chk_luks_keyslots program? If so, that explains why you have to custom compile it in. I never tape my passwords under my desk drawer--they're all in my head--but a file that could unlock everything, I must now protect too.
 
Old 01-22-2020, 12:24 PM   #13
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,776

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
Quote:
Originally Posted by slac-in-the-box View Post
Question: Is the key contained in the header? If an attacker had this header's backup, would they be able to retrieve a key from it, with this chk_luks_keyslots program? If so, that explains why you have to custom compile it in. I never tape my passwords under my desk drawer--they're all in my head--but a file that could unlock everything, I must now protect too.
That backup header is just a binary copy of the first ~2MB (larger for LUKS2) of the LUKS container. The header contains copies of the master key encrypted by each of the up to 8 allowed passphrases/keyfiles. Having a copy of that header would allow an adversary to perform an offline guessing attack attempting to discover a passphrase.
 
1 members found this post helpful.
Old 01-22-2020, 12:43 PM   #14
z0gnadal
LQ Newbie
 
Registered: Jan 2020
Posts: 8

Original Poster
Rep: Reputation: Disabled
I want to compile keyslot_checker , but I get error
Code:
gcc -lm -lcryptsetup chk_luks_keyslots.c -o chk_luks_keyslots 
chk_luks_keyslots.c:39:27: fatal error: libcryptsetup.h: No such file or directory
 #include <libcryptsetup.h>
in FAQ they say
Code:
 There is a tool that
automatizes this in the cryptsetup distribution from version 1.6.0
onwards.  It is located in misc/keyslot_checker/.  Instructions how
to use and how to interpret results are in the README file.  Note
that this tool requires a libcryptsetup from cryptsetup 1.6.0 or
later (which means libcryptsetup.so.4.5.0 or later).  If the tool
complains about missing functions in libcryptsetup, you likely have
an earlier version from your distribution still installed.  You can
either point the symbolic link(s) from libcryptsetup.so.4 to the new
version manually, or you can uninstall the distribution version of
cryptsetup and re-install that from cryptsetup >= 1.6.0 again to fix
this.
but I use version newer than 1.6.0
Code:
 apt-cache policy cryptsetup
cryptsetup:
  Installed: 2:1.7.3-4
  Candidate: 2:1.7.3-4
  Version table:
 *** 2:1.7.3-4 100
        100 /var/lib/dpkg/status
How can I fix this ? I don't understand how to point the symbolic link(s) from libcryptsetup.so.4 to the new version manually.
 
Old 01-22-2020, 04:06 PM   #15
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
The FAQ you cite has nothing to do with your problem. The FAQ is about running the program, but you don't even have a program yet that can be run. You need to compile it first.

Your problem is likely that you have to download the entire source code including the missing header file, not just chk_luks_keyslots.c. Or that header file is not at a location where the compiler finds it.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: How to Lock and Unlock User in Linux How to Lock and Unlock User in Linux LXer Syndicated Linux News 0 11-10-2019 06:21 PM
LXer: Wildfire ransomware code cracked: Victims can now unlock encrypted files for free LXer Syndicated Linux News 0 08-24-2016 10:51 PM
Can mkinitrd unlock an encrypted device identified by uuid? michaelslack Slackware 3 03-28-2015 06:01 AM
Slackware 14.1: LUKS encrypted volumes + mkinitrd => missing dmsetup and can't unlock furryspider Slackware 4 11-16-2013 09:58 AM
LXer: Automatically Unlock LUKS Encrypted Drives With A Keyfile LXer Syndicated Linux News 0 07-09-2008 03:40 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 08:52 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration