How to crack a password archive yourself

CPAP


There is an archive and you need to extract the contents, but the password is forgotten. You can google and trust different programs ( one , two , three ), but

The only way to crack the RAR archive is brute force.

Initial data


Archive, password dictionary (and if you put% username% into the archive, do not forget to add your frequently used ones, only locally! ).


Procedure


From previous articles:


โ€“ , 262144 SHA1, WinRAR ( AES) ( ). , CRC32, , . โ€“ , , . RAR โ€” ยซ ยป.

. WinRAR , .

Therefore, the algorithm in the first version will be simple: open the file with passwords and iterate over the passwords for the archive until it breaks.


Do not forget that we use Go .
Password file


dictFile, err := os.Open(dictionary)
if err != nil {
    log.Fatalln(err)
    }
defer dictFile.Close()

Archive itself


zipr, err := zip.OpenReader(zipfile)
if err != nil {
    log.Fatal(err)
}

And our super algorithm


scanner := bufio.NewScanner(dictFile)
for scanner.Scan() {
    pass := scanner.Text()
    for _, z := range zipr.File {
        z.SetPassword(pass)
        _, err := z.Open()
        //   
        if err == nil {
            println("[+] Found password")
            println("[+] Password = " + pass)
            os.Exit(0)
        }
    }

And if the password is in the archive - voila!


Blackjack and multithreading version


There is an even more interesting version - with multithreading and goroutines.


The repository has 63 more sophisticated utilities on various topics. And if you have ideas what to add - write.


UPD


Multiple subtraction is the most reliable way to avoid mistakes. Thanks to everyone who responded.


All Articles