Added challenge 246

This commit is contained in:
Michael Chen 2022-05-17 13:03:54 +02:00
parent afc0a0347d
commit 42e2486143
No known key found for this signature in database
GPG Key ID: FD1BAF55F0CBDCF9
2 changed files with 29 additions and 0 deletions

2
246/level2.flag.txt.enc Normal file
View File

@ -0,0 +1,2 @@
 TY'1qM :
X:]RW]J

27
246/level2.py Normal file
View File

@ -0,0 +1,27 @@
### THIS FUNCTION WILL NOT HELP YOU FIND THE FLAG --LT ########################
def str_xor(secret, key):
#extend key to secret length
new_key = key
i = 0
while len(new_key) < len(secret):
new_key = new_key + key[i]
i = (i + 1) % len(key)
return "".join([chr(ord(secret_c) ^ ord(new_key_c)) for (secret_c,new_key_c) in zip(secret,new_key)])
###############################################################################
flag_enc = open('level2.flag.txt.enc', 'rb').read()
def level_2_pw_check():
user_pw = input("Please enter correct password for flag: ")
if( user_pw == chr(0x64) + chr(0x65) + chr(0x37) + chr(0x36) ):
print("Welcome back... your flag, user:")
decryption = str_xor(flag_enc.decode(), user_pw)
print(decryption)
return
print("That password is incorrect")
level_2_pw_check()