Linux - SecurityThis forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
After encrypting file with gpg I have deleted source file (the unencrypted one).
For curiosity, i undeleted removed source file.
It turned out that the recovered file is encrypted with GPG!
Question:
how is that possible that recovered file is encrypted? I removed unencrypted/source file.
1. How can I tell GPG to to overwrite or replace source file?
2. I do agree with un-delete statement although small .txt files are quite successful to recover.
Also, I have quite successful un-delete results with software from this guys: https://www.cgsecurity.org/
Anyway, file that I recovered in my test was somehow GPG encrypted (and I am able to decrypt it with this same password).
I have repeated this test number of times.
I have created a small container for this test, so no other disk operation before on this file system.
Categorically speaking, filesystems do not support "un-deletion" and cannot do it reliably. Your Mileage May Vary.™
Although "secure delete" (overwrite ...) utilities do exist, once again you cannot be certain that they will, in fact, overwrite the data in every case. All applications must rely on the filesystem to perform all physical I/O and disk-space allocation tasks. You should never assume that fragments of your data – or, all of it – might not be recoverable by a forensic examination of the media.
So, continue to physically protect that media from theft and so forth. And, don't try to use computers to break the law.
Anyway, lets get back to the topic:
After encrypting file with gpg I have deleted source file (the unencrypted one).
I managed to undeleted it quite easily.
However (and this is actually good), it turned out that the recovered file is encrypted with GPG!
Questions:
1. Is there any syntax/switch to force gpg encryption to overwrite/destroy source file (yes, I know about /dev/urandom. Here I have actually even more interesting findings by overwriting gpg source file with /dev/urandom).
2. Does anyone know how come un-deleted source file is gpg encrypted?
Here it is how the restored and decrypted file looks like:
Code:
~/Desktop/x/recup_dir.1$ gpg -d f0002646.gpg
gpg: AES encrypted data
gpg: encrypted with 1 passphrase
oeri test test test
gpg: [don't know]: invalid packet (ctb=6c)
gpg: WARNING: encrypted message has been manipulated!
gpg: [don't know]: invalid packet (ctb=70)
1. Encrypt source file, producing message.txt.gpg, message.txt still exists
2. rm message.txt
3. Attempt to undelete message.txt, recover only encrypted data
I don't believe there is anything gpg could be doing to destroy the data in step 2, since it is not even being run at that point. It is simply a coincidence that you failed to recover the data of message.txt. Since it is a small test file that you created recently, maybe it stayed in cache, and was never actually written to disk?
Yes, that is exactly the sequence!
Following your advice, I have reproduced scenario with big file - over 100mb. And in this case, recovery output was split into a few UNENCRYPTED files (content looks good).
Then I reproduced the case scenario with small file again.
This time however, I did system shutdown/start up a couple of times (after gpg encryption and after file deletion) to make sure there is no cache leftovers. (i do the test in a small LUKS container, to isolate filesystem)
Recovery output is ENCRYPTED file, though.
That really blows my mind – why?
Additional question: what is the best practice once file is encrypted with gpg? Overwrite source with /dev/urandom ?
Then I reproduced the case scenario with small file again.
This time however, I did system shutdown/start up a couple of times (after gpg encryption and after file deletion) to make sure there is no cache leftovers. (i do the test in a small LUKS container, to isolate filesystem)
Recovery output is ENCRYPTED file, though.
That really blows my mind – why?
The shutdown procedure may have overwritten the deleted unencrypted data blocks.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.