Changed the way the decryption worked to allow 3 different lines to try on each line of the wordlist
This commit is contained in:
@@ -10,7 +10,10 @@ decrypted_workbook = io.BytesIO()
|
|||||||
colors = ["black", "red", "green", "yellow", "blue", "magenta", "cyan", "white", "light_grey", "dark_grey", "light_red",
|
colors = ["black", "red", "green", "yellow", "blue", "magenta", "cyan", "white", "light_grey", "dark_grey", "light_red",
|
||||||
"light_green", "light_yellow", "light_blue", "light_magenta", "light_cyan"]
|
"light_green", "light_yellow", "light_blue", "light_magenta", "light_cyan"]
|
||||||
|
|
||||||
global total_processes
|
total_processes = 0
|
||||||
|
total_decrypt_attempts = 0
|
||||||
|
|
||||||
|
update_rate = 100000
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Get a color for a process using an array
|
Get a color for a process using an array
|
||||||
@@ -26,10 +29,10 @@ Calculates and prints the number of iterations per seconds
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
def calculate_speed(processNumbar, start_time, iterations, word):
|
def calculate_speed(processNumbar, start_time, last_update, word):
|
||||||
elapsed_time = time.time() - start_time
|
elapsed_time = time.time() - start_time
|
||||||
if elapsed_time > 0:
|
if elapsed_time > 0:
|
||||||
loop_speed = iterations / elapsed_time
|
loop_speed = (total_decrypt_attempts - last_update) / elapsed_time
|
||||||
buifulNumbar = '{:,}'.format(round(loop_speed)).replace(',', ' ')
|
buifulNumbar = '{:,}'.format(round(loop_speed)).replace(',', ' ')
|
||||||
print_thread(processNumbar, "Loop speed: " + buifulNumbar + " iterations per second (at word " + word + ")")
|
print_thread(processNumbar, "Loop speed: " + buifulNumbar + " iterations per second (at word " + word + ")")
|
||||||
|
|
||||||
@@ -43,6 +46,31 @@ def print_thread(processNumbar, text):
|
|||||||
cprint("[" + str(processNumbar) + "/" + str(total_processes) + "] " + text, get_color(processNumbar))
|
cprint("[" + str(processNumbar) + "/" + str(total_processes) + "] " + text, get_color(processNumbar))
|
||||||
|
|
||||||
|
|
||||||
|
"""
|
||||||
|
Decryption function
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
def decrypt_file(file, text):
|
||||||
|
global total_decrypt_attempts
|
||||||
|
total_decrypt_attempts = total_decrypt_attempts + 1 # Global loop iterations
|
||||||
|
try:
|
||||||
|
file.load_key(password=text)
|
||||||
|
file.decrypt(decrypted_workbook)
|
||||||
|
return True
|
||||||
|
except Exception as e:
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
"""
|
||||||
|
Gets multiple different lines to decrypt
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
def get_lines(line):
|
||||||
|
return [line, line.lower(), line.upper()]
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Global function of a child process
|
Global function of a child process
|
||||||
"""
|
"""
|
||||||
@@ -57,27 +85,34 @@ def worldlist_bruteforce_partial(fileToCrack, wordlistPath, total_proc, processN
|
|||||||
office_file = msoffcrypto.OfficeFile(file)
|
office_file = msoffcrypto.OfficeFile(file)
|
||||||
|
|
||||||
# First definitions...
|
# First definitions...
|
||||||
i = 0
|
last_update = total_decrypt_attempts
|
||||||
iterations = 0
|
|
||||||
start_time = time.time()
|
start_time = time.time()
|
||||||
|
|
||||||
# Opens the wordlist and begins cracking
|
# Opens the wordlist and begins cracking
|
||||||
with open(wordlistPath, 'r', encoding='latin_1') as wordlistToUse:
|
with open(wordlistPath, 'r', encoding='latin_1') as wordlistToUse:
|
||||||
# Find the right start position in the wordlist for this process
|
# Find the right start position in the wordlist for this process
|
||||||
print_thread(processNumbar, "Started new process [" + str(startPos) + " -> " + str(endPos) + "]")
|
print_thread(processNumbar, "Started new process [" + str(startPos) + " -> " + str(endPos) + "]")
|
||||||
|
|
||||||
wordlistToUse.seek(startPos)
|
wordlistToUse.seek(startPos)
|
||||||
|
# Move backward until a newline character is found or we reach the beginning of the file
|
||||||
|
position = startPos
|
||||||
|
while position > 0:
|
||||||
|
wordlistToUse.seek(position - 1)
|
||||||
|
|
||||||
|
if wordlistToUse.read(1) == '\n':
|
||||||
|
wordlistToUse.seek(position - 1)
|
||||||
|
break
|
||||||
|
position -= 1
|
||||||
|
|
||||||
# I love while True loops
|
# I love while True loops
|
||||||
while True:
|
while True:
|
||||||
i = i + 1 # Global loop iterations
|
|
||||||
iterations = iterations + 1 # Resets every status update
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
line = wordlistToUse.readline()
|
line = wordlistToUse.readline()
|
||||||
|
|
||||||
# End the thread if it has arrived to its given endPos
|
# End the thread if it has arrived to its given endPos
|
||||||
if wordlistToUse.tell() >= endPos:
|
if wordlistToUse.tell() >= endPos:
|
||||||
print_thread(processNumbar, "Thread done at line " + line + " with " + str(i) + " attempts.")
|
print_thread(processNumbar, "Thread done at line " + line + " with " + str(
|
||||||
|
total_decrypt_attempts) + " attempts.")
|
||||||
break
|
break
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e) # When a line fails to decode properly (Probably a wrong text encoding)
|
print(e) # When a line fails to decode properly (Probably a wrong text encoding)
|
||||||
@@ -91,17 +126,15 @@ def worldlist_bruteforce_partial(fileToCrack, wordlistPath, total_proc, processN
|
|||||||
line = line.rstrip() # Removes line endings
|
line = line.rstrip() # Removes line endings
|
||||||
|
|
||||||
# Print status every x lines read
|
# Print status every x lines read
|
||||||
if iterations == 100000:
|
if last_update == update_rate:
|
||||||
calculate_speed(processNumbar, start_time, iterations, line)
|
calculate_speed(processNumbar, start_time, last_update, line)
|
||||||
start_time = time.time()
|
start_time = time.time()
|
||||||
iterations = 0
|
last_update = 0
|
||||||
|
|
||||||
# Trying to decrypt the file
|
# Trying to decrypt the file
|
||||||
try:
|
for lineToDecrypt in get_lines(line):
|
||||||
office_file.load_key(password=line)
|
if decrypt_file(office_file, lineToDecrypt): # Decrypts
|
||||||
office_file.decrypt(decrypted_workbook)
|
print_thread(processNumbar,
|
||||||
print_thread(processNumbar,
|
"!!FOUNDPASSWORD!! \"" + lineToDecrypt + "\" with " + str(
|
||||||
"!!FOUNDPASSWORD!! \"" + line + "\" with " + str(i) + " attempts.")
|
total_decrypt_attempts) + " attempts.")
|
||||||
sys.exit(111) # Exit with found code
|
sys.exit(111) # Exit with found code
|
||||||
except Exception as e:
|
|
||||||
pass
|
|
||||||
|
|||||||
2
main.py
2
main.py
@@ -7,7 +7,7 @@ from child_process import worldlist_bruteforce_partial
|
|||||||
|
|
||||||
# ============ Setup ============ #
|
# ============ Setup ============ #
|
||||||
|
|
||||||
fileToCrack = "Aazaza.xls" # The file to crack
|
fileToCrack = "Base_MPP_Ouest_2013.xls" # The file to crack
|
||||||
wordlistPath = "rockyou.txt" # The wordlist to use
|
wordlistPath = "rockyou.txt" # The wordlist to use
|
||||||
num_threads = 16 # Number of processes to launch (should be the same as your number of cpu cores)
|
num_threads = 16 # Number of processes to launch (should be the same as your number of cpu cores)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user