Reputation: 329
Recently I decided to encrypt my engineering log using vim's :X encryption feature. I wrote down the password, but evidently I misspelled something or messed something up because decrypting the file just gives gibberish. To make matters worse, all my backups are somehow corrupted (don't ask, I am not sure how either).
I am not going to make excuses: I know I messed up. Right now I want to focus on how I can fix the mess I've made.
Here's what I've tried:
Use vimzipper to wrap the encrypted file in a zip so it can be cracked by standard zip crackers like fcrackzip, zipcracker, pkcrack, Advanced Zip Password Recovery, etc. Unfortunately this hasn't worked. I recovered a line of plaintext from the file using the leftover info from the registers in my VIMINFO, but I don't have the offset in the file for the recovered plaintext. Regardless, the zip cracking hasn't worked, even for a simple test file with a three-character vim password.
Recovery of the swapfile didn't work. When I re-opened the encrypted file with the bad password, vim overwrote the "good" swapfile.
Run unixcrypt-breaker with a large database of plaintext (~30 books from Project Gutenberg) as reference data. This results in gibberish, even if I only seed unixcrypt-breaker with the recovered plaintext. Additionally, I can't seem to break even a simple test file encrypted with vim using this method. (FYI, I am stripping the VimCrypt~01! magic header before I run the decryption and I strip it off using vim in PASTE mode so I don't otherwise alter the file's contents).
Desperately guess every password and misspelling I can imagine. I have spent at least six hours guessing what I could possibly have spelled wrong. :)
In order to rapidly try passwords from a program, I tried compiling an old UNIX copy of crypt/makekey, but the result of that is not the same as the same file being encrypted using vim's -x encryption and the same password.
If anyone can help, I'd hugely appreciate it. If not, thanks for reading. :)
Upvotes: 32
Views: 26843
Reputation: 2621
This question is quite old. Here is a modern solution:
Use hashcat (https://hashcat.net/hashcat/). Hashcat has a plugins for a wide set for cryptography algorithms and it allows you to specify and seed your (brute force starting point-) dictionary file with hints you still remember about your lost password.
Upvotes: 1
Reputation: 92835
This ancient newsgroup post had a similar problem to yours:
My problem was that I had accidentally encrypted a script using vi and could not recall the key. many thanks to all those who responded.
Suggestions were as follows:
- use vi -x and guess the key (I had tried that without success)
- write a program which makes a crypt call and tries the likely key combinations. the person who suggested this reckoned it would take about 5 minutes to crack
- download CWB (crypt breakers work bench) form the archives which will help to crack
- post the problem to sci.crypt.newsgroup including the first 128 bytes of the file after encryption and these bytes before encryption (if i could remember) and somebody in the group might crack it for me
- re-type the script
One crib you have towards breaking this is you know what the password "should" have been. So, even if you had a random typo, it would still slightly resemble your intended password. Maybe you could start there, write a program to generate all possible combinations of your intended password with 1 or 2 character mispellings-additions.
In any case, what a neat exercise / diversion!
Upvotes: 5
Reputation: 14084
From the VIM documentation:
If it was feasible on a Pentium 133, I think you have a very good chance. :)
I would either use #vim to ask for details on the algorithm or browse through the source code to figure out how the encryption is working and then write a cryptanalysis program.
Upvotes: 26
Reputation: 13604
Is it possible that you could have data corruption issues in addition to your encryption problems?
If I was going to brute force this, I think I would write an algorithm that would start to try all variations of the passwords I could have used before moving on to dictionary attacks. Yet, after hearing your story - I have this nagging feeling that you didn't forget your password, but rather there was a data corruption issue somewhere along the way that messed up your password/crypttext/cryptokey/whatever.
Upvotes: 10
Reputation: 42692
Not sure if this may help:
Explains how to break a file encrypted with "crypt", might give you a starting point (at least with older versions of vi, the encryption was based on crypt).
Upvotes: 8