Skip to content

Instantly share code, notes, and snippets.

@Ivlyth
Forked from gabemarshall/excel.py
Last active August 29, 2015 14:26
Show Gist options
  • Save Ivlyth/ea528306c5ff325c12f2 to your computer and use it in GitHub Desktop.
Save Ivlyth/ea528306c5ff325c12f2 to your computer and use it in GitHub Desktop.
Cracking a password protected excel doc with python
import sys
import win32com.client
openedDoc = win32com.client.Dispatch("Excel.Application")
filename= sys.argv[1]
password_file = open ( 'wordlist.lst', 'r' )
passwords = password_file.readlines()
password_file.close()
passwords = [item.rstrip('\n') for item in passwords]
results = open('results.txt', 'w')
for password in passwords:
print(password)
try:
wb = openedDoc.Workbooks.Open(filename, False, True, None, password)
print("Success! Password is: "+password)
results.write(password)
results.close()
except:
print("Incorrect password")
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment