-
Notifications
You must be signed in to change notification settings - Fork 0
/
excel_pw_bruteforce.py
75 lines (53 loc) · 1.94 KB
/
excel_pw_bruteforce.py
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#WRITTEN BY: ALI ALNUAIMI ~ https://www.linkedin.com/in/ali-alnuaimi-9847a1164/
#OBJECTIVE:
#brute force password protected excel files.
#USAGE:
#1- CMD: Enter the folder where this script is located
#2- CMD: Type "excel_pw_bruteforce.py" and follow the instructions
#REQUIREMENTS: Below libraries to be installed "pip install <lib_name>"
#NOTES: FOR EDUCATION PURPOSES ONLY
import tempfile, shutil, os
import random
from win32com.client import Dispatch
def create_temporary_copy(path):
temp_dir = tempfile.gettempdir()
temp_path = os.path.join(temp_dir, str(random.randint(1, 100000)) + 'temp_file_name.xlsx')
shutil.copy2(path, temp_path)
return temp_path
def find_excel_password(file, password_list):
print ("Starting ...")
instance = Dispatch('Excel.Application')
temp_file = create_temporary_copy(file)
for pw in password_list:
try:
print("Attempting: " + pw.strip())
instance.Workbooks.Open(temp_file, False, True, None, pw.strip())
print ("Password Found!: " + pw.strip())
print ("Stopping...")
break
except:
pass
try:
instance.Workbooks.Close(SaveChanges = 0)
except:
pass
instance.Quit()
os.remove(temp_file)
if __name__ == '__main__':
file = ""
password_list = []
while True:
input1 = input('File to bruteforce (.xlsx): ')
if (input1.split(".")[-1] == "xlsx" and os.path.exists(input1)):
file = input1
break
else:
print ("File type not supported or file doesn't exist")
while True:
input2 = input('Wordlist (.txt): ')
if (input2.split(".")[-1] == "txt" and os.path.exists(input2)):
password_list = open(input2,'r').read().splitlines()
break
else:
print ("File type not supported or file doesn't exist")
find_password(file, password_list)