From 1144db567f060af6289930f001d6cd4bb8a80075 Mon Sep 17 00:00:00 2001 From: Michael Chen Date: Tue, 17 May 2022 12:59:39 +0200 Subject: [PATCH] Added challenge 245 --- 245/level1.flag.txt.enc | Bin 0 -> 30 bytes 245/level1.py | 28 ++++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 245/level1.flag.txt.enc create mode 100644 245/level1.py diff --git a/245/level1.flag.txt.enc b/245/level1.flag.txt.enc new file mode 100644 index 0000000000000000000000000000000000000000..83dc710d9549d1123560b684001458413e8795ff GIT binary patch literal 30 lcmeZ>3yP^uF8APNW{FOBWr&Suiw{X>3ucT9X6NSi0sw$G2U`FD literal 0 HcmV?d00001 diff --git a/245/level1.py b/245/level1.py new file mode 100644 index 0000000..8e3145e --- /dev/null +++ b/245/level1.py @@ -0,0 +1,28 @@ +### 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('level1.flag.txt.enc', 'rb').read() + + + +def level_1_pw_check(): + user_pw = input("Please enter correct password for flag: ") + if( user_pw == "8713"): + print("Welcome back... your flag, user:") + decryption = str_xor(flag_enc.decode(), user_pw) + print(decryption) + return + print("That password is incorrect") + + + +level_1_pw_check()