Completed challenge 238
This commit is contained in:
parent
2e84218428
commit
e74d98615f
43
238/code.py
Normal file
43
238/code.py
Normal file
@ -0,0 +1,43 @@
|
||||
|
||||
import random
|
||||
import sys
|
||||
|
||||
|
||||
|
||||
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 = chr(0x13) + chr(0x01) + chr(0x17) + chr(0x07) + chr(0x2c) + chr(0x3a) + chr(0x2f) + chr(0x1a) + chr(0x0d) + chr(0x53) + chr(0x0c) + chr(0x47) + chr(0x0a) + chr(0x5f) + chr(0x5e) + chr(0x02) + chr(0x3e) + chr(0x5a) + chr(0x56) + chr(0x5d) + chr(0x45) + chr(0x5d) + chr(0x58) + chr(0x31) + chr(0x0d) + chr(0x58) + chr(0x0f) + chr(0x02) + chr(0x5a) + chr(0x10) + chr(0x0e) + chr(0x5d) + chr(0x13)
|
||||
|
||||
|
||||
|
||||
def print_flag():
|
||||
try:
|
||||
codebook = open('codebook.txt', 'r').read()
|
||||
|
||||
password = codebook[4] + codebook[14] + codebook[13] + codebook[14] +\
|
||||
codebook[23]+ codebook[25] + codebook[16] + codebook[0] +\
|
||||
codebook[25]
|
||||
|
||||
flag = str_xor(flag_enc, password)
|
||||
print(flag)
|
||||
except FileNotFoundError:
|
||||
print('Couldn\'t find codebook.txt. Did you download that file into the same directory as this script?')
|
||||
|
||||
|
||||
|
||||
def main():
|
||||
print_flag()
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
1
238/codebook.txt
Normal file
1
238/codebook.txt
Normal file
@ -0,0 +1 @@
|
||||
azbycxdwevfugthsirjqkplomn
|
Loading…
Reference in New Issue
Block a user