Search code examples
batch-filecmd7zipwinrar

How to loop through every combination of two characters in Batch?


I have a zip which is password protected. I want to run a batch file which will brute force attack on the zipped file and extract the files trying every password of upto two letters only.

Something like

FOR %%I in a to zz
7zip e test.7z -p"%%I"

Solution

  • for %%I in (a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) do (
         for %%J in (a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) do (
              7z.exe x "D:/old.7z" -p"%%I%%J" 
    ))
    pause
    

    Though this is a long and filthy one It will work