1

I'm in an interesting predicament. I have an encrypted 7z file that I made myself. The password for the file is a 60 character generated password that I saved to my password manager. I made sure to test the password before putting anything in the encrypted file, to make sure I could reopen it. It's now a few months later and I'm trying to open the encrypted file and the password isn't working. ("Cannot open encrypted archive F:\secretstuff.7z. Wrong password?")

I know brute forcing a 60 character password would takes years, but since I have the expected password is there some software out there that takes the password and makes mutations of it until it can create a password that matches the file hash? I'm suspecting that I accidentally added a character somewhere when setting up the encrypted file, that didn't make it into the password manager or the 7zip GUI has a max password character limit for creating encrypted files that I hit without knowing it.

I have tried looking around but all I could find software's that use a dictionary attacks or brute force to crack the password. Both are useless because dictionary would only work if it is an easy to guess password, but mines is randomly generated and the brute force method would likely succeed long after I had died of old age (assuming the password is a mutation of the original password). I have used John the ripper to extract the file hash, but I have no idea what to do now. Any ideas or solutions that you think I should try would be greatly appreciated.

here is the expected password (not working): 4^^#iy3N3Et9LG$3kws!Qqz$VN$WF8r5h5$dS9FM$2JfQUjkmd%2778#X3&M

This is the file hash

$7z$1$19$0$$16$952ddf6c15b3bf407457d6857b90e456$1012580813$656$655$feeb649b24a30685f27d3acbf5f070147828709151dd779714f3d09095ba26744f31f48c466209a4077e3335bc242561d3b9fd8b65f38264f8b246c5a534e1f59a65997b48e0a272b030a6d9789794faf4fa059355e78c3803666554cfd6e67a01d57057e4313862c6328789eb1ef182b21307b40b16dbcbac8b393098a15fab8409fb332158b68ddb64d3a6ccc5c3ffbfbcc1be77e7ec0c0d694824502fa1c590e9f9c2a660f32753fcd91cb8179dbaf9b2afabb5823cc5aeba118dde131bf4e5ce25ae4009bbdecdaf44d103a3ad821806401f0a284ecf6ec88bf423ff458e71dfd63164c5fe701f4176be3baf99e7b864d042b217838a33704dbe41063b4f6ef4f7432242e8d32af661d23c1667c507f4589d72bee9eb1f3c8b97294f9c19c591c2da40a147458df15262b1c3bad768b044448798782a22ba9c30aa185589150c92ef650edce2cdd828892bffbec62477ecde9362a9b96e65daf9d818afbc66f6bf5aedeffb6e4ba2912d87540bdfa7c464f381d2efab30875c6ab77a9edaa0d3d7ae1068574d7281a53ff1ea14592a264e41064fdb2ee3b0744df03c281b4171697751c7fc8d55af55d9b8ef437bdafdb4b4dc0389fa5abd4b734edd66a205fee2c14a8dc926dc8b0f651d8fbef807a42152d6d92af99f057c18d2b2ea62a7bfcccc21a383968b08b1fee9d2c34ac7adf0b2048c05859819c88fc364c18f4ceaa037bc1f82b0756121bd2b10f9c130bb4969e084300de2dde3deff85221ebb403d5ae10e14b6348e63cd8526a3f103acfbc4545081a47b5d8c2f212cdf4c1988ec3de7d5ff90f50a9e9e67e9a08049f0e9a21a518ea1ef80441a27f86e3af4ad8ed8caa71d8a3fce0521618f819aeffbc1b6db20f1fcb210893d8681b8561d01c02cf70465b8b215f091f1555979$1822$5d00100000
3
  • This thread has some clues to the (non-)existent password limit: forum.altap.cz/viewtopic.php?t=4118 Aug 22, 2023 at 14:44
  • The hash doesnt match the password. At least Hashcat doesnt crack the hash using a dict, only containing your password. Aug 22, 2023 at 15:38
  • You can be creative with a Hashcat mask attack, replace some characters of your expected password with a charset variable. Assuming theres just a typo, you can crack the password fairly easy with that method. Aug 22, 2023 at 15:39

2 Answers 2

1

Assuming the hash is correct and you just forgot some characters in the supposed password, or added some too much, your password can be recovered using Hashcat within a reasonable time.

I already tried your password, Hashcat doesn't crack the hash using a dict, only containing your password, so there must be something like a typo.

Determine hash type

I saved your 7z hash in hash. To determine its exact hash type -m, you can run hashcat --identify hash. This will return

      # | Name                                                       | Category
  ======+============================================================+======================================
  11600 | 7-Zip                                                      | Archive

Dictionary Attack

The first thing you should try is checking whether you accidently added a character to your password. To check that we create a dictionary based on the presumable password but with an increasing amount of chars iteratively removed.

This can be done using this simple Python script.


original_string = "4^^#iy3N3Et9LG$3kws!Qqz$VN$WF8r5h5$dS9FM$2JfQUjkmd%2778#X3&M"

# Specify the output file path
output_file_path = "wordlist.lst"

# Open the file for writing
with open(output_file_path, "a") as output_file:
        # iterating from 3 to 59 (length of password - 1)
    for j in range(1, 59):
        # iterating through string length
        for i in range(len(original_string)-j):
            
            # modified_string = original_string up to the 'i'th char + original_string, starting from the 'i'th + 'j'th character until the end
            modified_string = original_string[:i] + original_string[i+j:]
            output_file.write(modified_string + "\n")

    # What this double for loop does, is it takes your "password", removes the 1st char, then the second one and so on.
    # After that, the same procedure, but now 2 chars are replaced by ?a and this goes on for up to 59 chars being removed. (Sure it's very unlikely/up to impossible you accidently added 59 false characters to your pw,
    # but it does not increase cracking time drastically either)



print(f"Variations written to {output_file_path}")

Now we also check for and remove duplicate lines with the following script

file_name = 'input.txt'  # Replace with your file name

with open(file_name, 'r') as file:
        lines = file.readlines()

lines = list(dict.fromkeys(lines))  # Removes duplicates while preserving order

with open(file_name, 'w') as file:
        file.writelines(lines)

print(f"Duplicate lines removed in '{file_name}'.")


Use -m to specify the hash mode and -a0to specify that we will run a dictionary attack. Use hashcat -I to see all available devices and then the -D flag to specify all available devices.

Now we will start the dictionary attack using hashcat -m11600 hash -a0 wordlist.lst -D <device ids here, seperated by a comma

(I also needed to set the flag --self-test-disable in order to work)

Mask attack

If the dictionary attack did not find your password, we need to move to a more advanced method, the mask attack.

With the mask attack, we will take your password and replace every char with ?a, one of the built-in charsets, iteratively, to check for typos.

Built-in charsets

    ?l = abcdefghijklmnopqrstuvwxyz
    ?u = ABCDEFGHIJKLMNOPQRSTUVWXYZ
    ?d = 0123456789
    ?h = 0123456789abcdef
    ?H = 0123456789ABCDEF
    ?s = «space»!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~
    ?a = ?l?u?d?s
    ?b = 0x00 - 0xff

Then we will do the same with 2 chars at a time again and so on, theoretically until we have all chars of the password except 1 replaced with ?a, since this is extremely performance intensive, we will crop the replacement at 10 chars maximum.

After that, we will do the exact same, but without replacing the char, so just adding a ?a in between the password.

In this script, both tasks will be combined, look at the comments of the code for more information.


original_string = "4^^#iy3N3Et9LG$3kws!Qqz$VN$WF8r5h5$dS9FM$2JfQUjkmd%2778#X3&M"

# Specify the output file path
output_file_path = "masks"

# Open the file for writing
with open(output_file_path, "a") as output_file:
        # iterating from 3 to 10 
    for j in range(3, 10):
            # iterating through string length
        for i in range(len(original_string)-j):
            
            # modified_string = original_string up to the 'i'th char + '?a' multiplied by j + original_string from the 'i'th + 'j'th character until the end
            # A
            modified_string = original_string[:i] + '?a'*j + original_string[i+j:]
            output_file.write(modified_string + "\n")
            
            # B
            modified_string = original_string[:i] + '?a'*j + original_string[i+j+1:]
            output_file.write(modified_string + "\n")

    # (SEE A)
    # What this double for loop does, is it takes your "password", replaces the first char with '?a' (= Hashcat tries every char), then the second one and so on.
    # After that, the same procedure, but now 2 chars are replaced by ?a and this goes on for up to 10 chars being replaced.

    # I was lying, actually this described procedure is directly starting at replacing the first 3 chars since anything lower than that would be a bottle neck for Hashcat

    # (SEE B)
    # And now all of those steps again, but no chars will be replaced, just added in between (to check if just a char is missing)


print(f"Variations written to {output_file_path}")

Now we will also again remove duplicates using the script before.

After that change to flag to -a3 to specify mask attack and run hashcat -m11600 hash -a3 masks -D <again devices here>

Hint: The flag -O would provide a better cracking performance but isn't available for this password length.

0

The various formats in John have different maximum length inputs that they support. You can see this with --list=format-details or --list=format-all-details:

$ john --list=format-all-details --format=7z
Format label                         7z
[...]
Min. password length                 0
Max. password length                 28

So although you could try various rules or other tools to try and create permutations of that password, John won't be able to test those passwords against your archive.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .