Created
October 26, 2021 08:44
-
-
Save bryanseah234/4c4934364c7581b7f1fea998c82393c2 to your computer and use it in GitHub Desktop.
attack-password-code (code to crack passwords for zip files)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import zipfile | |
charlist = 'abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ' #ALPHANUMERICAL ONLY (CAN ADD MORE) | |
complete = [] | |
for current in range(4): #MAX PASSWORD LENGTH = 4 | |
a = [i for i in charlist] | |
for x in range(current): | |
a = [y + i for i in charlist for y in a] | |
complete = complete + a | |
z = zipfile.ZipFile('filename') #INPUT THE NAME OF YOUR ZIP FILE (MUST BE IN SAME DIRECTORY) | |
tries = 0 | |
for password in complete: | |
try: | |
tries += 1 | |
print(f'Try number {tries}...') | |
password = password.strip("\n") | |
z.setpassword(password.encode('ascii')) | |
z.extract('This is it.docx') #NAME OF FILE(S) INSIDE ZIP | |
print(f'Password is -- {password} -- after {tries}!') | |
except: | |
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import zipfile | |
import itertools | |
z = zipfile.ZipFile('filename') #INPUT THE NAME OF YOUR ZIP FILE (MUST BE IN SAME DIRECTORY) | |
wordlist = [] | |
keywords = [] #INPUT POSSIBLE KEYWORDS YOU HAVE | |
combinations = itertools.combinations(keywords, 2) | |
for combination in combinations: | |
wordlist.append(combination[0]+combination[1]) | |
with open('1.txt', 'r', encoding="utf8") as f: #INPUT THE NAME OF YOUR WORDLISTS | |
words1 = f.readlines() | |
for i in words1: | |
wordlist.append(i) | |
with open('2.txt', 'r', encoding="utf8") as f: #INPUT THE NAME OF YOUR WORDLISTS | |
words2 = f.readlines() | |
for j in words2: | |
wordlist.append(words2) | |
with open('3.txt', 'r', encoding="utf8") as f: #INPUT THE NAME OF YOUR WORDLISTS | |
words3 = f.readlines() | |
for k in words3: | |
wordlist.append(words3) | |
# print(wordlist) | |
tries = 0 | |
for word in wordlist: | |
try: | |
tries += 1 | |
print(f'Try number {tries}...') | |
word = word.strip("\n") | |
z.setpassword(word.encode('ascii')) | |
z.extract('This is it.docx') #NAME OF FILE(S) INSIDE ZIP | |
print(f'Password is -- {word} -- after {tries}!') | |
except: | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment