-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathbruteforce-worksheet.py
More file actions
31 lines (24 loc) · 938 Bytes
/
bruteforce-worksheet.py
File metadata and controls
31 lines (24 loc) · 938 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import win32com.client
import time
excel_file = r'C:\Code\YouTube\python-brute-force-excel-password\Book1.xlsx'
password_file = r'C:\Code\YouTube\python-brute-force-excel-password\passwords.txt'
excel = win32com.client.Dispatch('Excel.Application')
password_list = []
# extract passwords from file and load to list object
with open(password_file, 'r', encoding='utf-8') as pwd:
passwords = pwd.readlines()
for password in passwords:
password_list.append(password.replace('\n', ''))
wb = excel.Workbooks.Open(excel_file, False, True, None)
for password in password_list:
try:
wb = excel.Workbooks.Open(excel_file, False, True, None)
ws = wb.Sheets(1)
ws.Unprotect(password)
print('Successfully Password: ', password)
excel.Quit()
time.sleep(1)
quit()
except:
continue
print('Password not able to unlock Worksheet')