mirror of
https://github.com/bvanroll/odiseectf.git
synced 2025-08-29 03:42:41 +00:00
idk
This commit is contained in:
84
uncrackable/New folder/decryptAESCBC.py
Normal file
84
uncrackable/New folder/decryptAESCBC.py
Normal file
@@ -0,0 +1,84 @@
|
||||
#!python3
|
||||
import sys
|
||||
import os
|
||||
import getpass
|
||||
from Cryptodome.Cipher import AES
|
||||
from Cryptodome.Hash import MD5, SHA256
|
||||
from itertools import product
|
||||
|
||||
|
||||
for group in list(product('azertyuiop', repeat = 6)):
|
||||
global passw
|
||||
passw = ''.join(group)
|
||||
print(passw + '\n')
|
||||
|
||||
# generates key based on password
|
||||
def generatekey():
|
||||
|
||||
return bytes.fromhex('084b8b05fae51beed25806aacf738fea')
|
||||
#return bytes.fromhex('1aa4e2c69d19ef436f0058168823c2b8')
|
||||
|
||||
|
||||
# calculates and return hash for message
|
||||
def calculatehash(message):
|
||||
h = SHA256.new()
|
||||
h.update(message)
|
||||
# use hexdigest to prevent problems with control characters
|
||||
# e.g. \r in charcter 5, appends 4, then overwrites beginning of message with rest of digest
|
||||
return h.hexdigest()
|
||||
|
||||
|
||||
# check integrity and return cleartext or error message
|
||||
def checkintegrity(decryptedcontent):
|
||||
return calculatehash(decryptedcontent[0:-64]).encode() == decryptedcontent[-64:]
|
||||
|
||||
|
||||
# encrypts content in AES CBC mode
|
||||
def decrypt_AES_CBC(inputfilename, encryptedContent):
|
||||
# create encrypted filename, keep extension
|
||||
outputfilename = inputfilename[0:inputfilename.find('.', len(inputfilename) - 5)] \
|
||||
+ '_decrypted' + inputfilename[inputfilename.find('.'):len(inputfilename)]
|
||||
|
||||
key = generatekey()
|
||||
decipher = AES.new(key, AES.MODE_CBC)
|
||||
decryptedcontent = decipher.decrypt(encryptedContent)
|
||||
|
||||
ivlength = 16
|
||||
# remove iv and padding
|
||||
decryptedcontent = decryptedcontent[ivlength:-decryptedcontent[-1]]
|
||||
|
||||
# check Integrity and retain cleartext
|
||||
if checkintegrity(decryptedcontent):
|
||||
cleartext = decryptedcontent[0:-64]
|
||||
# write to file
|
||||
outputfile = open(outputfilename, 'wb')
|
||||
outputfile.write(cleartext)
|
||||
outputfile.close()
|
||||
else:
|
||||
cleartext = 'Integrity check error'.encode()
|
||||
|
||||
# useful only for decrypted text files
|
||||
# print(cleartext)
|
||||
|
||||
|
||||
|
||||
|
||||
for i in sys.argv[1:]:
|
||||
|
||||
inputfilename = i
|
||||
|
||||
print('decrypting ' + inputfilename)
|
||||
|
||||
try:
|
||||
inputfile = open(inputfilename, 'rb')
|
||||
except IOError:
|
||||
print("File " + inputfilename + " not found, working directory: " + os.getcwd())
|
||||
continue
|
||||
else:
|
||||
# if file opened, read content into variable
|
||||
content = inputfile.read()
|
||||
inputfile.close()
|
||||
|
||||
# apply symmetric encryption
|
||||
decrypt_AES_CBC(inputfilename, content)
|
||||
# encrypt_AES_ECB(inputfilename,content)
|
1
uncrackable/New folder/hash34.txt
Normal file
1
uncrackable/New folder/hash34.txt
Normal file
@@ -0,0 +1 @@
|
||||
084b8b05fae51beed25806aacf738fea
|
BIN
uncrackable/New folder/uncrackable34.png
Normal file
BIN
uncrackable/New folder/uncrackable34.png
Normal file
Binary file not shown.
BIN
uncrackable/New folder/uncrackable37.zip
Normal file
BIN
uncrackable/New folder/uncrackable37.zip
Normal file
Binary file not shown.
82
uncrackable/New folder/uncrackable37/decryptAESCBC.py
Normal file
82
uncrackable/New folder/uncrackable37/decryptAESCBC.py
Normal file
@@ -0,0 +1,82 @@
|
||||
import sys
|
||||
import os
|
||||
import getpass
|
||||
|
||||
from Crypto.Cipher import AES
|
||||
# from Crypto.Random import get_random_bytes, random
|
||||
# from Crypto.Util import Padding
|
||||
from Crypto.Hash import MD5, SHA256
|
||||
|
||||
|
||||
# generates key based on password
|
||||
def generatekey():
|
||||
password = getpass.getpass('Password for decryption: ')
|
||||
|
||||
h = MD5.new()
|
||||
h.update(''.join(password))
|
||||
|
||||
return h.digest()
|
||||
|
||||
|
||||
# calculates and return hash for message
|
||||
def calculatehash(message):
|
||||
h = SHA256.new()
|
||||
h.update(message)
|
||||
# use hexdigest to prevent problems with control characters
|
||||
# e.g. \r in charcter 5, appends 4, then overwrites beginning of message with rest of digest
|
||||
return h.hexdigest()
|
||||
|
||||
|
||||
# check integrity and return cleartext or error message
|
||||
def checkintegrity(decryptedcontent):
|
||||
return calculatehash(decryptedcontent[0:-64]) == decryptedcontent[-64:]
|
||||
|
||||
|
||||
# encrypts content in AES CBC mode
|
||||
def decrypt_AES_CBC(inputfilename, encryptedContent):
|
||||
# create encrypted filename, keep extension
|
||||
outputfilename = inputfilename[0:inputfilename.find('.', len(inputfilename) - 5)] + '_decrypted' + inputfilename[
|
||||
inputfilename.find(
|
||||
'.'):len(
|
||||
inputfilename)]
|
||||
|
||||
key = generatekey()
|
||||
decipher = AES.new(key, AES.MODE_CBC)
|
||||
decryptedcontent = decipher.decrypt(encryptedContent)
|
||||
|
||||
ivlength = 16
|
||||
# remove iv and padding
|
||||
decryptedcontent = decryptedcontent[ivlength:-ord(decryptedcontent[-1])]
|
||||
|
||||
# check Integrity and retain cleartext
|
||||
if checkintegrity(decryptedcontent):
|
||||
cleartext = decryptedcontent[0:-64]
|
||||
else:
|
||||
cleartext = 'Integrity check error'
|
||||
|
||||
# useful only for decrypted text files
|
||||
# print(cleartext)
|
||||
|
||||
# write to file
|
||||
outputfile = open(outputfilename, 'wb')
|
||||
outputfile.write(cleartext)
|
||||
outputfile.close()
|
||||
|
||||
|
||||
for i in sys.argv[1:]:
|
||||
|
||||
inputfilename = i
|
||||
|
||||
try:
|
||||
inputfile = open(inputfilename, 'rb')
|
||||
except IOError:
|
||||
print("File " + inputfilename + " not found, working directory: " + os.getcwd())
|
||||
continue
|
||||
else:
|
||||
# if file opened, read content into variable
|
||||
content = inputfile.read()
|
||||
inputfile.close()
|
||||
|
||||
# apply symmetric encryption
|
||||
decrypt_AES_CBC(inputfilename, content)
|
||||
# encrypt_AES_ECB(inputfilename,content)
|
1
uncrackable/New folder/uncrackable37/hash37.txt
Normal file
1
uncrackable/New folder/uncrackable37/hash37.txt
Normal file
@@ -0,0 +1 @@
|
||||
1aa4e2c69d19ef436f0058168823c2b8
|
BIN
uncrackable/New folder/uncrackable37/uncrackable37.png
Normal file
BIN
uncrackable/New folder/uncrackable37/uncrackable37.png
Normal file
Binary file not shown.
Reference in New Issue
Block a user