From e67a2071769f49ccb5edcc6251900b70901e1b4b Mon Sep 17 00:00:00 2001
From: Li
Date: Tue, 21 Nov 2023 16:02:03 +1300
Subject: [PATCH] Add files via upload
---
crackSheetProt.py | 65 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 65 insertions(+)
create mode 100644 crackSheetProt.py
diff --git a/crackSheetProt.py b/crackSheetProt.py
new file mode 100644
index 0000000..1d7b69a
--- /dev/null
+++ b/crackSheetProt.py
@@ -0,0 +1,65 @@
+import sys
+import itertools
+import struct
+import string
+import olefile
+
+def excel_hash(password):
+ result = 0
+ MAX_UINT16 = 0xFFFF
+
+ if len(password) <= MAX_UINT16:
+ for c in password[::-1]:
+ result = ((result >> 14) & 0x01) | ((result << 1) & 0x7FFF)
+ result ^= ord(c)
+
+ result = ((result >> 14) & 0x01) | ((result << 1) & 0x7FFF)
+ result ^= (0x8000 | (ord('N') << 8) | ord('K'))
+ result ^= len(password)
+
+ return result
+
+def crack_password(targetHash):
+ for combLen in range(0, 6):
+ for combination in itertools.product(string.printable, repeat=combLen):
+ attempt = ''.join(combination)
+ gotHash = excel_hash(attempt)
+ if gotHash == targetHash:
+ return attempt
+
+def extract_sheet_hashes(stream):
+ hashes = []
+ while True:
+ pos = stream.tell()
+ if pos >= stream.size:
+ break # eof
+ try:
+ type = struct.unpack("= 1:
+ for hash in hashes:
+ if hash == 0:
+ continue
+ print("FOUND PASSWORD: "+crack_password(hash))
+
+ stream.close()
+ ole.close()
+
+if __name__ == "__main__":
+ if len(sys.argv) <= 1:
+ print("Usage: crackSheetProt.py ")
+ sys.exit()
+ read_xls(sys.argv[1])
\ No newline at end of file