Skip to content

Instantly share code, notes, and snippets.

@gabemarshall
Created March 5, 2014 17:31
Show Gist options
  • Save gabemarshall/9372073 to your computer and use it in GitHub Desktop.
Save gabemarshall/9372073 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
@CaioEuzebio
Copy link

@datatalking, i think that this code Just work on WInd as a VBA, because If plan is XLSM forgot any others SOs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment